BIND 10 trac749, updated. ecb22c0c225d8da3710f4f912648acf401183cfa [trac749] update namespace names
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Apr 14 07:19:24 UTC 2011
The branch, trac749 has been updated
via ecb22c0c225d8da3710f4f912648acf401183cfa (commit)
from f5bcf535de7b23fd48061b9ee37580e2ac761f16 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ecb22c0c225d8da3710f4f912648acf401183cfa
Author: chenzhengzhang <jerry.zzpku at gmail.com>
Date: Thu Apr 14 15:15:55 2011 +0800
[trac749] update namespace names
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/auth_srv.cc | 4 +-
src/bin/auth/auth_srv.h | 2 +-
src/bin/auth/benchmarks/query_bench.cc | 4 +-
src/bin/auth/main.cc | 4 +-
src/bin/auth/tests/auth_srv_unittest.cc | 2 +-
src/bin/host/host.cc | 4 +-
src/bin/resolver/main.cc | 2 +-
src/bin/resolver/resolver.cc | 4 +-
src/bin/resolver/resolver.h | 2 +-
src/lib/asiolink/dns_answer.h | 2 +-
src/lib/asiolink/dns_lookup.h | 4 +-
src/lib/asiolink/io_asio_socket.h | 6 +-
src/lib/asiolink/io_fetch.cc | 4 +-
src/lib/asiolink/io_fetch.h | 4 +-
src/lib/asiolink/tcp_server.cc | 4 +-
src/lib/asiolink/tcp_server.h | 2 +-
src/lib/asiolink/tcp_socket.h | 14 ++--
src/lib/asiolink/tests/dns_server_unittest.cc | 4 +-
src/lib/asiolink/tests/io_fetch_unittest.cc | 6 +-
src/lib/asiolink/tests/tcp_socket_unittest.cc | 6 +-
src/lib/asiolink/tests/udp_socket_unittest.cc | 6 +-
src/lib/asiolink/udp_server.cc | 4 +-
src/lib/asiolink/udp_socket.h | 4 +-
src/lib/bench/benchmark_util.cc | 4 +-
src/lib/bench/tests/loadquery_unittest.cc | 4 +-
src/lib/cache/tests/cache_test_messagefromfile.h | 4 +-
src/lib/cache/tests/cache_test_sectioncount.h | 2 +-
src/lib/cache/tests/message_cache_unittest.cc | 4 +-
src/lib/cache/tests/message_entry_unittest.cc | 2 +-
src/lib/datasrc/data_source.cc | 10 ++--
src/lib/datasrc/query.cc | 2 +-
src/lib/datasrc/tests/datasrc_unittest.cc | 4 +-
src/lib/datasrc/tests/query_unittest.cc | 2 +-
src/lib/datasrc/tests/test_datasrc.cc | 2 +-
src/lib/dns/edns.cc | 6 +-
src/lib/dns/edns.h | 4 +-
src/lib/dns/gen-rdatacode.py.in | 6 +-
src/lib/dns/message.cc | 4 +-
src/lib/dns/message.h | 6 +-
src/lib/dns/messagerenderer.cc | 4 +-
src/lib/dns/messagerenderer.h | 4 +-
src/lib/dns/name.cc | 4 +-
src/lib/dns/name.h | 6 +-
src/lib/dns/python/edns_python.cc | 2 +-
src/lib/dns/python/message_python.cc | 2 +-
src/lib/dns/python/messagerenderer_python.cc | 2 +-
src/lib/dns/python/name_python.cc | 2 +-
src/lib/dns/python/pydnspp.cc | 2 +-
src/lib/dns/python/rdata_python.cc | 2 +-
src/lib/dns/python/rrclass_python.cc | 2 +-
src/lib/dns/python/rrset_python.cc | 2 +-
src/lib/dns/python/rrttl_python.cc | 2 +-
src/lib/dns/python/rrtype_python.cc | 2 +-
src/lib/dns/question.cc | 4 +-
src/lib/dns/question.h | 6 +-
src/lib/dns/rdata.cc | 10 ++--
src/lib/dns/rdata.h | 10 +--
src/lib/dns/rdata/any_255/tsig_250.cc | 8 +-
src/lib/dns/rdata/ch_3/a_1.cc | 4 +-
src/lib/dns/rdata/generic/cname_5.cc | 4 +-
src/lib/dns/rdata/generic/dname_39.cc | 4 +-
src/lib/dns/rdata/generic/dnskey_48.cc | 8 +-
src/lib/dns/rdata/generic/ds_43.cc | 8 +-
src/lib/dns/rdata/generic/mx_15.cc | 4 +-
src/lib/dns/rdata/generic/ns_2.cc | 4 +-
src/lib/dns/rdata/generic/nsec3_50.cc | 10 ++--
src/lib/dns/rdata/generic/nsec3param_51.cc | 8 +-
src/lib/dns/rdata/generic/nsec_47.cc | 8 +-
src/lib/dns/rdata/generic/opt_41.cc | 4 +-
src/lib/dns/rdata/generic/ptr_12.cc | 4 +-
src/lib/dns/rdata/generic/rrsig_46.cc | 10 ++--
src/lib/dns/rdata/generic/soa_6.cc | 4 +-
src/lib/dns/rdata/generic/txt_16.cc | 4 +-
src/lib/dns/rdata/hs_4/a_1.cc | 4 +-
src/lib/dns/rdata/in_1/a_1.cc | 4 +-
src/lib/dns/rdata/in_1/aaaa_28.cc | 4 +-
src/lib/dns/rdata/template.cc | 4 +-
src/lib/dns/rrclass-placeholder.h | 6 +-
src/lib/dns/rrclass.cc | 4 +-
src/lib/dns/rrparamregistry-placeholder.cc | 2 +-
src/lib/dns/rrparamregistry.h | 4 +-
src/lib/dns/rrset.cc | 4 +-
src/lib/dns/rrset.h | 6 +-
src/lib/dns/rrttl.cc | 4 +-
src/lib/dns/rrttl.h | 6 +-
src/lib/dns/rrtype-placeholder.h | 6 +-
src/lib/dns/rrtype.cc | 4 +-
src/lib/dns/tests/edns_unittest.cc | 4 +-
src/lib/dns/tests/message_unittest.cc | 4 +-
src/lib/dns/tests/messagerenderer_unittest.cc | 4 +-
src/lib/dns/tests/name_unittest.cc | 4 +-
src/lib/dns/tests/question_unittest.cc | 4 +-
src/lib/dns/tests/rdata_cname_unittest.cc | 4 +-
src/lib/dns/tests/rdata_dname_unittest.cc | 4 +-
src/lib/dns/tests/rdata_dnskey_unittest.cc | 4 +-
src/lib/dns/tests/rdata_ds_unittest.cc | 4 +-
src/lib/dns/tests/rdata_in_a_unittest.cc | 4 +-
src/lib/dns/tests/rdata_in_aaaa_unittest.cc | 4 +-
src/lib/dns/tests/rdata_mx_unittest.cc | 4 +-
src/lib/dns/tests/rdata_ns_unittest.cc | 4 +-
src/lib/dns/tests/rdata_nsec3_unittest.cc | 8 +-
src/lib/dns/tests/rdata_nsec3param_unittest.cc | 10 ++--
src/lib/dns/tests/rdata_nsec_unittest.cc | 4 +-
src/lib/dns/tests/rdata_opt_unittest.cc | 4 +-
src/lib/dns/tests/rdata_ptr_unittest.cc | 4 +-
src/lib/dns/tests/rdata_rrsig_unittest.cc | 8 +-
src/lib/dns/tests/rdata_soa_unittest.cc | 4 +-
src/lib/dns/tests/rdata_tsig_unittest.cc | 4 +-
src/lib/dns/tests/rdata_txt_unittest.cc | 4 +-
src/lib/dns/tests/rdata_unittest.cc | 4 +-
src/lib/dns/tests/rdata_unittest.h | 4 +-
src/lib/dns/tests/rrclass_unittest.cc | 4 +-
src/lib/dns/tests/rrparamregistry_unittest.cc | 2 +-
src/lib/dns/tests/rrset_unittest.cc | 4 +-
src/lib/dns/tests/rrttl_unittest.cc | 4 +-
src/lib/dns/tests/rrtype_unittest.cc | 4 +-
src/lib/log/compiler/message.cc | 8 +-
src/lib/log/message_reader.cc | 8 +-
src/lib/nsas/hash_table.h | 6 +-
src/lib/nsas/nameserver_entry.cc | 2 +-
src/lib/nsas/nameserver_entry.h | 2 +-
src/lib/nsas/tests/nsas_test.h | 4 +-
src/lib/nsas/zone_entry.cc | 2 +-
src/lib/nsas/zone_entry.h | 2 +-
src/lib/resolve/recursive_query.cc | 2 +-
src/lib/resolve/recursive_query.h | 4 +-
src/lib/resolve/tests/recursive_query_unittest.cc | 6 +-
.../resolve/tests/recursive_query_unittest_2.cc | 6 +-
src/lib/testutils/srv_test.cc | 2 +-
src/lib/testutils/srv_test.h | 6 +-
src/lib/util/Makefile.am | 20 +++---
src/lib/util/{io => }/buffer.h | 2 -
.../util/{compat => coder}/base16_from_binary.h | 0
src/lib/util/{compat => coder}/base32hex.h | 4 +-
.../util/{compat => coder}/base32hex_from_binary.h | 0
src/lib/util/{compat => coder}/base64.h | 4 +-
src/lib/util/{compat => coder}/base_n.cc | 16 ++--
.../util/{compat => coder}/binary_from_base16.h | 0
.../util/{compat => coder}/binary_from_base32hex.h | 0
src/lib/util/{compat => coder}/hex.h | 4 +-
src/lib/util/{compat => coder}/sha1.cc | 10 +++-
src/lib/util/{compat => coder}/sha1.h | 7 ++
src/lib/util/{compat => coder}/time_utilities.cc | 4 +-
src/lib/util/{compat => coder}/time_utilities.h | 2 +-
src/lib/util/filename.cc | 8 +-
src/lib/util/filename.h | 4 +-
src/lib/util/{io => }/io_utilities.h | 2 -
src/lib/util/locks.h | 12 ++-
src/lib/util/lru_list.h | 10 ++--
src/lib/util/strutil.cc | 6 +-
src/lib/util/strutil.h | 10 ++-
src/lib/util/tests/base32hex_unittest.cc | 4 +-
src/lib/util/tests/base64_unittest.cc | 4 +-
src/lib/util/tests/buffer_unittest.cc | 28 ++++----
src/lib/util/tests/hex_unittest.cc | 4 +-
src/lib/util/tests/io_utilities_unittest.cc | 6 +-
src/lib/util/tests/sha1_unittest.cc | 11 ++-
src/lib/util/tests/strutil_unittest.cc | 71 ++++++++++----------
src/lib/util/tests/time_utilities_unittest.cc | 6 +-
159 files changed, 420 insertions(+), 417 deletions(-)
rename src/lib/util/{io => }/buffer.h (99%)
rename src/lib/util/{compat => coder}/base16_from_binary.h (100%)
rename src/lib/util/{compat => coder}/base32hex.h (98%)
rename src/lib/util/{compat => coder}/base32hex_from_binary.h (100%)
rename src/lib/util/{compat => coder}/base64.h (98%)
rename src/lib/util/{compat => coder}/base_n.cc (98%)
rename src/lib/util/{compat => coder}/binary_from_base16.h (100%)
rename src/lib/util/{compat => coder}/binary_from_base32hex.h (100%)
rename src/lib/util/{compat => coder}/hex.h (98%)
rename src/lib/util/{compat => coder}/sha1.cc (99%)
rename src/lib/util/{compat => coder}/sha1.h (96%)
rename src/lib/util/{compat => coder}/time_utilities.cc (99%)
rename src/lib/util/{compat => coder}/time_utilities.h (99%)
rename src/lib/util/{io => }/io_utilities.h (98%)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc
index caef9a0..297d509 100644
--- a/src/bin/auth/auth_srv.cc
+++ b/src/bin/auth/auth_srv.cc
@@ -31,7 +31,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/edns.h>
#include <dns/exceptions.h>
@@ -64,7 +64,7 @@ using namespace isc;
using namespace isc::cc;
using namespace isc::datasrc;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::auth;
using namespace isc::dns::rdata;
using namespace isc::data;
diff --git a/src/bin/auth/auth_srv.h b/src/bin/auth/auth_srv.h
index 3d26eea..8ccd4dc 100644
--- a/src/bin/auth/auth_srv.h
+++ b/src/bin/auth/auth_srv.h
@@ -109,7 +109,7 @@ public:
/// \throw isc::Unexpected Protocol type of \a message is unexpected
void processMessage(const asiolink::IOMessage& io_message,
isc::dns::MessagePtr message,
- isc::util::io::OutputBufferPtr buffer,
+ isc::util::OutputBufferPtr buffer,
asiolink::DNSServer* server);
/// \brief Set verbose flag
diff --git a/src/bin/auth/benchmarks/query_bench.cc b/src/bin/auth/benchmarks/query_bench.cc
index fc98569..6421862 100644
--- a/src/bin/auth/benchmarks/query_bench.cc
+++ b/src/bin/auth/benchmarks/query_bench.cc
@@ -22,7 +22,7 @@
#include <bench/benchmark.h>
#include <bench/benchmark_util.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/question.h>
@@ -41,7 +41,7 @@ using namespace isc;
using namespace isc::data;
using namespace isc::auth;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::xfr;
using namespace isc::bench;
using namespace asiolink;
diff --git a/src/bin/auth/main.cc b/src/bin/auth/main.cc
index 3154b40..b47395f 100644
--- a/src/bin/auth/main.cc
+++ b/src/bin/auth/main.cc
@@ -25,7 +25,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/message.h>
#include <dns/messagerenderer.h>
@@ -50,7 +50,7 @@ using namespace isc::data;
using namespace isc::cc;
using namespace isc::config;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::xfr;
using namespace asiolink;
diff --git a/src/bin/auth/tests/auth_srv_unittest.cc b/src/bin/auth/tests/auth_srv_unittest.cc
index 41d9d65..4ac7352 100644
--- a/src/bin/auth/tests/auth_srv_unittest.cc
+++ b/src/bin/auth/tests/auth_srv_unittest.cc
@@ -41,7 +41,7 @@
using namespace std;
using namespace isc::cc;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
using namespace isc::data;
using namespace isc::xfr;
diff --git a/src/bin/host/host.cc b/src/bin/host/host.cc
index a8ec026..973509e 100644
--- a/src/bin/host/host.cc
+++ b/src/bin/host/host.cc
@@ -24,7 +24,7 @@
#include <string>
#include <iostream>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/name.h>
#include <dns/message.h>
@@ -38,7 +38,7 @@
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace {
char* dns_type = NULL; // not set, so A, AAAA, MX
diff --git a/src/bin/resolver/main.cc b/src/bin/resolver/main.cc
index 8a858de..ac6d441 100644
--- a/src/bin/resolver/main.cc
+++ b/src/bin/resolver/main.cc
@@ -29,7 +29,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/rcode.h>
#include <dns/message.h>
#include <dns/messagerenderer.h>
diff --git a/src/bin/resolver/resolver.cc b/src/bin/resolver/resolver.cc
index 51b27c1..f132a0d 100644
--- a/src/bin/resolver/resolver.cc
+++ b/src/bin/resolver/resolver.cc
@@ -29,7 +29,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/opcode.h>
#include <dns/rcode.h>
@@ -51,7 +51,7 @@
using namespace std;
using namespace isc;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns;
using namespace isc::data;
using namespace isc::config;
diff --git a/src/bin/resolver/resolver.h b/src/bin/resolver/resolver.h
index 30d222c..6d3e306 100644
--- a/src/bin/resolver/resolver.h
+++ b/src/bin/resolver/resolver.h
@@ -77,7 +77,7 @@ public:
void processMessage(const asiolink::IOMessage& io_message,
isc::dns::MessagePtr query_message,
isc::dns::MessagePtr answer_message,
- isc::util::io::OutputBufferPtr buffer,
+ isc::util::OutputBufferPtr buffer,
asiolink::DNSServer* server);
/// \brief Set and get the config session
diff --git a/src/lib/asiolink/dns_answer.h b/src/lib/asiolink/dns_answer.h
index b6c3211..e6e404d 100644
--- a/src/lib/asiolink/dns_answer.h
+++ b/src/lib/asiolink/dns_answer.h
@@ -66,7 +66,7 @@ public:
virtual void operator()(const IOMessage& io_message,
isc::dns::MessagePtr query_message,
isc::dns::MessagePtr answer_message,
- isc::util::io::OutputBufferPtr buffer) const = 0;
+ isc::util::OutputBufferPtr buffer) const = 0;
};
} // namespace asiolink
diff --git a/src/lib/asiolink/dns_lookup.h b/src/lib/asiolink/dns_lookup.h
index 99d75bd..2e87c4b 100644
--- a/src/lib/asiolink/dns_lookup.h
+++ b/src/lib/asiolink/dns_lookup.h
@@ -17,7 +17,7 @@
#include <asiolink/io_message.h>
#include <asiolink/dns_server.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/message.h>
namespace asiolink {
@@ -70,7 +70,7 @@ public:
virtual void operator()(const IOMessage& io_message,
isc::dns::MessagePtr message,
isc::dns::MessagePtr answer_message,
- isc::util::io::OutputBufferPtr buffer,
+ isc::util::OutputBufferPtr buffer,
DNSServer* server) const
{
(*self_)(io_message, message, answer_message, buffer, server);
diff --git a/src/lib/asiolink/io_asio_socket.h b/src/lib/asiolink/io_asio_socket.h
index 8aaabee..9d22990 100644
--- a/src/lib/asiolink/io_asio_socket.h
+++ b/src/lib/asiolink/io_asio_socket.h
@@ -26,7 +26,7 @@
#include <exceptions/exceptions.h>
#include <coroutine.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <asiolink/io_error.h>
#include <asiolink/io_socket.h>
@@ -270,7 +270,7 @@ public:
virtual bool processReceivedData(const void* staging, size_t length,
size_t& cumulative, size_t& offset,
size_t& expected,
- isc::util::io::OutputBufferPtr& outbuff) = 0;
+ isc::util::OutputBufferPtr& outbuff) = 0;
/// \brief Cancel I/O On AsioSocket
virtual void cancel() = 0;
@@ -372,7 +372,7 @@ public:
virtual bool receiveComplete(const void* staging, size_t length,
size_t& cumulative, size_t& offset,
size_t& expected,
- isc::util::io::OutputBufferPtr& outbuff)
+ isc::util::OutputBufferPtr& outbuff)
{
return (true);
}
diff --git a/src/lib/asiolink/io_fetch.cc b/src/lib/asiolink/io_fetch.cc
index bfa756e..f38a1f5 100644
--- a/src/lib/asiolink/io_fetch.cc
+++ b/src/lib/asiolink/io_fetch.cc
@@ -28,7 +28,7 @@
#include <dns/rcode.h>
#include <log/logger.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <util/random/qid_gen.h>
#include <asio.hpp>
@@ -49,7 +49,7 @@
using namespace asio;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::util::random;
using namespace isc::log;
using namespace std;
diff --git a/src/lib/asiolink/io_fetch.h b/src/lib/asiolink/io_fetch.h
index 19aee10..8a522d6 100644
--- a/src/lib/asiolink/io_fetch.h
+++ b/src/lib/asiolink/io_fetch.h
@@ -25,7 +25,7 @@
#include <asio/error_code.hpp>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/question.h>
namespace asiolink {
@@ -134,7 +134,7 @@ public:
/// -1 indicates no timeout.
IOFetch(Protocol protocol, IOService& service,
const isc::dns::Question& question, const IOAddress& address,
- uint16_t port, isc::util::io::OutputBufferPtr& buff, Callback* cb,
+ uint16_t port, isc::util::OutputBufferPtr& buff, Callback* cb,
int wait = -1);
/// \brief Return Current Protocol
diff --git a/src/lib/asiolink/tcp_server.cc b/src/lib/asiolink/tcp_server.cc
index 68af8e0..6ea862b 100644
--- a/src/lib/asiolink/tcp_server.cc
+++ b/src/lib/asiolink/tcp_server.cc
@@ -23,7 +23,7 @@
#include <log/dummylog.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <asio.hpp>
#include <asiolink/dummy_io_cb.h>
@@ -38,7 +38,7 @@ using asio::ip::tcp;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace asiolink {
diff --git a/src/lib/asiolink/tcp_server.h b/src/lib/asiolink/tcp_server.h
index 64e4dda..a4449f7 100644
--- a/src/lib/asiolink/tcp_server.h
+++ b/src/lib/asiolink/tcp_server.h
@@ -91,7 +91,7 @@ private:
boost::shared_ptr<asio::ip::tcp::socket> socket_;
// The buffer into which the response is written
- boost::shared_ptr<isc::util::io::OutputBuffer> respbuf_;
+ boost::shared_ptr<isc::util::OutputBuffer> respbuf_;
// \c IOMessage and \c Message objects to be passed to the
// DNS lookup and answer providers
diff --git a/src/lib/asiolink/tcp_socket.h b/src/lib/asiolink/tcp_socket.h
index 0b9ef69..3488cc5 100644
--- a/src/lib/asiolink/tcp_socket.h
+++ b/src/lib/asiolink/tcp_socket.h
@@ -33,8 +33,8 @@
#include <config.h>
-#include <util/io/buffer.h>
-#include <util/io/io_utilities.h>
+#include <util/buffer.h>
+#include <util/io_utilities.h>
#include <asiolink/io_asio_socket.h>
#include <asiolink/io_endpoint.h>
@@ -155,7 +155,7 @@ public:
virtual bool processReceivedData(const void* staging, size_t length,
size_t& cumulative, size_t& offset,
size_t& expected,
- isc::util::io::OutputBufferPtr& outbuff);
+ isc::util::OutputBufferPtr& outbuff);
/// \brief Cancel I/O On Socket
virtual void cancel();
@@ -185,7 +185,7 @@ private:
// The option of sending the data in two operations, the count followed by
// the data was discounted as that would lead to two callbacks which would
// cause problems with the stackless coroutine code.
- isc::util::io::OutputBufferPtr send_buffer_; ///< Send buffer
+ isc::util::OutputBufferPtr send_buffer_; ///< Send buffer
};
// Constructor - caller manages socket
@@ -268,7 +268,7 @@ TCPSocket<C>::asyncSend(const void* data, size_t length,
uint16_t count = boost::numeric_cast<uint16_t>(length);
// Copy data into a buffer preceded by the count field.
- send_buffer_.reset(new isc::util::io::OutputBuffer(length + 2));
+ send_buffer_.reset(new isc::util::OutputBuffer(length + 2));
send_buffer_->writeUint16(count);
send_buffer_->writeData(data, length);
@@ -333,7 +333,7 @@ template <typename C> bool
TCPSocket<C>::processReceivedData(const void* staging, size_t length,
size_t& cumulative, size_t& offset,
size_t& expected,
- isc::util::io::OutputBufferPtr& outbuff)
+ isc::util::OutputBufferPtr& outbuff)
{
// Point to the data in the staging buffer and note how much there is.
const uint8_t* data = static_cast<const uint8_t*>(staging);
@@ -358,7 +358,7 @@ TCPSocket<C>::processReceivedData(const void* staging, size_t length,
}
// Have enough data to interpret the packet count, so do so now.
- expected = isc::util::io::readUint16(data);
+ expected = isc::util::readUint16(data);
// We have two bytes less of data to process. Point to the start of the
// data and adjust the packet size. Note that at this point,
diff --git a/src/lib/asiolink/tests/dns_server_unittest.cc b/src/lib/asiolink/tests/dns_server_unittest.cc
index 2e07e3f..181387d 100644
--- a/src/lib/asiolink/tests/dns_server_unittest.cc
+++ b/src/lib/asiolink/tests/dns_server_unittest.cc
@@ -110,7 +110,7 @@ class DummyLookup : public DNSLookup, public ServerStopper {
void operator()(const IOMessage& io_message,
isc::dns::MessagePtr message,
isc::dns::MessagePtr answer_message,
- isc::util::io::OutputBufferPtr buffer,
+ isc::util::OutputBufferPtr buffer,
DNSServer* server) const {
stopServer();
server->resume(true);
@@ -124,7 +124,7 @@ class SimpleAnswer : public DNSAnswer, public ServerStopper {
void operator()(const IOMessage& message,
isc::dns::MessagePtr query_message,
isc::dns::MessagePtr answer_message,
- isc::util::io::OutputBufferPtr buffer) const
+ isc::util::OutputBufferPtr buffer) const
{
//copy what we get from user
buffer->writeData(message.getData(), message.getDataSize());
diff --git a/src/lib/asiolink/tests/io_fetch_unittest.cc b/src/lib/asiolink/tests/io_fetch_unittest.cc
index c65fc69..bec6104 100644
--- a/src/lib/asiolink/tests/io_fetch_unittest.cc
+++ b/src/lib/asiolink/tests/io_fetch_unittest.cc
@@ -26,8 +26,8 @@
#include <asio.hpp>
-#include <util/io/buffer.h>
-#include <util/io/io_utilities.h>
+#include <util/buffer.h>
+#include <util/io_utilities.h>
#include <dns/question.h>
#include <dns/message.h>
@@ -43,7 +43,7 @@
using namespace asio;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace asio::ip;
using namespace std;
diff --git a/src/lib/asiolink/tests/tcp_socket_unittest.cc b/src/lib/asiolink/tests/tcp_socket_unittest.cc
index 28f0d9e..1784aa2 100644
--- a/src/lib/asiolink/tests/tcp_socket_unittest.cc
+++ b/src/lib/asiolink/tests/tcp_socket_unittest.cc
@@ -35,8 +35,8 @@
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
-#include <util/io/buffer.h>
-#include <util/io/io_utilities.h>
+#include <util/buffer.h>
+#include <util/io_utilities.h>
#include <asio.hpp>
@@ -47,7 +47,7 @@
using namespace asio;
using namespace asio::ip;
using namespace asiolink;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace std;
namespace {
diff --git a/src/lib/asiolink/tests/udp_socket_unittest.cc b/src/lib/asiolink/tests/udp_socket_unittest.cc
index f006991..2170ab6 100644
--- a/src/lib/asiolink/tests/udp_socket_unittest.cc
+++ b/src/lib/asiolink/tests/udp_socket_unittest.cc
@@ -35,8 +35,8 @@
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
-#include <util/io/buffer.h>
-#include <util/io/io_utilities.h>
+#include <util/buffer.h>
+#include <util/io_utilities.h>
#include <asio.hpp>
@@ -46,7 +46,7 @@
using namespace asio;
using namespace asiolink;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace std;
namespace {
diff --git a/src/lib/asiolink/udp_server.cc b/src/lib/asiolink/udp_server.cc
index afbc754..5e9fe1d 100644
--- a/src/lib/asiolink/udp_server.cc
+++ b/src/lib/asiolink/udp_server.cc
@@ -38,7 +38,7 @@ using isc::log::dlog;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace asiolink {
@@ -135,7 +135,7 @@ struct UDPServer::Data {
isc::dns::MessagePtr answer_message_;
// The buffer into which the response is written
- isc::util::io::OutputBufferPtr respbuf_;
+ isc::util::OutputBufferPtr respbuf_;
// The buffer into which the query packet is written
boost::shared_array<char> data_;
diff --git a/src/lib/asiolink/udp_socket.h b/src/lib/asiolink/udp_socket.h
index c378ea7..a03d3d4 100644
--- a/src/lib/asiolink/udp_socket.h
+++ b/src/lib/asiolink/udp_socket.h
@@ -141,7 +141,7 @@ public:
virtual bool processReceivedData(const void* staging, size_t length,
size_t& cumulative, size_t& offset,
size_t& expected,
- isc::util::io::OutputBufferPtr& outbuff);
+ isc::util::OutputBufferPtr& outbuff);
/// \brief Cancel I/O On Socket
virtual void cancel();
@@ -283,7 +283,7 @@ template <typename C> bool
UDPSocket<C>::processReceivedData(const void* staging, size_t length,
size_t& cumulative, size_t& offset,
size_t& expected,
- isc::util::io::OutputBufferPtr& outbuff)
+ isc::util::OutputBufferPtr& outbuff)
{
// Set return values to what we should expect.
cumulative = length;
diff --git a/src/lib/bench/benchmark_util.cc b/src/lib/bench/benchmark_util.cc
index dbc28fd..c67a851 100644
--- a/src/lib/bench/benchmark_util.cc
+++ b/src/lib/bench/benchmark_util.cc
@@ -19,7 +19,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/name.h>
#include <dns/message.h>
@@ -35,7 +35,7 @@
using namespace std;
using namespace isc;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace isc {
namespace bench {
diff --git a/src/lib/bench/tests/loadquery_unittest.cc b/src/lib/bench/tests/loadquery_unittest.cc
index acb7ac2..93130d2 100644
--- a/src/lib/bench/tests/loadquery_unittest.cc
+++ b/src/lib/bench/tests/loadquery_unittest.cc
@@ -17,7 +17,7 @@
#include <vector>
#include <sstream>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/opcode.h>
@@ -32,7 +32,7 @@
using namespace std;
using namespace isc::bench;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace {
typedef pair<string, string> QueryParam;
diff --git a/src/lib/cache/tests/cache_test_messagefromfile.h b/src/lib/cache/tests/cache_test_messagefromfile.h
index 611386c..7d55f08 100644
--- a/src/lib/cache/tests/cache_test_messagefromfile.h
+++ b/src/lib/cache/tests/cache_test_messagefromfile.h
@@ -14,7 +14,7 @@
#include <vector>
#include <dns/tests/unittest_util.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/message.h>
using namespace isc;
@@ -31,7 +31,7 @@ messageFromFile(Message& message, const char* datafile) {
std::vector<unsigned char> data;
UnitTestUtil::readWireData(datafile, data);
- isc::util::io::InputBuffer buffer(&data[0], data.size());
+ isc::util::InputBuffer buffer(&data[0], data.size());
message.fromWire(buffer);
}
diff --git a/src/lib/cache/tests/cache_test_sectioncount.h b/src/lib/cache/tests/cache_test_sectioncount.h
index 6cb37a5..df7cb52 100644
--- a/src/lib/cache/tests/cache_test_sectioncount.h
+++ b/src/lib/cache/tests/cache_test_sectioncount.h
@@ -14,7 +14,7 @@
#include <vector>
#include <dns/tests/unittest_util.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/message.h>
using namespace isc;
diff --git a/src/lib/cache/tests/message_cache_unittest.cc b/src/lib/cache/tests/message_cache_unittest.cc
index c9f816f..60ae037 100644
--- a/src/lib/cache/tests/message_cache_unittest.cc
+++ b/src/lib/cache/tests/message_cache_unittest.cc
@@ -16,7 +16,7 @@
#include <string>
#include <gtest/gtest.h>
#include <dns/tests/unittest_util.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include "../message_cache.h"
#include "../rrset_cache.h"
#include "../resolver_cache.h"
@@ -25,7 +25,7 @@
using namespace isc::cache;
using namespace isc;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace std;
namespace {
diff --git a/src/lib/cache/tests/message_entry_unittest.cc b/src/lib/cache/tests/message_entry_unittest.cc
index cb6df76..d9709ed 100644
--- a/src/lib/cache/tests/message_entry_unittest.cc
+++ b/src/lib/cache/tests/message_entry_unittest.cc
@@ -15,7 +15,7 @@
#include <gtest/gtest.h>
#include <dns/tests/unittest_util.h>
#include <dns/message.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include "../message_entry.h"
#include "../rrset_cache.h"
#include "../resolver_cache.h"
diff --git a/src/lib/datasrc/data_source.cc b/src/lib/datasrc/data_source.cc
index c242ef5..aca35b9 100644
--- a/src/lib/datasrc/data_source.cc
+++ b/src/lib/datasrc/data_source.cc
@@ -26,9 +26,9 @@
#include <datasrc/data_source.h>
#include <datasrc/query.h>
-#include <util/compat/base32hex.h>
-#include <util/compat/sha1.h>
-#include <util/io/buffer.h>
+#include <util/coder/base32hex.h>
+#include <util/coder/sha1.h>
+#include <util/buffer.h>
#include <dns/message.h>
#include <dns/name.h>
@@ -46,8 +46,8 @@
} while (0)
using namespace std;
-using namespace isc::util::io;
-using namespace isc::util::compat;
+using namespace isc::util;
+using namespace isc::util::coder;
using namespace isc::dns;
using namespace isc::dns::rdata;
diff --git a/src/lib/datasrc/query.cc b/src/lib/datasrc/query.cc
index 86643b9..a8d675a 100644
--- a/src/lib/datasrc/query.cc
+++ b/src/lib/datasrc/query.cc
@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/name.h>
#include <dns/rrset.h>
#include <dns/message.h>
diff --git a/src/lib/datasrc/tests/datasrc_unittest.cc b/src/lib/datasrc/tests/datasrc_unittest.cc
index 8d36e73..01de77a 100644
--- a/src/lib/datasrc/tests/datasrc_unittest.cc
+++ b/src/lib/datasrc/tests/datasrc_unittest.cc
@@ -20,7 +20,7 @@
#include <gtest/gtest.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/message.h>
#include <dns/messagerenderer.h>
@@ -45,7 +45,7 @@
using isc::UnitTestUtil;
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns;
using namespace isc::dns::rdata;
using namespace isc::datasrc;
diff --git a/src/lib/datasrc/tests/query_unittest.cc b/src/lib/datasrc/tests/query_unittest.cc
index 5daccbf..7a20b86 100644
--- a/src/lib/datasrc/tests/query_unittest.cc
+++ b/src/lib/datasrc/tests/query_unittest.cc
@@ -14,7 +14,7 @@
#include <gtest/gtest.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/opcode.h>
diff --git a/src/lib/datasrc/tests/test_datasrc.cc b/src/lib/datasrc/tests/test_datasrc.cc
index 14f6afa..d78e7db 100644
--- a/src/lib/datasrc/tests/test_datasrc.cc
+++ b/src/lib/datasrc/tests/test_datasrc.cc
@@ -23,7 +23,7 @@
#include <datasrc/data_source.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/name.h>
#include <dns/rdata.h>
diff --git a/src/lib/dns/edns.cc b/src/lib/dns/edns.cc
index c6cb2cc..5405dab 100644
--- a/src/lib/dns/edns.cc
+++ b/src/lib/dns/edns.cc
@@ -36,7 +36,7 @@
using namespace std;
using namespace boost;
using namespace isc::dns::rdata;
-using namespace isc::util::io;
+using namespace isc::util;
namespace isc {
namespace dns {
@@ -144,8 +144,8 @@ EDNS::toWire(MessageRenderer& renderer, const uint8_t extended_rcode) const {
}
unsigned int
-EDNS::toWire(isc::util::io::OutputBuffer& buffer, const uint8_t extended_rcode) const {
- return (toWire<isc::util::io::OutputBuffer>(buffer, extended_rcode));
+EDNS::toWire(isc::util::OutputBuffer& buffer, const uint8_t extended_rcode) const {
+ return (toWire<isc::util::OutputBuffer>(buffer, extended_rcode));
}
EDNS*
diff --git a/src/lib/dns/edns.h b/src/lib/dns/edns.h
index fea0e2a..b794183 100644
--- a/src/lib/dns/edns.h
+++ b/src/lib/dns/edns.h
@@ -25,10 +25,8 @@
namespace isc {
namespace util {
-namespace io {
class OutputBuffer;
}
-}
namespace dns {
@@ -325,7 +323,7 @@ public:
/// except it renders the OPT RR in an \c OutputBuffer and therefore
/// does not care about message size limit.
/// As a consequence it always returns 1.
- unsigned int toWire(isc::util::io::OutputBuffer& buffer,
+ unsigned int toWire(isc::util::OutputBuffer& buffer,
const uint8_t extended_rcode) const;
/// \brief Convert the EDNS to a string.
diff --git a/src/lib/dns/gen-rdatacode.py.in b/src/lib/dns/gen-rdatacode.py.in
index 8eb3235..ff56735 100755
--- a/src/lib/dns/gen-rdatacode.py.in
+++ b/src/lib/dns/gen-rdatacode.py.in
@@ -87,11 +87,9 @@ def import_classheader(class_txt, type_txt, type_code, file):
if re.match('// BEGIN_ISC_NAMESPACE', line):
content += 'namespace isc {\n'
content += 'namespace util {\n'
- content += 'namespace io {'
content += '''
class InputBuffer;
class OutputBuffer;\n'''
- content += '}\n'
content += '}\n\n'
content += 'namespace dns {\n'
continue
@@ -116,10 +114,10 @@ class MessageRenderer;\n\n'''
if re.match('\s+// BEGIN_COMMON_MEMBERS$', line):
content += '''
explicit ''' + type_utxt + '''(const std::string& type_str);
- ''' + type_utxt + '''(isc::util::io::InputBuffer& buffer, size_t rdata_len);
+ ''' + type_utxt + '''(isc::util::InputBuffer& buffer, size_t rdata_len);
''' + type_utxt + '''(const ''' + type_utxt + '''& other);
virtual std::string toText() const;
- virtual void toWire(isc::util::io::OutputBuffer& buffer) const;
+ virtual void toWire(isc::util::OutputBuffer& buffer) const;
virtual void toWire(MessageRenderer& renderer) const;
virtual int compare(const Rdata& other) const;\n\n'''
rdata_header.close()
diff --git a/src/lib/dns/message.cc b/src/lib/dns/message.cc
index 3516f6a..d1025d1 100644
--- a/src/lib/dns/message.cc
+++ b/src/lib/dns/message.cc
@@ -25,7 +25,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/edns.h>
#include <dns/exceptions.h>
@@ -44,7 +44,7 @@
using namespace std;
using namespace boost;
using namespace isc::dns::rdata;
-using namespace isc::util::io;
+using namespace isc::util;
namespace isc {
namespace dns {
diff --git a/src/lib/dns/message.h b/src/lib/dns/message.h
index 2b6af9b..5601299 100644
--- a/src/lib/dns/message.h
+++ b/src/lib/dns/message.h
@@ -29,10 +29,8 @@
namespace isc {
namespace util {
-namespace io {
class InputBuffer;
}
-}
namespace dns {
@@ -534,10 +532,10 @@ public:
void toWire(MessageRenderer& renderer);
/// \brief Parse the header section of the \c Message.
- void parseHeader(isc::util::io::InputBuffer& buffer);
+ void parseHeader(isc::util::InputBuffer& buffer);
/// \brief Parse the \c Message.
- void fromWire(isc::util::io::InputBuffer& buffer);
+ void fromWire(isc::util::InputBuffer& buffer);
///
/// \name Protocol constants
diff --git a/src/lib/dns/messagerenderer.cc b/src/lib/dns/messagerenderer.cc
index eeb1f1c..9ae2d34 100644
--- a/src/lib/dns/messagerenderer.cc
+++ b/src/lib/dns/messagerenderer.cc
@@ -16,11 +16,11 @@
#include <cassert>
#include <set>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/name.h>
#include <dns/messagerenderer.h>
-using namespace isc::util::io;
+using namespace isc::util;
namespace isc {
namespace dns {
diff --git a/src/lib/dns/messagerenderer.h b/src/lib/dns/messagerenderer.h
index 41507aa..4d51eea 100644
--- a/src/lib/dns/messagerenderer.h
+++ b/src/lib/dns/messagerenderer.h
@@ -17,10 +17,8 @@
namespace isc {
namespace util {
-namespace io {
class OutputBuffer;
}
-}
namespace dns {
// forward declarations
@@ -106,7 +104,7 @@ public:
///
/// \param buffer An \c OutputBuffer object to which wire format data is
/// written.
- MessageRenderer(isc::util::io::OutputBuffer& buffer);
+ MessageRenderer(isc::util::OutputBuffer& buffer);
/// \brief The destructor.
///
/// The destructor does nothing on the given \c buffer on construction;
diff --git a/src/lib/dns/name.cc b/src/lib/dns/name.cc
index 5ff419c..8269b40 100644
--- a/src/lib/dns/name.cc
+++ b/src/lib/dns/name.cc
@@ -20,13 +20,13 @@
#include <iostream>
#include <algorithm>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/name.h>
#include <dns/messagerenderer.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
using isc::dns::NameComparisonResult;
using isc::dns::MessageRenderer;
diff --git a/src/lib/dns/name.h b/src/lib/dns/name.h
index 562a1d5..f58bb93 100644
--- a/src/lib/dns/name.h
+++ b/src/lib/dns/name.h
@@ -24,11 +24,9 @@
namespace isc {
namespace util {
-namespace io {
class InputBuffer;
class OutputBuffer;
}
-}
namespace dns {
class MessageRenderer;
@@ -252,7 +250,7 @@ public:
///
/// \param buffer A buffer storing the wire format %data.
/// \param downcase Whether to convert upper case alphabets to lower case.
- explicit Name(isc::util::io::InputBuffer& buffer, bool downcase = false);
+ explicit Name(isc::util::InputBuffer& buffer, bool downcase = false);
///
/// We use the default copy constructor intentionally.
//@}
@@ -364,7 +362,7 @@ public:
/// then this method should not throw an exception.
///
/// \param buffer An output buffer to store the wire %data.
- void toWire(isc::util::io::OutputBuffer& buffer) const;
+ void toWire(isc::util::OutputBuffer& buffer) const;
//@}
///
diff --git a/src/lib/dns/python/edns_python.cc b/src/lib/dns/python/edns_python.cc
index bceee7a..07dcc14 100644
--- a/src/lib/dns/python/edns_python.cc
+++ b/src/lib/dns/python/edns_python.cc
@@ -17,7 +17,7 @@
#include <dns/edns.h>
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
//
diff --git a/src/lib/dns/python/message_python.cc b/src/lib/dns/python/message_python.cc
index 42af4d4..30100f4 100644
--- a/src/lib/dns/python/message_python.cc
+++ b/src/lib/dns/python/message_python.cc
@@ -15,7 +15,7 @@
#include <exceptions/exceptions.h>
#include <dns/message.h>
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
//
// Declaration of the custom exceptions
diff --git a/src/lib/dns/python/messagerenderer_python.cc b/src/lib/dns/python/messagerenderer_python.cc
index 9da2a63..139475a 100644
--- a/src/lib/dns/python/messagerenderer_python.cc
+++ b/src/lib/dns/python/messagerenderer_python.cc
@@ -18,7 +18,7 @@
// and static wrappers around the methods we export), a list of methods,
// and a type description
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
// MessageRenderer
diff --git a/src/lib/dns/python/name_python.cc b/src/lib/dns/python/name_python.cc
index d8070b8..b36e313 100644
--- a/src/lib/dns/python/name_python.cc
+++ b/src/lib/dns/python/name_python.cc
@@ -41,7 +41,7 @@ static PyObject* po_NameRelation;
// and static wrappers around the methods we export), a list of methods,
// and a type description
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
// NameComparisonResult
class s_NameComparisonResult : public PyObject {
diff --git a/src/lib/dns/python/pydnspp.cc b/src/lib/dns/python/pydnspp.cc
index 8fd1e17..27dbae6 100644
--- a/src/lib/dns/python/pydnspp.cc
+++ b/src/lib/dns/python/pydnspp.cc
@@ -31,7 +31,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/name.h>
#include <dns/messagerenderer.h>
diff --git a/src/lib/dns/python/rdata_python.cc b/src/lib/dns/python/rdata_python.cc
index 8f07ef2..faa4f4c 100644
--- a/src/lib/dns/python/rdata_python.cc
+++ b/src/lib/dns/python/rdata_python.cc
@@ -14,7 +14,7 @@
#include <dns/rdata.h>
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
//
diff --git a/src/lib/dns/python/rrclass_python.cc b/src/lib/dns/python/rrclass_python.cc
index 66611a3..8e8b60b 100644
--- a/src/lib/dns/python/rrclass_python.cc
+++ b/src/lib/dns/python/rrclass_python.cc
@@ -14,7 +14,7 @@
#include <dns/rrclass.h>
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
//
// Declaration of the custom exceptions
diff --git a/src/lib/dns/python/rrset_python.cc b/src/lib/dns/python/rrset_python.cc
index 952503c..c7d05d1 100644
--- a/src/lib/dns/python/rrset_python.cc
+++ b/src/lib/dns/python/rrset_python.cc
@@ -29,7 +29,7 @@ static PyObject* po_EmptyRRset;
// and static wrappers around the methods we export), a list of methods,
// and a type description
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
// RRset
diff --git a/src/lib/dns/python/rrttl_python.cc b/src/lib/dns/python/rrttl_python.cc
index 7d244e8..db9d736 100644
--- a/src/lib/dns/python/rrttl_python.cc
+++ b/src/lib/dns/python/rrttl_python.cc
@@ -18,7 +18,7 @@
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
//
// Declaration of the custom exceptions
diff --git a/src/lib/dns/python/rrtype_python.cc b/src/lib/dns/python/rrtype_python.cc
index a31bb54..10895c6 100644
--- a/src/lib/dns/python/rrtype_python.cc
+++ b/src/lib/dns/python/rrtype_python.cc
@@ -18,7 +18,7 @@
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
//
// Declaration of the custom exceptions
diff --git a/src/lib/dns/question.cc b/src/lib/dns/question.cc
index 86f1d48..723fc88 100644
--- a/src/lib/dns/question.cc
+++ b/src/lib/dns/question.cc
@@ -15,7 +15,7 @@
#include <iostream>
#include <string>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/name.h>
#include <dns/question.h>
@@ -23,7 +23,7 @@
#include <dns/rrtype.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
namespace isc {
namespace dns {
diff --git a/src/lib/dns/question.h b/src/lib/dns/question.h
index 42d2dfe..3c038b3 100644
--- a/src/lib/dns/question.h
+++ b/src/lib/dns/question.h
@@ -26,11 +26,9 @@
namespace isc {
namespace util {
-namespace io {
class InputBuffer;
class OutputBuffer;
}
-}
namespace dns {
@@ -124,7 +122,7 @@ public:
/// classes fails.
///
/// \param buffer A buffer storing the wire format data.
- Question(isc::util::io::InputBuffer& buffer);
+ Question(isc::util::InputBuffer& buffer);
/// \brief Constructor from fixed parameters of the \c Question.
///
@@ -230,7 +228,7 @@ public:
///
/// \param buffer An output buffer to store the wire data.
/// \return 1
- unsigned int toWire(isc::util::io::OutputBuffer& buffer) const;
+ unsigned int toWire(isc::util::OutputBuffer& buffer) const;
//@}
///
diff --git a/src/lib/dns/rdata.cc b/src/lib/dns/rdata.cc
index e23727f..e51991f 100644
--- a/src/lib/dns/rdata.cc
+++ b/src/lib/dns/rdata.cc
@@ -27,7 +27,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/name.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -36,7 +36,7 @@
using namespace std;
using namespace boost;
-using namespace isc::util::io;
+using namespace isc::util;
namespace isc {
namespace dns {
@@ -54,7 +54,7 @@ createRdata(const RRType& rrtype, const RRClass& rrclass,
RdataPtr
createRdata(const RRType& rrtype, const RRClass& rrclass,
- isc::util::io::InputBuffer& buffer, size_t len)
+ isc::util::InputBuffer& buffer, size_t len)
{
if (len > MAX_RDLENGTH) {
isc_throw(InvalidRdataLength, "RDLENGTH too large");
@@ -105,7 +105,7 @@ struct GenericImpl {
vector<uint8_t> data_;
};
-Generic::Generic(isc::util::io::InputBuffer& buffer, size_t rdata_len) {
+Generic::Generic(isc::util::InputBuffer& buffer, size_t rdata_len) {
if (rdata_len > MAX_RDLENGTH) {
isc_throw(InvalidRdataLength, "RDLENGTH too large");
}
@@ -224,7 +224,7 @@ Generic::toText() const {
}
void
-Generic::toWire(isc::util::io::OutputBuffer& buffer) const {
+Generic::toWire(isc::util::OutputBuffer& buffer) const {
buffer.writeData(&impl_->data_[0], impl_->data_.size());
}
diff --git a/src/lib/dns/rdata.h b/src/lib/dns/rdata.h
index ab15918..1e57f27 100644
--- a/src/lib/dns/rdata.h
+++ b/src/lib/dns/rdata.h
@@ -23,11 +23,9 @@
namespace isc {
namespace util {
-namespace io {
class InputBuffer;
class OutputBuffer;
}
-}
namespace dns {
class MessageRenderer;
class RRType;
@@ -172,7 +170,7 @@ public:
/// should be explicitly defined in the derived class.
///
/// \param buffer An output buffer to store the wire data.
- virtual void toWire(isc::util::io::OutputBuffer& buffer) const = 0;
+ virtual void toWire(isc::util::OutputBuffer& buffer) const = 0;
/// \brief Render the \c Rdata in the wire format into a
/// \c MessageRenderer object.
///
@@ -276,7 +274,7 @@ public:
/// \param buffer A reference to an \c InputBuffer object storing the
/// \c Rdata to parse.
/// \param rdata_len The length in buffer of the \c Rdata. In bytes.
- Generic(isc::util::io::InputBuffer& buffer, size_t rdata_len);
+ Generic(isc::util::InputBuffer& buffer, size_t rdata_len);
///
/// \brief The destructor.
virtual ~Generic();
@@ -320,7 +318,7 @@ public:
/// be thrown.
///
/// \param buffer An output buffer to store the wire data.
- virtual void toWire(isc::util::io::OutputBuffer& buffer) const;
+ virtual void toWire(isc::util::OutputBuffer& buffer) const;
/// \brief Render the \c generic::Generic in the wire format into a
/// \c MessageRenderer object.
///
@@ -447,7 +445,7 @@ RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
/// \return An \c RdataPtr object pointing to the created \c Rdata
/// object.
RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
- isc::util::io::InputBuffer& buffer, size_t len);
+ isc::util::InputBuffer& buffer, size_t len);
/// \brief Create RDATA of a given pair of RR type and class, copying
/// of another RDATA of same kind.
///
diff --git a/src/lib/dns/rdata/any_255/tsig_250.cc b/src/lib/dns/rdata/any_255/tsig_250.cc
index 994623d..cfc46da 100644
--- a/src/lib/dns/rdata/any_255/tsig_250.cc
+++ b/src/lib/dns/rdata/any_255/tsig_250.cc
@@ -18,8 +18,8 @@
#include <boost/lexical_cast.hpp>
-#include <util/io/buffer.h>
-#include <util/compat/base64.h>
+#include <util/buffer.h>
+#include <util/coder/base64.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -28,8 +28,8 @@
using namespace std;
using namespace boost;
-using namespace isc::util::io;
-using namespace isc::util::compat;
+using namespace isc::util;
+using namespace isc::util::coder;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/ch_3/a_1.cc b/src/lib/dns/rdata/ch_3/a_1.cc
index dbd5613..359624d 100644
--- a/src/lib/dns/rdata/ch_3/a_1.cc
+++ b/src/lib/dns/rdata/ch_3/a_1.cc
@@ -16,13 +16,13 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/cname_5.cc b/src/lib/dns/rdata/generic/cname_5.cc
index a970b41..6a3447d 100644
--- a/src/lib/dns/rdata/generic/cname_5.cc
+++ b/src/lib/dns/rdata/generic/cname_5.cc
@@ -16,14 +16,14 @@
#include <string>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/name.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/dname_39.cc b/src/lib/dns/rdata/generic/dname_39.cc
index a2a685b..7cd22bf 100644
--- a/src/lib/dns/rdata/generic/dname_39.cc
+++ b/src/lib/dns/rdata/generic/dname_39.cc
@@ -16,14 +16,14 @@
#include <string>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/name.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/dnskey_48.cc b/src/lib/dns/rdata/generic/dnskey_48.cc
index 823e60d..a9dc19b 100644
--- a/src/lib/dns/rdata/generic/dnskey_48.cc
+++ b/src/lib/dns/rdata/generic/dnskey_48.cc
@@ -20,8 +20,8 @@
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
-#include <util/compat/base64.h>
-#include <util/io/buffer.h>
+#include <util/coder/base64.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/name.h>
#include <dns/rdata.h>
@@ -31,8 +31,8 @@
#include <time.h>
using namespace std;
-using namespace isc::util::io;
-using namespace isc::util::compat;
+using namespace isc::util;
+using namespace isc::util::coder;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/ds_43.cc b/src/lib/dns/rdata/generic/ds_43.cc
index 69eb2a3..fb24492 100644
--- a/src/lib/dns/rdata/generic/ds_43.cc
+++ b/src/lib/dns/rdata/generic/ds_43.cc
@@ -19,8 +19,8 @@
#include <boost/lexical_cast.hpp>
-#include <util/io/buffer.h>
-#include <util/compat/hex.h>
+#include <util/buffer.h>
+#include <util/coder/hex.h>
#include <dns/messagerenderer.h>
#include <dns/name.h>
@@ -31,8 +31,8 @@
#include <time.h>
using namespace std;
-using namespace isc::util::io;
-using namespace isc::util::compat;
+using namespace isc::util;
+using namespace isc::util::coder;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/mx_15.cc b/src/lib/dns/rdata/generic/mx_15.cc
index 858ca92..8999384 100644
--- a/src/lib/dns/rdata/generic/mx_15.cc
+++ b/src/lib/dns/rdata/generic/mx_15.cc
@@ -20,7 +20,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/name.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -28,7 +28,7 @@
using namespace std;
using namespace boost;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/ns_2.cc b/src/lib/dns/rdata/generic/ns_2.cc
index e2a2b23..dcdbcd2 100644
--- a/src/lib/dns/rdata/generic/ns_2.cc
+++ b/src/lib/dns/rdata/generic/ns_2.cc
@@ -16,14 +16,14 @@
#include <string>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/name.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/nsec3_50.cc b/src/lib/dns/rdata/generic/nsec3_50.cc
index 1613623..e946d0a 100644
--- a/src/lib/dns/rdata/generic/nsec3_50.cc
+++ b/src/lib/dns/rdata/generic/nsec3_50.cc
@@ -20,9 +20,9 @@
#include <boost/lexical_cast.hpp>
-#include <util/compat/base32hex.h>
-#include <util/compat/hex.h>
-#include <util/io/buffer.h>
+#include <util/coder/base32hex.h>
+#include <util/coder/hex.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
@@ -38,8 +38,8 @@
using namespace std;
using namespace isc::dns::rdata::generic::detail::nsec;
-using namespace isc::util::compat;
-using namespace isc::util::io;
+using namespace isc::util::coder;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/nsec3param_51.cc b/src/lib/dns/rdata/generic/nsec3param_51.cc
index c190cb2..20e4fea 100644
--- a/src/lib/dns/rdata/generic/nsec3param_51.cc
+++ b/src/lib/dns/rdata/generic/nsec3param_51.cc
@@ -19,8 +19,8 @@
#include <boost/lexical_cast.hpp>
-#include <util/io/buffer.h>
-#include <util/compat/hex.h>
+#include <util/buffer.h>
+#include <util/coder/hex.h>
#include <dns/messagerenderer.h>
#include <dns/name.h>
#include <dns/rdata.h>
@@ -30,8 +30,8 @@
#include <time.h>
using namespace std;
-using namespace isc::util::io;
-using namespace isc::util::compat;
+using namespace isc::util;
+using namespace isc::util::coder;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/nsec_47.cc b/src/lib/dns/rdata/generic/nsec_47.cc
index 040a83a..c50123c 100644
--- a/src/lib/dns/rdata/generic/nsec_47.cc
+++ b/src/lib/dns/rdata/generic/nsec_47.cc
@@ -17,8 +17,8 @@
#include <sstream>
#include <vector>
-#include <util/compat/base64.h>
-#include <util/io/buffer.h>
+#include <util/coder/base64.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/name.h>
@@ -32,8 +32,8 @@
#include <time.h>
using namespace std;
-using namespace isc::util::io;
-using namespace isc::util::compat;
+using namespace isc::util;
+using namespace isc::util::coder;
using namespace isc::dns::rdata::generic::detail::nsec;
// BEGIN_ISC_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/opt_41.cc b/src/lib/dns/rdata/generic/opt_41.cc
index cb80256..fc80832 100644
--- a/src/lib/dns/rdata/generic/opt_41.cc
+++ b/src/lib/dns/rdata/generic/opt_41.cc
@@ -16,13 +16,13 @@
#include <string>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/ptr_12.cc b/src/lib/dns/rdata/generic/ptr_12.cc
index 304da08..63585b0 100644
--- a/src/lib/dns/rdata/generic/ptr_12.cc
+++ b/src/lib/dns/rdata/generic/ptr_12.cc
@@ -16,14 +16,14 @@
#include <string>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/name.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/rrsig_46.cc b/src/lib/dns/rdata/generic/rrsig_46.cc
index 65eb0c7..c7c8bd1 100644
--- a/src/lib/dns/rdata/generic/rrsig_46.cc
+++ b/src/lib/dns/rdata/generic/rrsig_46.cc
@@ -20,9 +20,9 @@
#include <boost/lexical_cast.hpp>
-#include <util/compat/base64.h>
-#include <util/io/buffer.h>
-#include <util/compat/time_utilities.h>
+#include <util/coder/base64.h>
+#include <util/buffer.h>
+#include <util/coder/time_utilities.h>
#include <dns/messagerenderer.h>
#include <dns/name.h>
#include <dns/rrtype.h>
@@ -35,8 +35,8 @@
using namespace std;
using namespace isc::util;
-using namespace isc::util::io;
-using namespace isc::util::compat;
+using namespace isc::util;
+using namespace isc::util::coder;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/soa_6.cc b/src/lib/dns/rdata/generic/soa_6.cc
index 01cde31..58d6da4 100644
--- a/src/lib/dns/rdata/generic/soa_6.cc
+++ b/src/lib/dns/rdata/generic/soa_6.cc
@@ -20,7 +20,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/name.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -28,7 +28,7 @@
using namespace std;
using namespace boost;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/txt_16.cc b/src/lib/dns/rdata/generic/txt_16.cc
index c7c6dde..d1d4d89 100644
--- a/src/lib/dns/rdata/generic/txt_16.cc
+++ b/src/lib/dns/rdata/generic/txt_16.cc
@@ -18,14 +18,14 @@
#include <string>
#include <vector>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/hs_4/a_1.cc b/src/lib/dns/rdata/hs_4/a_1.cc
index dbd5613..359624d 100644
--- a/src/lib/dns/rdata/hs_4/a_1.cc
+++ b/src/lib/dns/rdata/hs_4/a_1.cc
@@ -16,13 +16,13 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/in_1/a_1.cc b/src/lib/dns/rdata/in_1/a_1.cc
index 21f5a73..1d7b8de 100644
--- a/src/lib/dns/rdata/in_1/a_1.cc
+++ b/src/lib/dns/rdata/in_1/a_1.cc
@@ -22,14 +22,14 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/in_1/aaaa_28.cc b/src/lib/dns/rdata/in_1/aaaa_28.cc
index edaa190..1125a59 100644
--- a/src/lib/dns/rdata/in_1/aaaa_28.cc
+++ b/src/lib/dns/rdata/in_1/aaaa_28.cc
@@ -22,14 +22,14 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/template.cc b/src/lib/dns/rdata/template.cc
index 617ce2a..b1dc571 100644
--- a/src/lib/dns/rdata/template.cc
+++ b/src/lib/dns/rdata/template.cc
@@ -14,13 +14,13 @@
#include <string>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rrclass-placeholder.h b/src/lib/dns/rrclass-placeholder.h
index b14179b..ae3ff6f 100644
--- a/src/lib/dns/rrclass-placeholder.h
+++ b/src/lib/dns/rrclass-placeholder.h
@@ -24,11 +24,9 @@
namespace isc {
namespace util {
-namespace io {
class InputBuffer;
class OutputBuffer;
}
-}
namespace dns {
@@ -137,7 +135,7 @@ public:
/// an exception of class \c IncompleteRRClass will be thrown.
///
/// \param buffer A buffer storing the wire format data.
- explicit RRClass(isc::util::io::InputBuffer& buffer);
+ explicit RRClass(isc::util::InputBuffer& buffer);
///
/// We use the default copy constructor intentionally.
//@}
@@ -182,7 +180,7 @@ public:
///
/// \param renderer DNS message rendering context that encapsulates the
/// output buffer in which the RRClass is to be stored.
- void toWire(isc::util::io::OutputBuffer& buffer) const;
+ void toWire(isc::util::OutputBuffer& buffer) const;
//@}
///
diff --git a/src/lib/dns/rrclass.cc b/src/lib/dns/rrclass.cc
index 43a6b9d..f1bb8d7 100644
--- a/src/lib/dns/rrclass.cc
+++ b/src/lib/dns/rrclass.cc
@@ -18,14 +18,14 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rrparamregistry.h>
#include <dns/rrclass.h>
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace isc {
namespace dns {
diff --git a/src/lib/dns/rrparamregistry-placeholder.cc b/src/lib/dns/rrparamregistry-placeholder.cc
index 735c699..5058ca3 100644
--- a/src/lib/dns/rrparamregistry-placeholder.cc
+++ b/src/lib/dns/rrparamregistry-placeholder.cc
@@ -36,7 +36,7 @@
using namespace std;
using namespace boost;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace isc {
diff --git a/src/lib/dns/rrparamregistry.h b/src/lib/dns/rrparamregistry.h
index 7244d7f..ae41b5f 100644
--- a/src/lib/dns/rrparamregistry.h
+++ b/src/lib/dns/rrparamregistry.h
@@ -102,7 +102,7 @@ public:
/// \c Rdata to parse.
/// \param rdata_len The length in buffer of the \c Rdata. In bytes.
/// \return An \c RdataPtr object pointing to the created \c Rdata object.
- virtual RdataPtr create(isc::util::io::InputBuffer& buffer, size_t rdata_len) const = 0;
+ virtual RdataPtr create(isc::util::InputBuffer& buffer, size_t rdata_len) const = 0;
///
/// \brief Create RDATA from another \c Rdata object of the same type.
///
@@ -473,7 +473,7 @@ public:
/// \return An \c rdata::RdataPtr object pointing to the created \c Rdata
/// object.
rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
- isc::util::io::InputBuffer& buffer, size_t len);
+ isc::util::InputBuffer& buffer, size_t len);
/// \brief Create RDATA of a given pair of RR type and class, copying
/// of another RDATA of same kind.
///
diff --git a/src/lib/dns/rrset.cc b/src/lib/dns/rrset.cc
index fd95817..e80afdb 100644
--- a/src/lib/dns/rrset.cc
+++ b/src/lib/dns/rrset.cc
@@ -18,7 +18,7 @@
#include <boost/shared_ptr.hpp>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/name.h>
#include <dns/rrclass.h>
@@ -28,7 +28,7 @@
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace isc {
diff --git a/src/lib/dns/rrset.h b/src/lib/dns/rrset.h
index 996bec1..bf7adc0 100644
--- a/src/lib/dns/rrset.h
+++ b/src/lib/dns/rrset.h
@@ -27,10 +27,8 @@
namespace isc {
namespace util {
-namespace io {
class OututBuffer;
}
-}
namespace dns {
@@ -321,7 +319,7 @@ public:
///
/// \param buffer An output buffer to store the wire data.
/// \return The number of RRs rendered.
- virtual unsigned int toWire(isc::util::io::OutputBuffer& buffer) const = 0;
+ virtual unsigned int toWire(isc::util::OutputBuffer& buffer) const = 0;
//@}
///
@@ -625,7 +623,7 @@ public:
///
/// This method simply uses the default implementation.
/// See \c AbstractRRset::toWire(OutputBuffer&)const.
- virtual unsigned int toWire(isc::util::io::OutputBuffer& buffer) const;
+ virtual unsigned int toWire(isc::util::OutputBuffer& buffer) const;
//@}
///
diff --git a/src/lib/dns/rrttl.cc b/src/lib/dns/rrttl.cc
index b85a440..a4c4f83 100644
--- a/src/lib/dns/rrttl.cc
+++ b/src/lib/dns/rrttl.cc
@@ -17,13 +17,13 @@
#include <sstream>
#include <ostream>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rrttl.h>
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace isc {
namespace dns {
diff --git a/src/lib/dns/rrttl.h b/src/lib/dns/rrttl.h
index f37b040..17ec891 100644
--- a/src/lib/dns/rrttl.h
+++ b/src/lib/dns/rrttl.h
@@ -21,11 +21,9 @@
namespace isc {
namespace util {
-namespace io {
class InputBuffer;
class OutputBuffer;
}
-}
namespace dns {
@@ -96,7 +94,7 @@ public:
/// an exception of class \c IncompleteRRTTL will be thrown.
///
/// \param buffer A buffer storing the wire format data.
- explicit RRTTL(isc::util::io::InputBuffer& buffer);
+ explicit RRTTL(isc::util::InputBuffer& buffer);
///
//@}
@@ -135,7 +133,7 @@ public:
/// standard exception will be thrown.
///
/// \param buffer An output buffer to store the wire data.
- void toWire(isc::util::io::OutputBuffer& buffer) const;
+ void toWire(isc::util::OutputBuffer& buffer) const;
//@}
///
diff --git a/src/lib/dns/rrtype-placeholder.h b/src/lib/dns/rrtype-placeholder.h
index 6dd4f88..69437f5 100644
--- a/src/lib/dns/rrtype-placeholder.h
+++ b/src/lib/dns/rrtype-placeholder.h
@@ -24,11 +24,9 @@
namespace isc {
namespace util {
-namespace io {
class InputBuffer;
class OutputBuffer;
}
-}
namespace dns {
@@ -150,7 +148,7 @@ public:
/// an exception of class \c IncompleteRRType will be thrown.
///
/// \param buffer A buffer storing the wire format data.
- explicit RRType(isc::util::io::InputBuffer& buffer);
+ explicit RRType(isc::util::InputBuffer& buffer);
///
/// We use the default copy constructor intentionally.
//@}
@@ -194,7 +192,7 @@ public:
///
/// \param renderer DNS message rendering context that encapsulates the
/// output buffer in which the RRType is to be stored.
- void toWire(isc::util::io::OutputBuffer& buffer) const;
+ void toWire(isc::util::OutputBuffer& buffer) const;
//@}
///
diff --git a/src/lib/dns/rrtype.cc b/src/lib/dns/rrtype.cc
index c54fce5..e234fad 100644
--- a/src/lib/dns/rrtype.cc
+++ b/src/lib/dns/rrtype.cc
@@ -19,13 +19,13 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rrparamregistry.h>
#include <dns/rrtype.h>
using namespace std;
-using namespace isc::util::io;
+using namespace isc::util;
using isc::dns::RRType;
namespace isc {
diff --git a/src/lib/dns/tests/edns_unittest.cc b/src/lib/dns/tests/edns_unittest.cc
index 292a4f9..26cc01c 100644
--- a/src/lib/dns/tests/edns_unittest.cc
+++ b/src/lib/dns/tests/edns_unittest.cc
@@ -16,7 +16,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/edns.h>
#include <dns/exceptions.h>
#include <dns/message.h>
@@ -35,7 +35,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
const uint8_t EDNS::SUPPORTED_VERSION;
diff --git a/src/lib/dns/tests/message_unittest.cc b/src/lib/dns/tests/message_unittest.cc
index d8ed6a8..4031e4f 100644
--- a/src/lib/dns/tests/message_unittest.cc
+++ b/src/lib/dns/tests/message_unittest.cc
@@ -14,7 +14,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/edns.h>
#include <dns/exceptions.h>
#include <dns/message.h>
@@ -35,7 +35,7 @@ using isc::UnitTestUtil;
using namespace std;
using namespace isc;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
//
diff --git a/src/lib/dns/tests/messagerenderer_unittest.cc b/src/lib/dns/tests/messagerenderer_unittest.cc
index 645e5f3..fe790fe 100644
--- a/src/lib/dns/tests/messagerenderer_unittest.cc
+++ b/src/lib/dns/tests/messagerenderer_unittest.cc
@@ -14,7 +14,7 @@
#include <vector>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/name.h>
#include <dns/messagerenderer.h>
@@ -25,7 +25,7 @@
using isc::UnitTestUtil;
using isc::dns::Name;
using isc::dns::MessageRenderer;
-using isc::util::io::OutputBuffer;
+using isc::util::OutputBuffer;
namespace {
class MessageRendererTest : public ::testing::Test {
diff --git a/src/lib/dns/tests/name_unittest.cc b/src/lib/dns/tests/name_unittest.cc
index 6d4ae82..6434229 100644
--- a/src/lib/dns/tests/name_unittest.cc
+++ b/src/lib/dns/tests/name_unittest.cc
@@ -19,7 +19,7 @@
#include <limits>
#include <stdexcept>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/name.h>
#include <dns/messagerenderer.h>
@@ -31,7 +31,7 @@
using namespace std;
using namespace isc;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
//
// XXX: these are defined as class static constants, but some compilers
diff --git a/src/lib/dns/tests/question_unittest.cc b/src/lib/dns/tests/question_unittest.cc
index 3e10e3f..25fd75b 100644
--- a/src/lib/dns/tests/question_unittest.cc
+++ b/src/lib/dns/tests/question_unittest.cc
@@ -17,7 +17,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/name.h>
@@ -32,7 +32,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace {
class QuestionTest : public ::testing::Test {
diff --git a/src/lib/dns/tests/rdata_cname_unittest.cc b/src/lib/dns/tests/rdata_cname_unittest.cc
index cc27d99..d6b02aa 100644
--- a/src/lib/dns/tests/rdata_cname_unittest.cc
+++ b/src/lib/dns/tests/rdata_cname_unittest.cc
@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -28,7 +28,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_dname_unittest.cc b/src/lib/dns/tests/rdata_dname_unittest.cc
index 3c26c5a..ebd9e0e 100644
--- a/src/lib/dns/tests/rdata_dname_unittest.cc
+++ b/src/lib/dns/tests/rdata_dname_unittest.cc
@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -28,7 +28,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_dnskey_unittest.cc b/src/lib/dns/tests/rdata_dnskey_unittest.cc
index 5ddacbc..f0596ed 100644
--- a/src/lib/dns/tests/rdata_dnskey_unittest.cc
+++ b/src/lib/dns/tests/rdata_dnskey_unittest.cc
@@ -16,7 +16,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
@@ -32,7 +32,7 @@ using isc::UnitTestUtil;
using namespace std;
using namespace isc;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_ds_unittest.cc b/src/lib/dns/tests/rdata_ds_unittest.cc
index 57c688d..5988620 100644
--- a/src/lib/dns/tests/rdata_ds_unittest.cc
+++ b/src/lib/dns/tests/rdata_ds_unittest.cc
@@ -14,7 +14,7 @@
#include <string>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
@@ -29,7 +29,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_in_a_unittest.cc b/src/lib/dns/tests/rdata_in_a_unittest.cc
index a54988f..47e2bfa 100644
--- a/src/lib/dns/tests/rdata_in_a_unittest.cc
+++ b/src/lib/dns/tests/rdata_in_a_unittest.cc
@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -28,7 +28,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_in_aaaa_unittest.cc b/src/lib/dns/tests/rdata_in_aaaa_unittest.cc
index 2e46b4c..6fd4d0e 100644
--- a/src/lib/dns/tests/rdata_in_aaaa_unittest.cc
+++ b/src/lib/dns/tests/rdata_in_aaaa_unittest.cc
@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -28,7 +28,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_mx_unittest.cc b/src/lib/dns/tests/rdata_mx_unittest.cc
index ef65ef9..c4c9757 100644
--- a/src/lib/dns/tests/rdata_mx_unittest.cc
+++ b/src/lib/dns/tests/rdata_mx_unittest.cc
@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
@@ -27,7 +27,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_ns_unittest.cc b/src/lib/dns/tests/rdata_ns_unittest.cc
index 996d49d..b805783 100644
--- a/src/lib/dns/tests/rdata_ns_unittest.cc
+++ b/src/lib/dns/tests/rdata_ns_unittest.cc
@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -28,7 +28,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_nsec3_unittest.cc b/src/lib/dns/tests/rdata_nsec3_unittest.cc
index bc0697e..3e1c007 100644
--- a/src/lib/dns/tests/rdata_nsec3_unittest.cc
+++ b/src/lib/dns/tests/rdata_nsec3_unittest.cc
@@ -16,8 +16,8 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
-#include <util/compat/hex.h>
+#include <util/buffer.h>
+#include <util/coder/hex.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -34,8 +34,8 @@ using isc::UnitTestUtil;
using namespace std;
using namespace isc;
using namespace isc::dns;
-using namespace isc::util::io;
-using namespace isc::util::compat;
+using namespace isc::util;
+using namespace isc::util::coder;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_nsec3param_unittest.cc b/src/lib/dns/tests/rdata_nsec3param_unittest.cc
index e8732cb..ea876a9 100644
--- a/src/lib/dns/tests/rdata_nsec3param_unittest.cc
+++ b/src/lib/dns/tests/rdata_nsec3param_unittest.cc
@@ -16,9 +16,9 @@
#include <exceptions/exceptions.h>
-#include <util/compat/base32hex.h>
-#include <util/compat/hex.h>
-#include <util/io/buffer.h>
+#include <util/coder/base32hex.h>
+#include <util/coder/hex.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
@@ -34,8 +34,8 @@ using isc::UnitTestUtil;
using namespace std;
using namespace isc;
using namespace isc::dns;
-using namespace isc::util::io;
-using namespace isc::util::compat;
+using namespace isc::util;
+using namespace isc::util::coder;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_nsec_unittest.cc b/src/lib/dns/tests/rdata_nsec_unittest.cc
index 8e2ca12..5aa1e9c 100644
--- a/src/lib/dns/tests/rdata_nsec_unittest.cc
+++ b/src/lib/dns/tests/rdata_nsec_unittest.cc
@@ -14,7 +14,7 @@
#include <string>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -30,7 +30,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_opt_unittest.cc b/src/lib/dns/tests/rdata_opt_unittest.cc
index e009ba2..698d586 100644
--- a/src/lib/dns/tests/rdata_opt_unittest.cc
+++ b/src/lib/dns/tests/rdata_opt_unittest.cc
@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
@@ -27,7 +27,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_ptr_unittest.cc b/src/lib/dns/tests/rdata_ptr_unittest.cc
index 5e18fd4..7f5de20 100644
--- a/src/lib/dns/tests/rdata_ptr_unittest.cc
+++ b/src/lib/dns/tests/rdata_ptr_unittest.cc
@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -28,7 +28,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
//
diff --git a/src/lib/dns/tests/rdata_rrsig_unittest.cc b/src/lib/dns/tests/rdata_rrsig_unittest.cc
index 7aa6c05..77ae740 100644
--- a/src/lib/dns/tests/rdata_rrsig_unittest.cc
+++ b/src/lib/dns/tests/rdata_rrsig_unittest.cc
@@ -14,8 +14,8 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
-#include <util/compat/time_utilities.h>
+#include <util/buffer.h>
+#include <util/coder/time_utilities.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
@@ -31,8 +31,8 @@ using isc::UnitTestUtil;
using namespace std;
using namespace isc;
using namespace isc::dns;
-using namespace isc::util::io;
-using namespace isc::util::compat;
+using namespace isc::util;
+using namespace isc::util::coder;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_soa_unittest.cc b/src/lib/dns/tests/rdata_soa_unittest.cc
index 4786d63..63fe1f7 100644
--- a/src/lib/dns/tests/rdata_soa_unittest.cc
+++ b/src/lib/dns/tests/rdata_soa_unittest.cc
@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
@@ -27,7 +27,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_tsig_unittest.cc b/src/lib/dns/tests/rdata_tsig_unittest.cc
index 5bf04ba..76f91a6 100644
--- a/src/lib/dns/tests/rdata_tsig_unittest.cc
+++ b/src/lib/dns/tests/rdata_tsig_unittest.cc
@@ -16,7 +16,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -32,7 +32,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_txt_unittest.cc b/src/lib/dns/tests/rdata_txt_unittest.cc
index e71ee54..e5f8ac9 100644
--- a/src/lib/dns/tests/rdata_txt_unittest.cc
+++ b/src/lib/dns/tests/rdata_txt_unittest.cc
@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
@@ -28,7 +28,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rdata_unittest.cc b/src/lib/dns/tests/rdata_unittest.cc
index 2506af9..fa791dc 100644
--- a/src/lib/dns/tests/rdata_unittest.cc
+++ b/src/lib/dns/tests/rdata_unittest.cc
@@ -16,7 +16,7 @@
#include <string>
#include <sstream>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
@@ -31,7 +31,7 @@
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace isc {
diff --git a/src/lib/dns/tests/rdata_unittest.h b/src/lib/dns/tests/rdata_unittest.h
index 8b4813b..1bc0fa4 100644
--- a/src/lib/dns/tests/rdata_unittest.h
+++ b/src/lib/dns/tests/rdata_unittest.h
@@ -15,7 +15,7 @@
#ifndef __RDATA_UNITTEST_H
#define __RDATA_UNITTEST_H 1
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rrclass.h>
#include <dns/rrtype.h>
@@ -23,7 +23,7 @@
#include <gtest/gtest.h>
-using namespace isc::util::io;
+using namespace isc::util;
namespace isc {
namespace dns {
diff --git a/src/lib/dns/tests/rrclass_unittest.cc b/src/lib/dns/tests/rrclass_unittest.cc
index fcfcb95..15f9a8c 100644
--- a/src/lib/dns/tests/rrclass_unittest.cc
+++ b/src/lib/dns/tests/rrclass_unittest.cc
@@ -14,7 +14,7 @@
#include <gtest/gtest.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rrclass.h>
@@ -23,7 +23,7 @@
using namespace std;
using namespace isc;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace {
class RRClassTest : public ::testing::Test {
diff --git a/src/lib/dns/tests/rrparamregistry_unittest.cc b/src/lib/dns/tests/rrparamregistry_unittest.cc
index 15efff1..d2bec5c 100644
--- a/src/lib/dns/tests/rrparamregistry_unittest.cc
+++ b/src/lib/dns/tests/rrparamregistry_unittest.cc
@@ -27,7 +27,7 @@
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rrset_unittest.cc b/src/lib/dns/tests/rrset_unittest.cc
index 42a98a6..f951341 100644
--- a/src/lib/dns/tests/rrset_unittest.cc
+++ b/src/lib/dns/tests/rrset_unittest.cc
@@ -14,7 +14,7 @@
#include <stdexcept>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/name.h>
#include <dns/rdata.h>
@@ -32,7 +32,7 @@ using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::dns::rdata;
namespace {
diff --git a/src/lib/dns/tests/rrttl_unittest.cc b/src/lib/dns/tests/rrttl_unittest.cc
index 7eb6ee4..fe75eb6 100644
--- a/src/lib/dns/tests/rrttl_unittest.cc
+++ b/src/lib/dns/tests/rrttl_unittest.cc
@@ -14,7 +14,7 @@
#include <gtest/gtest.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rrttl.h>
@@ -23,7 +23,7 @@
using namespace std;
using namespace isc;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace {
class RRTTLTest : public ::testing::Test {
diff --git a/src/lib/dns/tests/rrtype_unittest.cc b/src/lib/dns/tests/rrtype_unittest.cc
index c3a1bfc..12f6001 100644
--- a/src/lib/dns/tests/rrtype_unittest.cc
+++ b/src/lib/dns/tests/rrtype_unittest.cc
@@ -14,7 +14,7 @@
#include <gtest/gtest.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/messagerenderer.h>
#include <dns/rrtype.h>
@@ -23,7 +23,7 @@
using namespace std;
using namespace isc;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace {
class RRTypeTest : public ::testing::Test {
diff --git a/src/lib/log/compiler/message.cc b/src/lib/log/compiler/message.cc
index faacd2d..ef4bafd 100644
--- a/src/lib/log/compiler/message.cc
+++ b/src/lib/log/compiler/message.cc
@@ -107,7 +107,7 @@ currentTime() {
// Convert to string and strip out the trailing newline
string current_time = buffer;
- return isc::strutil::trim(current_time);
+ return isc::util::str::trim(current_time);
}
@@ -127,7 +127,7 @@ sentinel(Filename& file) {
string name = file.name();
string ext = file.extension();
string sentinel_text = "__" + name + "_" + ext.substr(1);
- isc::strutil::uppercase(sentinel_text);
+ isc::util::str::uppercase(sentinel_text);
return sentinel_text;
}
@@ -208,7 +208,7 @@ splitNamespace(string ns) {
// ... and return the vector of namespace components split on the single
// colon.
- return isc::strutil::tokens(ns, ":");
+ return isc::util::str::tokens(ns, ":");
}
@@ -537,7 +537,7 @@ main(int argc, char* argv[]) {
text += global.getText(e.id());
// Format with arguments
- text = isc::strutil::format(text, e.arguments());
+ text = isc::util::str::format(text, e.arguments());
cerr << text << "\n";
return 1;
diff --git a/src/lib/log/message_reader.cc b/src/lib/log/message_reader.cc
index 9d936a1..7281346 100644
--- a/src/lib/log/message_reader.cc
+++ b/src/lib/log/message_reader.cc
@@ -69,7 +69,7 @@ void
MessageReader::processLine(const string& line, MessageReader::Mode mode) {
// Get rid of leading and trailing spaces
- string text = isc::strutil::trim(line);
+ string text = isc::util::str::trim(line);
if (text.empty()) {
; // Ignore blank lines
@@ -93,10 +93,10 @@ MessageReader::parseDirective(const std::string& text) {
// Break into tokens
- vector<string> tokens = isc::strutil::tokens(text);
+ vector<string> tokens = isc::util::str::tokens(text);
// Uppercase directive and branch on valid ones
- isc::strutil::uppercase(tokens[0]);
+ isc::util::str::uppercase(tokens[0]);
if (tokens[0] == string("$PREFIX")) {
parsePrefix(tokens);
} else if (tokens[0] == string("$NAMESPACE")) {
@@ -123,7 +123,7 @@ MessageReader::parsePrefix(const vector<string>& tokens) {
// As a style, we are going to have the symbols in uppercase
string prefix = tokens[1];
- isc::strutil::uppercase(prefix);
+ isc::util::str::uppercase(prefix);
// Token is potentially valid providing it only contains alphabetic
// and numeric characters (and underscores) and does not start with a
diff --git a/src/lib/nsas/hash_table.h b/src/lib/nsas/hash_table.h
index 1a9de5e..c028fa4 100644
--- a/src/lib/nsas/hash_table.h
+++ b/src/lib/nsas/hash_table.h
@@ -48,7 +48,7 @@ struct HashTableSlot {
typedef typename std::list<boost::shared_ptr<T> >::iterator iterator;
///< Iterator over elements with same hash
- typedef isc::locks::upgradable_mutex mutex_type;
+ typedef isc::util::locks::upgradable_mutex mutex_type;
///< Mutex protecting this slot
//@}
@@ -115,11 +115,11 @@ public:
///
//@{
typedef typename
- isc::locks::sharable_lock<typename HashTableSlot<T>::mutex_type>
+ isc::util::locks::sharable_lock<typename HashTableSlot<T>::mutex_type>
sharable_lock; ///< Type for a scope-limited read-lock
typedef typename
- isc::locks::scoped_lock<typename HashTableSlot<T>::mutex_type>
+ isc::util::locks::scoped_lock<typename HashTableSlot<T>::mutex_type>
scoped_lock; ///< Type for a scope-limited write-lock
//@}
diff --git a/src/lib/nsas/nameserver_entry.cc b/src/lib/nsas/nameserver_entry.cc
index 40d5cd7..d991bcb 100644
--- a/src/lib/nsas/nameserver_entry.cc
+++ b/src/lib/nsas/nameserver_entry.cc
@@ -52,7 +52,7 @@ namespace nsas {
namespace {
// Just shorter type alias
-typedef isc::locks::scoped_lock<isc::locks::recursive_mutex> Lock;
+typedef isc::util::locks::scoped_lock<isc::util::locks::recursive_mutex> Lock;
}
diff --git a/src/lib/nsas/nameserver_entry.h b/src/lib/nsas/nameserver_entry.h
index fe3b23b..0f214c6 100644
--- a/src/lib/nsas/nameserver_entry.h
+++ b/src/lib/nsas/nameserver_entry.h
@@ -247,7 +247,7 @@ public:
//@}
private:
- mutable isc::locks::recursive_mutex mutex_;///< Mutex protecting this object
+ mutable isc::util::locks::recursive_mutex mutex_;///< Mutex protecting this object
std::string name_; ///< Canonical name of the nameserver
isc::dns::RRClass classCode_; ///< Class of the nameserver
/**
diff --git a/src/lib/nsas/tests/nsas_test.h b/src/lib/nsas/tests/nsas_test.h
index 0bdcd4b..0bd5e36 100644
--- a/src/lib/nsas/tests/nsas_test.h
+++ b/src/lib/nsas/tests/nsas_test.h
@@ -26,7 +26,7 @@
#include <config.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/message.h>
#include <dns/rdata.h>
#include <dns/rrtype.h>
@@ -40,7 +40,7 @@
using namespace isc::dns::rdata;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace {
MessagePtr
diff --git a/src/lib/nsas/zone_entry.cc b/src/lib/nsas/zone_entry.cc
index 878f193..1c5df03 100644
--- a/src/lib/nsas/zone_entry.cc
+++ b/src/lib/nsas/zone_entry.cc
@@ -53,7 +53,7 @@ ZoneEntry::ZoneEntry(
namespace {
// Shorter aliases for frequently used types
-typedef isc::locks::scoped_lock<isc::locks::recursive_mutex> Lock; // Local lock, nameservers not locked
+typedef isc::util::locks::scoped_lock<isc::util::locks::recursive_mutex> Lock; // Local lock, nameservers not locked
typedef boost::shared_ptr<AddressRequestCallback> CallbackPtr;
/*
diff --git a/src/lib/nsas/zone_entry.h b/src/lib/nsas/zone_entry.h
index acd769b..f772784 100644
--- a/src/lib/nsas/zone_entry.h
+++ b/src/lib/nsas/zone_entry.h
@@ -133,7 +133,7 @@ protected:
time_t expiry_; ///< Expiry time of this entry, 0 means not set
//}@
private:
- mutable isc::locks::recursive_mutex mutex_;///< Mutex protecting this zone entry
+ mutable isc::util::locks::recursive_mutex mutex_;///< Mutex protecting this zone entry
std::string name_; ///< Canonical zone name
isc::dns::RRClass class_code_; ///< Class code
/**
diff --git a/src/lib/resolve/recursive_query.cc b/src/lib/resolve/recursive_query.cc
index af6cc2d..2acede8 100644
--- a/src/lib/resolve/recursive_query.cc
+++ b/src/lib/resolve/recursive_query.cc
@@ -42,7 +42,7 @@
using isc::log::dlog;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace asiolink {
diff --git a/src/lib/resolve/recursive_query.h b/src/lib/resolve/recursive_query.h
index 4f049a6..ebdab95 100644
--- a/src/lib/resolve/recursive_query.h
+++ b/src/lib/resolve/recursive_query.h
@@ -17,7 +17,7 @@
#include <asiolink/dns_service.h>
#include <asiolink/dns_server.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <nsas/nameserver_address_store.h>
#include <cache/resolver_cache.h>
@@ -99,7 +99,7 @@ public:
/// \param server A pointer to the \c DNSServer object handling the client
void resolve(const isc::dns::Question& question,
isc::dns::MessagePtr answer_message,
- isc::util::io::OutputBufferPtr buffer,
+ isc::util::OutputBufferPtr buffer,
DNSServer* server);
/// \brief Set Test Server
diff --git a/src/lib/resolve/tests/recursive_query_unittest.cc b/src/lib/resolve/tests/recursive_query_unittest.cc
index 868d86c..4f340c7 100644
--- a/src/lib/resolve/tests/recursive_query_unittest.cc
+++ b/src/lib/resolve/tests/recursive_query_unittest.cc
@@ -30,7 +30,7 @@
#include <dns/tests/unittest_util.h>
#include <dns/rcode.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/message.h>
#include <nsas/nameserver_address_store.h>
@@ -56,7 +56,7 @@ using isc::UnitTestUtil;
using namespace std;
using namespace asiolink;
using namespace isc::dns;
-using namespace isc::util::io;
+using namespace isc::util;
namespace {
const char* const TEST_SERVER_PORT = "53535";
@@ -320,7 +320,7 @@ protected:
boost::shared_ptr<asiolink::IOMessage> io_message_;
isc::dns::MessagePtr message_;
isc::dns::MessagePtr answer_message_;
- isc::util::io::OutputBufferPtr respbuf_;
+ isc::util::OutputBufferPtr respbuf_;
// Callback functions provided by the caller
const SimpleCallback* checkin_;
diff --git a/src/lib/resolve/tests/recursive_query_unittest_2.cc b/src/lib/resolve/tests/recursive_query_unittest_2.cc
index a0048ae..75f026c 100644
--- a/src/lib/resolve/tests/recursive_query_unittest_2.cc
+++ b/src/lib/resolve/tests/recursive_query_unittest_2.cc
@@ -23,8 +23,8 @@
#include <asio.hpp>
-#include <util/io/buffer.h>
-#include <util/io/io_utilities.h>
+#include <util/buffer.h>
+#include <util/io_utilities.h>
#include <dns/question.h>
#include <dns/message.h>
@@ -49,7 +49,7 @@ using namespace asio;
using namespace asio::ip;
using namespace isc::dns;
using namespace isc::dns::rdata;
-using namespace isc::util::io;
+using namespace isc::util;
using namespace isc::resolve;
using namespace std;
diff --git a/src/lib/testutils/srv_test.cc b/src/lib/testutils/srv_test.cc
index fe5a742..783aae7 100644
--- a/src/lib/testutils/srv_test.cc
+++ b/src/lib/testutils/srv_test.cc
@@ -26,7 +26,7 @@
using namespace isc::dns;
using namespace asiolink;
-using namespace isc::util::io;
+using namespace isc::util;
namespace isc {
namespace testutils {
diff --git a/src/lib/testutils/srv_test.h b/src/lib/testutils/srv_test.h
index 85e4432..a848ffc 100644
--- a/src/lib/testutils/srv_test.h
+++ b/src/lib/testutils/srv_test.h
@@ -12,7 +12,7 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <dns/name.h>
#include <dns/message.h>
#include <dns/messagerenderer.h>
@@ -99,9 +99,9 @@ protected:
asiolink::IOSocket* io_sock;
asiolink::IOMessage* io_message;
const asiolink::IOEndpoint* endpoint;
- isc::util::io::OutputBuffer request_obuffer;
+ isc::util::OutputBuffer request_obuffer;
isc::dns::MessageRenderer request_renderer;
- isc::util::io::OutputBufferPtr response_obuffer;
+ isc::util::OutputBufferPtr response_obuffer;
std::vector<uint8_t> data;
};
} // end of namespace testutils
diff --git a/src/lib/util/Makefile.am b/src/lib/util/Makefile.am
index 46ec749..4df3bec 100644
--- a/src/lib/util/Makefile.am
+++ b/src/lib/util/Makefile.am
@@ -10,16 +10,16 @@ lib_LTLIBRARIES = libutil.la
libutil_la_SOURCES = filename.h filename.cc
libutil_la_SOURCES += locks.h lru_list.h
libutil_la_SOURCES += strutil.h strutil.cc
-libutil_la_SOURCES += compat/base16_from_binary.h
-libutil_la_SOURCES += compat/base32hex.h compat/base64.h
-libutil_la_SOURCES += compat/base32hex_from_binary.h
-libutil_la_SOURCES += compat/base_n.cc compat/hex.h
-libutil_la_SOURCES += compat/binary_from_base32hex.h
-libutil_la_SOURCES += compat/binary_from_base16.h
-libutil_la_SOURCES += compat/sha1.h compat/sha1.cc
-libutil_la_SOURCES += compat/time_utilities.h
-libutil_la_SOURCES += compat/time_utilities.cc
-libutil_la_SOURCES += io/buffer.h io/io_utilities.h
+libutil_la_SOURCES += buffer.h io_utilities.h
+libutil_la_SOURCES += coder/base16_from_binary.h
+libutil_la_SOURCES += coder/base32hex.h coder/base64.h
+libutil_la_SOURCES += coder/base32hex_from_binary.h
+libutil_la_SOURCES += coder/base_n.cc coder/hex.h
+libutil_la_SOURCES += coder/binary_from_base32hex.h
+libutil_la_SOURCES += coder/binary_from_base16.h
+libutil_la_SOURCES += coder/sha1.h coder/sha1.cc
+libutil_la_SOURCES += coder/time_utilities.h
+libutil_la_SOURCES += coder/time_utilities.cc
libutil_la_SOURCES += random/qid_gen.h random/qid_gen.cc
libutil_la_SOURCES += random/random_number_generator.h
diff --git a/src/lib/util/buffer.h b/src/lib/util/buffer.h
new file mode 100644
index 0000000..58c75f5
--- /dev/null
+++ b/src/lib/util/buffer.h
@@ -0,0 +1,446 @@
+// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __BUFFER_H
+#define __BUFFER_H 1
+
+#include <vector>
+
+#include <string.h>
+
+#include <stdint.h>
+
+#include <exceptions/exceptions.h>
+
+#include <boost/shared_ptr.hpp>
+
+namespace isc {
+namespace util {
+
+///
+/// \brief A standard DNS module exception that is thrown if an out-of-range
+/// buffer operation is being performed.
+///
+class InvalidBufferPosition : public Exception {
+public:
+ InvalidBufferPosition(const char* file, size_t line, const char* what) :
+ isc::Exception(file, line, what) {}
+};
+
+///\brief The \c InputBuffer class is a buffer abstraction for manipulating
+/// read-only data.
+///
+/// The main purpose of this class is to provide a safe placeholder for
+/// examining wire-format data received from a network.
+///
+/// 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 BIND10 DNS library. One common usage of this
+/// class for an application would therefore be something like this:
+///
+/// \code unsigned char buf[1024];
+/// struct sockaddr addr;
+/// socklen_t addrlen = sizeof(addr);
+/// int cc = recvfrom(s, buf, sizeof(buf), 0, &addr, &addrlen);
+/// InputBuffer buffer(buf, cc);
+/// // pass the buffer to a DNS message object to parse the message \endcode
+///
+/// Other BIND10 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.
+///
+/// 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 responsibility to ensure
+/// the data remains valid throughout the lifetime of the \c InputBuffer
+/// object. Likewise, this object generally assumes the data isn't modified
+/// throughout its lifetime; if the application modifies the data while this
+/// object retains a 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.
+///
+/// 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 DNS message can be
+/// as large as a few KB. Alternatively, we could allow the object to allocate
+/// memory internally and expose it to the application to store network data
+/// in it. This is also a bad design, however, in that we would effectively
+/// break the abstraction employed in the class, and do so by publishing
+/// "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.
+///
+/// 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 will take place from the
+/// head of the unread data. An object of this class internally holds (a
+/// notion of) where the next read operation should start. We call it the
+/// <em>read position</em> in this document.
+class InputBuffer {
+public:
+ ///
+ /// \name Constructors and Destructor
+ //@{
+ /// \brief Constructor from variable length of data.
+ ///
+ /// 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.
+ /// \param len The length of the data in bytes.
+ InputBuffer(const void* data, size_t len) :
+ position_(0), data_(static_cast<const uint8_t*>(data)), len_(len) {}
+ //@}
+
+ ///
+ /// \name Getter Methods
+ //@{
+ /// \brief Return the length of the data stored in the buffer.
+ size_t getLength() const { return (len_); }
+ /// \brief Return the current read position.
+ size_t getPosition() const { return (position_); }
+ //@}
+
+ ///
+ /// \name Setter Methods
+ ///
+ //@{
+ /// \brief Set the read position of the buffer to the given value.
+ ///
+ /// The new position must be in the valid range of the buffer; otherwise
+ /// an exception of class \c isc::dns::InvalidBufferPosition will be thrown.
+ /// \param position The new position (offset from the beginning of the
+ /// buffer).
+ void setPosition(size_t position)
+ {
+ if (position > len_)
+ isc_throw(InvalidBufferPosition, "position is too large");
+ position_ = position;
+ }
+ //@}
+
+ ///
+ /// \name Methods for reading data from the buffer.
+ //@{
+ /// \brief Read an unsigned 8-bit integer from the buffer and return it.
+ ///
+ /// If the remaining length of the buffer is smaller than 8-bit, an
+ /// exception of class \c isc::dns::InvalidBufferPosition will be thrown.
+ uint8_t readUint8()
+ {
+ if (position_ + sizeof(uint8_t) > len_) {
+ isc_throw(InvalidBufferPosition, "read beyond end of buffer");
+ }
+
+ return (data_[position_++]);
+ }
+ /// \brief Read an unsigned 16-bit integer in network byte order from the
+ /// buffer, convert it to host byte order, and return it.
+ ///
+ /// If the remaining length of the buffer is smaller than 16-bit, an
+ /// exception of class \c isc::dns::InvalidBufferPosition will be thrown.
+ uint16_t readUint16()
+ {
+ uint16_t data;
+ const uint8_t* cp;
+
+ if (position_ + sizeof(data) > len_) {
+ isc_throw(InvalidBufferPosition, "read beyond end of buffer");
+ }
+
+ cp = &data_[position_];
+ data = ((unsigned int)(cp[0])) << 8;
+ data |= ((unsigned int)(cp[1]));
+ position_ += sizeof(data);
+
+ return (data);
+ }
+ /// \brief Read an unsigned 32-bit integer in network byte order from the
+ /// buffer, convert it to host byte order, and return it.
+ ///
+ /// If the remaining length of the buffer is smaller than 32-bit, an
+ /// exception of class \c isc::dns::InvalidBufferPosition will be thrown.
+ uint32_t readUint32()
+ {
+ uint32_t data;
+ const uint8_t* cp;
+
+ if (position_ + sizeof(data) > len_) {
+ isc_throw(InvalidBufferPosition, "read beyond end of buffer");
+ }
+
+ cp = &data_[position_];
+ data = ((unsigned int)(cp[0])) << 24;
+ data |= ((unsigned int)(cp[1])) << 16;
+ data |= ((unsigned int)(cp[2])) << 8;
+ data |= ((unsigned int)(cp[3]));
+ position_ += sizeof(data);
+
+ return (data);
+ }
+ /// \brief Read data of the specified length from the buffer and copy it to
+ /// the caller supplied buffer.
+ ///
+ /// 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::dns::InvalidBufferPosition will
+ /// be thrown.
+ void readData(void* data, size_t len)
+ {
+ if (position_ + len > len_) {
+ isc_throw(InvalidBufferPosition, "read beyond end of buffer");
+ }
+
+ memcpy(data, &data_[position_], len);
+ position_ += len;
+ }
+ //@}
+
+private:
+ size_t position_;
+
+ // XXX: The following must be private, but for a short term workaround with
+ // Boost.Python binding, we changed it to protected. We should soon
+ // revisit it.
+protected:
+ const uint8_t* data_;
+ size_t len_;
+};
+
+///
+///\brief The \c OutputBuffer class is a buffer abstraction for manipulating
+/// mutable data.
+///
+/// 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.
+///
+/// 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:
+///
+/// \code OutputBuffer buffer(4096); // give a sufficiently large initial size
+/// // pass the buffer to a DNS message object to construct a wire-format
+/// // DNS message.
+/// struct sockaddr to;
+/// sendto(s, buffer.getData(), buffer.getLength(), 0, &to, sizeof(to));
+/// \endcode
+///
+/// where the \c getData() 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 encapsulated "handle" of an object to its user.
+/// Unfortunately, there is no easy way to avoid this without involving
+/// expensive data copy if we want to use this object with a legacy API such as
+/// a BSD socket interface. And, indeed, this is one major purpose for this
+/// object. Applications should use this method only under 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.
+///
+/// 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 more memory and copying
+/// data. It is therefore recommended to construct the buffer object with a
+/// sufficiently large initial 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.
+///
+/// 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 operation will take place from
+/// the end of the buffer. Other methods to emulate "random access" are also
+/// provided (e.g., \c writeUint16At()). The normal write operations are
+/// normally exception-free as this class automatically extends the buffer
+/// when necessary. However, in extreme cases such as an attempt of 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.
+///
+/// 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
+/// a concrete derived class. That way we can provide flexibility for future
+/// extension such as more efficient 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
+/// 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 {
+public:
+ ///
+ /// \name Constructors and Destructor
+ ///
+ //@{
+ /// \brief Constructor from the initial size of the buffer.
+ ///
+ /// \param len The initial length of the buffer in bytes.
+ OutputBuffer(size_t len) { data_.reserve(len); }
+ //@}
+
+ ///
+ /// \name Getter Methods
+ ///
+ //@{
+ /// \brief Return the current capacity of the buffer.
+ size_t getCapacity() const { return (data_.capacity()); }
+ /// \brief Return a pointer to the head of the data stored in the buffer.
+ ///
+ /// The caller can assume that the subsequent \c getLength() bytes are
+ /// identical to the stored data of the buffer.
+ ///
+ /// Note: The pointer returned by this method may be invalidated after a
+ /// subsequent write operation.
+ const void* getData() const { return (&data_[0]); }
+ /// \brief Return the length of data written in the buffer.
+ size_t getLength() const { return (data_.size()); }
+ /// \brief Return the value of the buffer at the specified position.
+ ///
+ /// \c pos must specify the valid position of the buffer; otherwise an
+ /// exception class of \c InvalidBufferPosition will be thrown.
+ ///
+ /// \param pos The position in the buffer to be returned.
+ const uint8_t& operator[](size_t pos) const
+ {
+ if (pos >= data_.size()) {
+ isc_throw(InvalidBufferPosition, "read at invalid position");
+ }
+ return (data_[pos]);
+ }
+ //@}
+
+ ///
+ /// \name Methods for writing data into the buffer.
+ ///
+ //@{
+ /// \brief Insert a specified length of gap at the end of the buffer.
+ ///
+ /// 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 \ref writeUint16At().
+ /// \param len The length of the gap to be inserted in bytes.
+ void skip(size_t len) { data_.insert(data_.end(), len, 0); }
+
+ /// \brief Trim the specified length of data from the end of the buffer.
+ ///
+ /// The specified length must not exceed the current data size of the
+ /// buffer; otherwise an exception of class \c isc::OutOfRange will
+ /// be thrown.
+ ///
+ /// \param len The length of data that should be trimmed.
+ void trim(size_t len)
+ {
+ if (len > data_.size()) {
+ isc_throw(OutOfRange, "trimming too large from output buffer");
+ }
+ data_.resize(data_.size() - len);
+ }
+ /// \brief Clear buffer content.
+ ///
+ /// This method can be used to re-initialize and reuse the buffer without
+ /// constructing a new one.
+ void clear() { data_.clear(); }
+ /// \brief Write an unsigned 8-bit integer into the buffer.
+ ///
+ /// \param data The 8-bit integer to be written into the buffer.
+ void writeUint8(uint8_t data) { data_.push_back(data); }
+
+ /// \brief Write an unsigned 8-bit integer into the buffer.
+ ///
+ /// The position must be lower than the size of the buffer,
+ /// otherwise an exception of class \c isc::dns::InvalidBufferPosition
+ /// will be thrown.
+ ///
+ /// \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) {
+ if (pos + sizeof(data) > data_.size()) {
+ isc_throw(InvalidBufferPosition, "write at invalid position");
+ }
+ data_[pos] = data;
+ }
+
+ /// \brief Write an unsigned 16-bit integer in host byte order into the
+ /// buffer in network byte order.
+ ///
+ /// \param data The 16-bit integer to be written into the buffer.
+ void writeUint16(uint16_t data)
+ {
+ data_.push_back(static_cast<uint8_t>((data & 0xff00U) >> 8));
+ data_.push_back(static_cast<uint8_t>(data & 0x00ffU));
+ }
+ /// \brief Write an unsigned 16-bit integer in host byte order at the
+ /// specified position of the buffer in network byte order.
+ ///
+ /// 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::dns::InvalidBufferPosition will
+ /// be thrown.
+ /// 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) > data_.size()) {
+ isc_throw(InvalidBufferPosition, "write at invalid position");
+ }
+
+ data_[pos] = static_cast<uint8_t>((data & 0xff00U) >> 8);
+ data_[pos + 1] = static_cast<uint8_t>(data & 0x00ffU);
+ }
+ /// \brief Write an unsigned 32-bit integer in host byte order
+ /// into the buffer in network byte order.
+ ///
+ /// \param data The 32-bit integer to be written into the buffer.
+ void writeUint32(uint32_t data)
+ {
+ data_.push_back(static_cast<uint8_t>((data & 0xff000000) >> 24));
+ data_.push_back(static_cast<uint8_t>((data & 0x00ff0000) >> 16));
+ data_.push_back(static_cast<uint8_t>((data & 0x0000ff00) >> 8));
+ data_.push_back(static_cast<uint8_t>(data & 0x000000ff));
+ }
+ /// \brief Copy an arbitrary length of data into the buffer.
+ ///
+ /// 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)
+ {
+ const uint8_t* cp = static_cast<const uint8_t*>(data);
+ data_.insert(data_.end(), cp, cp + len);
+ }
+ //@}
+
+private:
+ std::vector<uint8_t> data_;
+};
+
+/// \brief Pointer-like types pointing to \c InputBuffer or \c OutputBuffer
+///
+/// These types are expected to be used as an argument in asynchronous
+/// callback functions. The internal reference-counting will ensure that
+/// that ongoing state information will not be lost if the object
+/// that originated the asynchronous call falls out of scope.
+typedef boost::shared_ptr<InputBuffer> InputBufferPtr;
+typedef boost::shared_ptr<OutputBuffer> OutputBufferPtr;
+
+} // namespace util
+} // namespace isc
+#endif // __BUFFER_H
+
+// Local Variables:
+// mode: c++
+// End:
diff --git a/src/lib/util/coder/base16_from_binary.h b/src/lib/util/coder/base16_from_binary.h
new file mode 100644
index 0000000..8606c61
--- /dev/null
+++ b/src/lib/util/coder/base16_from_binary.h
@@ -0,0 +1,108 @@
+#ifndef BOOST_ARCHIVE_ITERATORS_BASE16_FROM_BINARY_HPP
+#define BOOST_ARCHIVE_ITERATORS_BASE16_FROM_BINARY_HPP
+
+// MS compatible compilers support #pragma once
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// base16_from_binary.h (derived from boost base64_from_binary.hpp)
+
+// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#include <cassert>
+
+#include <cstddef> // size_t
+#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
+#if defined(BOOST_NO_STDC_NAMESPACE)
+namespace std{
+ using ::size_t;
+} // namespace std
+#endif
+
+// See base32hex_from_binary.h for why we need base64_from...hpp here.
+#include <boost/archive/iterators/base64_from_binary.hpp>
+
+namespace boost {
+namespace archive {
+namespace iterators {
+
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// convert binary integers to base16 characters
+
+namespace detail {
+
+template<class CharType>
+struct from_4_bit {
+ typedef CharType result_type;
+ CharType operator()(CharType t) const{
+ const char * lookup_table =
+ "0123456789"
+ "ABCDEF";
+ assert(t < 16);
+ return (lookup_table[static_cast<size_t>(t)]);
+ }
+};
+
+} // namespace detail
+
+// note: what we would like to do is
+// template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type>
+// typedef transform_iterator<
+// from_4_bit<CharType>,
+// transform_width<Base, 4, sizeof(Base::value_type) * 8, CharType>
+// > base16_from_binary;
+// but C++ won't accept this. Rather than using a "type generator" and
+// using a different syntax, make a derivation which should be equivalent.
+//
+// Another issue addressed here is that the transform_iterator doesn't have
+// a templated constructor. This makes it incompatible with the dataflow
+// ideal. This is also addressed here.
+
+//template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type>
+template<
+ class Base,
+ class CharType = BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type
+>
+class base16_from_binary :
+ public transform_iterator<
+ detail::from_4_bit<CharType>,
+ Base
+ >
+{
+ friend class boost::iterator_core_access;
+ typedef transform_iterator<
+ BOOST_DEDUCED_TYPENAME detail::from_4_bit<CharType>,
+ Base
+ > super_t;
+
+public:
+ // make composible buy using templated constructor
+ template<class T>
+ base16_from_binary(BOOST_PFTO_WRAPPER(T) start) :
+ super_t(
+ Base(BOOST_MAKE_PFTO_WRAPPER(static_cast<T>(start))),
+ detail::from_4_bit<CharType>()
+ )
+ {}
+ // intel 7.1 doesn't like default copy constructor
+ base16_from_binary(const base16_from_binary & rhs) :
+ super_t(
+ Base(rhs.base_reference()),
+ detail::from_4_bit<CharType>()
+ )
+ {}
+// base16_from_binary(){};
+};
+
+} // namespace iterators
+} // namespace archive
+} // namespace boost
+
+#endif // BOOST_ARCHIVE_ITERATORS_BASE16_FROM_BINARY_HPP
diff --git a/src/lib/util/coder/base32hex.h b/src/lib/util/coder/base32hex.h
new file mode 100644
index 0000000..255352c
--- /dev/null
+++ b/src/lib/util/coder/base32hex.h
@@ -0,0 +1,64 @@
+// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __BASE32HEX_H
+#define __BASE32HEX_H 1
+
+#include <stdint.h>
+#include <string>
+#include <vector>
+
+//
+// Note: this helper module isn't specific to the DNS protocol per se.
+// We should probably move this to somewhere else, possibly in some common
+// utility area.
+//
+
+namespace isc {
+namespace util {
+namespace coder {
+
+/// \brief Encode binary data in the base32hex format.
+///
+/// The underlying implementation is shared with \c encodeBase64, and all
+/// description except the format (base32hex) equally applies.
+///
+/// Note: the encoding format is base32hex, not base32.
+///
+/// \param binary A vector object storing the data to be encoded.
+/// \return A newly created string that stores base32hex encoded value for
+/// binary.
+std::string encodeBase32Hex(const std::vector<uint8_t>& binary);
+
+/// \brief Decode a text encoded in the base32hex format into the
+/// original %data.
+///
+/// The underlying implementation is shared with \c decodeBase64, and all
+/// description except the format (base32hex) equally applies.
+///
+/// Note: the encoding format is base32hex, not base32.
+///
+/// \param input A text encoded in the base32hex format.
+/// \param result A vector in which the decoded %data is to be stored.
+void decodeBase32Hex(const std::string& input, std::vector<uint8_t>& result);
+
+} // namespace coder
+} // namespace util
+} // namespace isc
+
+#endif // __BASE32HEX_H
+
+// Local Variables:
+// mode: c++
+// End:
diff --git a/src/lib/util/coder/base32hex_from_binary.h b/src/lib/util/coder/base32hex_from_binary.h
new file mode 100644
index 0000000..5d16d04
--- /dev/null
+++ b/src/lib/util/coder/base32hex_from_binary.h
@@ -0,0 +1,110 @@
+#ifndef BOOST_ARCHIVE_ITERATORS_BASE32HEX_FROM_BINARY_HPP
+#define BOOST_ARCHIVE_ITERATORS_BASE32HEX_FROM_BINARY_HPP
+
+// MS compatible compilers support #pragma once
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// base32hex_from_binary.h (derived from boost base64_from_binary.hpp)
+
+// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#include <cassert>
+
+#include <cstddef> // size_t
+#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
+#if defined(BOOST_NO_STDC_NAMESPACE)
+namespace std{
+ using ::size_t;
+} // namespace std
+#endif
+
+// We use the same boost header files used in "base64_from_". Since the
+// precise path to these headers may vary depending on the boost version we
+// simply include the base64 header here.
+#include <boost/archive/iterators/base64_from_binary.hpp>
+
+namespace boost {
+namespace archive {
+namespace iterators {
+
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// convert binary integers to base32hex characters
+
+namespace detail {
+
+template<class CharType>
+struct from_5_bit {
+ typedef CharType result_type;
+ CharType operator()(CharType t) const{
+ const char * lookup_table =
+ "0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUV";
+ assert(t < 32);
+ return (lookup_table[static_cast<size_t>(t)]);
+ }
+};
+
+} // namespace detail
+
+// note: what we would like to do is
+// template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type>
+// typedef transform_iterator<
+// from_5_bit<CharType>,
+// transform_width<Base, 5, sizeof(Base::value_type) * 8, CharType>
+// > base32hex_from_binary;
+// but C++ won't accept this. Rather than using a "type generator" and
+// using a different syntax, make a derivation which should be equivalent.
+//
+// Another issue addressed here is that the transform_iterator doesn't have
+// a templated constructor. This makes it incompatible with the dataflow
+// ideal. This is also addressed here.
+
+//template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type>
+template<
+ class Base,
+ class CharType = BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type
+>
+class base32hex_from_binary :
+ public transform_iterator<
+ detail::from_5_bit<CharType>,
+ Base
+ >
+{
+ friend class boost::iterator_core_access;
+ typedef transform_iterator<
+ BOOST_DEDUCED_TYPENAME detail::from_5_bit<CharType>,
+ Base
+ > super_t;
+
+public:
+ // make composible buy using templated constructor
+ template<class T>
+ base32hex_from_binary(BOOST_PFTO_WRAPPER(T) start) :
+ super_t(
+ Base(BOOST_MAKE_PFTO_WRAPPER(static_cast<T>(start))),
+ detail::from_5_bit<CharType>()
+ )
+ {}
+ // intel 7.1 doesn't like default copy constructor
+ base32hex_from_binary(const base32hex_from_binary & rhs) :
+ super_t(
+ Base(rhs.base_reference()),
+ detail::from_5_bit<CharType>()
+ )
+ {}
+// base32hex_from_binary(){};
+};
+
+} // namespace iterators
+} // namespace archive
+} // namespace boost
+
+#endif // BOOST_ARCHIVE_ITERATORS_BASE32HEX_FROM_BINARY_HPP
diff --git a/src/lib/util/coder/base64.h b/src/lib/util/coder/base64.h
new file mode 100644
index 0000000..98abfad
--- /dev/null
+++ b/src/lib/util/coder/base64.h
@@ -0,0 +1,79 @@
+// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __BASE64_H
+#define __BASE64_H 1
+
+#include <stdint.h>
+#include <string>
+#include <vector>
+
+//
+// Note: this helper module isn't specific to the DNS protocol per se.
+// We should probably move this to somewhere else, possibly in some common
+// utility area.
+//
+
+namespace isc {
+namespace util {
+namespace coder {
+
+/// \brief Encode binary data in the base64 format.
+///
+/// This function returns a new \c std::string object that stores a text
+/// encoded in the base64 format for the given \c binary %data.
+/// The resulting string will be a valid, canonical form of base64
+/// representation as specified in RFC4648.
+///
+/// If memory allocation for the returned string fails, a corresponding
+/// standard exception will be thrown. This function never throws exceptions
+/// otherwise.
+///
+/// \param binary A vector object storing the data to be encoded.
+/// \return A newly created string that stores base64 encoded value for binary.
+std::string encodeBase64(const std::vector<uint8_t>& binary);
+
+/// \brief Decode a text encoded in the base64 format into the original %data.
+///
+/// The \c input argument must be a valid string represented in the base64
+/// format as specified in RFC4648. Space characters (spaces, tabs, newlines)
+/// can be included in \c input and will be ignored. Without spaces, the
+/// length of string must be a multiple of 4 bytes with necessary paddings.
+/// Also it must be encoded using the canonical encoding (see RFC4648).
+/// If any of these conditions is not met, an exception of class
+/// \c isc::BadValue will be thrown.
+///
+/// If \c result doesn't have sufficient capacity to store all decoded %data
+/// and memory allocation fails, a corresponding standard exception will be
+/// thrown. If the caller knows the necessary length (which can in theory
+/// be calculated from the input string), this situation can be avoided by
+/// reserving sufficient space for \c result beforehand.
+///
+/// Any existing %data in \c result will be removed. This is the case in some
+/// of the cases where an exception is thrown; that is, this function only
+/// provides the basic exception guarantee.
+///
+/// \param input A text encoded in the base64 format.
+/// \param result A vector in which the decoded %data is to be stored.
+void decodeBase64(const std::string& input, std::vector<uint8_t>& result);
+
+} // namespace coder
+} // namespace util
+} // namespace isc
+
+#endif // __BASE64_H
+
+// Local Variables:
+// mode: c++
+// End:
diff --git a/src/lib/util/coder/base_n.cc b/src/lib/util/coder/base_n.cc
new file mode 100644
index 0000000..d288b1a
--- /dev/null
+++ b/src/lib/util/coder/base_n.cc
@@ -0,0 +1,398 @@
+// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <stdint.h>
+#include <cassert>
+#include <iterator>
+#include <string>
+#include <vector>
+
+#include <boost/archive/iterators/base64_from_binary.hpp>
+#include <boost/archive/iterators/binary_from_base64.hpp>
+#include <boost/archive/iterators/transform_width.hpp>
+#include <boost/math/common_factor.hpp>
+
+#include <util/coder/base32hex_from_binary.h>
+#include <util/coder/binary_from_base32hex.h>
+#include <util/coder/base16_from_binary.h>
+#include <util/coder/binary_from_base16.h>
+#include <util/coder/base32hex.h>
+#include <util/coder/base64.h>
+
+#include <exceptions/exceptions.h>
+
+using namespace std;
+using namespace boost::archive::iterators;
+
+namespace isc {
+namespace util {
+namespace coder {
+
+// In the following anonymous namespace, we provide a generic framework
+// to encode/decode baseN format. We use the following tools:
+// - boost base64_from_binary/binary_from_base64: provide mapping table for
+// base64.
+// These classes take another iterator (Base) as a template argument, and
+// their dereference operator (operator*()) first retrieves an input value
+// from Base via Base::operator* and converts the value using their mapping
+// table. The converted value is returned as their own operator*.
+// - base{32hex,16}_from_binary/binary_from_base{32hex,16}: provide mapping
+// table for base32hex and base16. A straightforward variation of their
+// base64 counterparts.
+// - EncodeNormalizer/DecodeNormalizer: supplemental filter handling baseN
+// padding characters (=)
+// - boost transform_width: an iterator framework for handling data stream
+// per bit-group. It takes another iterator (Base) and output/input bit
+// numbers (BitsOut/BitsIn) template arguments. A transform_width object
+// internally maintains a bit stream, which can be retrieved per BitsOut
+// bits via its dereference operator (operator*()). It builds the stream
+// by internally iterating over the Base object via Base::operator++ and
+// Base::operator*, using the least BitsIn bits of the result of
+// Base::operator*. In our usage BitsIn for encoding and BitsOut for
+// decoding are always 8 (# of bits for one byte).
+//
+// Its dereference operator
+// retrieves BitsIn bits from the result of "*Base" (if necessary it
+// internally calls ++Base)
+//
+// A conceptual description of how the encoding and decoding work is as
+// follows:
+// Encoding:
+// input binary data => Normalizer (append sufficient number of 0 bits)
+// => transform_width (extract bit groups from the original
+// stream)
+// => baseXX_from_binary (convert each bit group to an
+// encoded byte using the mapping)
+// Decoding:
+// input baseXX text => Normalizer (convert '='s to the encoded characters
+// corresponding to 0, e.g. 'A's in base64)
+// => binary_from_baseXX (convert each encoded byte into
+// the original group bit)
+// => transform_width (build original byte stream by
+// concatenating the decoded bit
+// stream)
+//
+// Below, we define a set of templated classes to handle different parameters
+// for different encoding algorithms.
+namespace {
+// Common constants used for all baseN encoding.
+const char BASE_PADDING_CHAR = '=';
+const uint8_t BINARY_ZERO_CODE = 0;
+
+// EncodeNormalizer is an input iterator intended to be used as a filter
+// between the binary stream and baseXX_from_binary translator (via
+// transform_width). An EncodeNormalizer object is configured with two
+// iterators (base and base_end), specifying the head and end of the input
+// stream. It internally iterators over the original stream, and return
+// each byte of the stream intact via its dereference operator until it
+// reaches the end of the stream. After that the EncodeNormalizer object
+// will return 0 no matter how many times it is subsequently incremented.
+// This is necessary because the input binary stream may not contain
+// sufficient bits for a full encoded text while baseXX_from_binary expects
+// a sufficient length of input.
+// Note: this class is intended to be used within this implementation file,
+// and assumes "base < base_end" on construction without validating the
+// arguments. The behavior is undefined if this assumption doesn't hold.
+class EncodeNormalizer : public iterator<input_iterator_tag, uint8_t> {
+public:
+ EncodeNormalizer(const vector<uint8_t>::const_iterator& base,
+ const vector<uint8_t>::const_iterator& base_end) :
+ base_(base), base_end_(base_end), in_pad_(false)
+ {}
+ EncodeNormalizer& operator++() {
+ if (!in_pad_) {
+ ++base_;
+ }
+ if (base_ == base_end_) {
+ in_pad_ = true;
+ }
+ return (*this);
+ }
+ const uint8_t& operator*() const {
+ if (in_pad_) {
+ return (BINARY_ZERO_CODE);
+ } else {
+ return (*base_);
+ }
+ }
+ bool operator==(const EncodeNormalizer& other) const {
+ return (base_ == other.base_);
+ }
+private:
+ vector<uint8_t>::const_iterator base_;
+ const vector<uint8_t>::const_iterator base_end_;
+ bool in_pad_;
+};
+
+// DecodeNormalizer is an input iterator intended to be used as a filter
+// between the encoded baseX stream and binary_from_baseXX.
+// A DecodeNormalizer object is configured with three string iterators
+// (base, base_beinpad, and base_beginpad), specifying the head of the string,
+// the beginning position of baseX padding (when there's padding), and
+// end of the string, respectively. It internally iterators over the original
+// stream, and return each character of the encoded string via its dereference
+// operator until it reaches base_beginpad. After that the DecodeNormalizer
+// will return the encoding character corresponding to the all-0 value
+// (which is specified on construction via base_zero_code. see also
+// BaseZeroCode below). This translation is necessary because
+// binary_from_baseXX doesn't accept the padding character (i.e. '=').
+// Note: this class is intended to be used within this implementation file,
+// and for simplicity assumes "base < base_beginpad <= base_end" on
+// construction without validating the arguments. The behavior is undefined
+// if this assumption doesn't hold.
+class DecodeNormalizer : public iterator<input_iterator_tag, char> {
+public:
+ DecodeNormalizer(const char base_zero_code,
+ const string::const_iterator& base,
+ const string::const_iterator& base_beginpad,
+ const string::const_iterator& base_end) :
+ base_zero_code_(base_zero_code),
+ base_(base), base_beginpad_(base_beginpad), base_end_(base_end),
+ in_pad_(false)
+ {}
+ DecodeNormalizer& operator++() {
+ ++base_;
+ while (base_ != base_end_ && isspace(*base_)) {
+ ++base_;
+ }
+ if (base_ == base_beginpad_) {
+ in_pad_ = true;
+ }
+ return (*this);
+ }
+ const char& operator*() const {
+ if (in_pad_ && *base_ == BASE_PADDING_CHAR) {
+ return (base_zero_code_);
+ } else {
+ return (*base_);
+ }
+ }
+ bool operator==(const DecodeNormalizer& other) const {
+ return (base_ == other.base_);
+ }
+private:
+ const char base_zero_code_;
+ string::const_iterator base_;
+ const string::const_iterator base_beginpad_;
+ const string::const_iterator base_end_;
+ bool in_pad_;
+};
+
+// BitsPerChunk: number of bits to be converted using the baseN mapping table.
+// e.g. 6 for base64.
+// BaseZeroCode: the byte character that represents a value of 0 in
+// the corresponding encoding. e.g. 'A' for base64.
+// Encoder: baseX_from_binary<transform_width<EncodeNormalizer,
+// BitsPerChunk, 8> >
+// Decoder: transform_width<binary_from_baseX<DecodeNormalizer>,
+// 8, BitsPerChunk>
+template <int BitsPerChunk, char BaseZeroCode,
+ typename Encoder, typename Decoder>
+struct BaseNTransformer {
+ static string encode(const vector<uint8_t>& binary);
+ static void decode(const char* algorithm,
+ const string& base64, vector<uint8_t>& result);
+
+ // BITS_PER_GROUP is the number of bits for the smallest possible (non
+ // empty) bit string that can be converted to a valid baseN encoded text
+ // without padding. It's the least common multiple of 8 and BitsPerChunk,
+ // e.g. 24 for base64.
+ static const int BITS_PER_GROUP =
+ boost::math::static_lcm<BitsPerChunk, 8>::value;
+
+ // MAX_PADDING_CHARS is the maximum number of padding characters
+ // that can appear in a valid baseN encoded text.
+ // It's group_len - chars_for_byte, where group_len is the number of
+ // encoded characters to represent BITS_PER_GROUP bits, and
+ // chars_for_byte is the number of encoded character that is needed to
+ // represent a single byte, which is ceil(8 / BitsPerChunk).
+ // For example, for base64 we need two encoded characters to represent a
+ // byte, and each group consists of 4 encoded characters, so
+ // MAX_PADDING_CHARS is 4 - 2 = 2.
+ static const int MAX_PADDING_CHARS =
+ BITS_PER_GROUP / BitsPerChunk -
+ (8 / BitsPerChunk + ((8 % BitsPerChunk) == 0 ? 0 : 1));
+};
+
+template <int BitsPerChunk, char BaseZeroCode,
+ typename Encoder, typename Decoder>
+string
+BaseNTransformer<BitsPerChunk, BaseZeroCode, Encoder, Decoder>::encode(
+ const vector<uint8_t>& binary)
+{
+ // calculate the resulting length.
+ size_t bits = binary.size() * 8;
+ if (bits % BITS_PER_GROUP > 0) {
+ bits += (BITS_PER_GROUP - (bits % BITS_PER_GROUP));
+ }
+ const size_t len = bits / BitsPerChunk;
+
+ string result;
+ result.reserve(len);
+ result.assign(Encoder(EncodeNormalizer(binary.begin(), binary.end())),
+ Encoder(EncodeNormalizer(binary.end(), binary.end())));
+ assert(len >= result.length());
+ result.append(len - result.length(), BASE_PADDING_CHAR);
+ return (result);
+}
+
+template <int BitsPerChunk, char BaseZeroCode,
+ typename Encoder, typename Decoder>
+void
+BaseNTransformer<BitsPerChunk, BaseZeroCode, Encoder, Decoder>::decode(
+ const char* const algorithm,
+ const string& input,
+ vector<uint8_t>& result)
+{
+ // enumerate the number of trailing padding characters (=), ignoring
+ // white spaces. since baseN_from_binary doesn't accept padding,
+ // we handle it explicitly.
+ size_t padchars = 0;
+ string::const_reverse_iterator srit = input.rbegin();
+ string::const_reverse_iterator srit_end = input.rend();
+ while (srit != srit_end) {
+ char ch = *srit;
+ if (ch == BASE_PADDING_CHAR) {
+ if (++padchars > MAX_PADDING_CHARS) {
+ isc_throw(BadValue, "Too many " << algorithm
+ << " padding characters: " << input);
+ }
+ } else if (!isspace(ch)) {
+ break;
+ }
+ ++srit;
+ }
+ // then calculate the number of padding bits corresponding to the padding
+ // characters. In general, the padding bits consist of all-zero
+ // trailing bits of the last encoded character followed by zero bits
+ // represented by the padding characters:
+ // 1st pad 2nd pad 3rd pad...
+ // +++===== ======= ===... (+: from encoded chars, =: from pad chars)
+ // 0000...0 0......0 000...
+ // 0 7 8 15 16.... (bits)
+ // The number of bits for the '==...' part is padchars * BitsPerChunk.
+ // So the total number of padding bits is the smallest multiple of 8
+ // that is >= padchars * BitsPerChunk.
+ // (Below, note the common idiom of the bitwise AND with ~7. It clears the
+ // lowest three bits, so has the effect of rounding the result down to the
+ // nearest multiple of 8)
+ const size_t padbits = (padchars * BitsPerChunk + 7) & ~7;
+
+ // In some encoding algorithm, it could happen that a padding byte would
+ // contain a full set of encoded bits, which is not allowed by definition
+ // of padding. For example, if BitsPerChunk is 5, the following
+ // representation could happen:
+ // ++00000= (+: from encoded chars, 0: encoded char for '0', =: pad chars)
+ // 0 7 (bits)
+ // This must actually be encoded as follows:
+ // ++======
+ // 0 7 (bits)
+ // The following check rejects this type of invalid encoding.
+ if (padbits > BitsPerChunk * (padchars + 1)) {
+ isc_throw(BadValue, "Invalid " << algorithm << "padding: " << input);
+ }
+
+ // convert the number of bits in bytes for convenience.
+ const size_t padbytes = padbits / 8;
+
+ try {
+ result.assign(Decoder(DecodeNormalizer(BaseZeroCode, input.begin(),
+ srit.base(), input.end())),
+ Decoder(DecodeNormalizer(BaseZeroCode, input.end(),
+ input.end(), input.end())));
+ } catch (const dataflow_exception& ex) {
+ // convert any boost exceptions into our local one.
+ isc_throw(BadValue, ex.what());
+ }
+
+ // Confirm the original BaseX text is the canonical encoding of the
+ // data, that is, that the first byte of padding is indeed 0.
+ // (DecodeNormalizer and binary_from_baseXX ensure that the rest of the
+ // padding is all zero).
+ assert(result.size() >= padbytes);
+ if (padbytes > 0 && *(result.end() - padbytes) != 0) {
+ isc_throw(BadValue, "Non 0 bits included in " << algorithm
+ << " padding: " << input);
+ }
+
+ // strip the padded zero-bit fields
+ result.resize(result.size() - padbytes);
+}
+
+//
+// Instantiation for BASE-64
+//
+typedef
+base64_from_binary<transform_width<EncodeNormalizer, 6, 8> > base64_encoder;
+typedef
+transform_width<binary_from_base64<DecodeNormalizer>, 8, 6> base64_decoder;
+typedef BaseNTransformer<6, 'A', base64_encoder, base64_decoder>
+Base64Transformer;
+
+//
+// Instantiation for BASE-32HEX
+//
+typedef
+base32hex_from_binary<transform_width<EncodeNormalizer, 5, 8> >
+base32hex_encoder;
+typedef
+transform_width<binary_from_base32hex<DecodeNormalizer>, 8, 5>
+base32hex_decoder;
+typedef BaseNTransformer<5, '0', base32hex_encoder, base32hex_decoder>
+Base32HexTransformer;
+
+//
+// Instantiation for BASE-16 (HEX)
+//
+typedef
+base16_from_binary<transform_width<EncodeNormalizer, 4, 8> > base16_encoder;
+typedef
+transform_width<binary_from_base16<DecodeNormalizer>, 8, 4> base16_decoder;
+typedef BaseNTransformer<4, '0', base16_encoder, base16_decoder>
+Base16Transformer;
+}
+
+string
+encodeBase64(const vector<uint8_t>& binary) {
+ return (Base64Transformer::encode(binary));
+}
+
+void
+decodeBase64(const string& input, vector<uint8_t>& result) {
+ Base64Transformer::decode("base64", input, result);
+}
+
+string
+encodeBase32Hex(const vector<uint8_t>& binary) {
+ return (Base32HexTransformer::encode(binary));
+}
+
+void
+decodeBase32Hex(const string& input, vector<uint8_t>& result) {
+ Base32HexTransformer::decode("base32hex", input, result);
+}
+
+string
+encodeHex(const vector<uint8_t>& binary) {
+ return (Base16Transformer::encode(binary));
+}
+
+void
+decodeHex(const string& input, vector<uint8_t>& result) {
+ Base16Transformer::decode("base16", input, result);
+}
+
+} // namespace coder
+} // namespace util
+} // namespace isc
diff --git a/src/lib/util/coder/binary_from_base16.h b/src/lib/util/coder/binary_from_base16.h
new file mode 100644
index 0000000..50342f1
--- /dev/null
+++ b/src/lib/util/coder/binary_from_base16.h
@@ -0,0 +1,120 @@
+#ifndef BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE16_HPP
+#define BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE16_HPP
+
+// MS compatible compilers support #pragma once
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// binary_from_base16.h (derived from boost binary_from_base64.hpp)
+
+// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#include <cassert>
+
+// See binary_from_base32hex.h for why we need _from_base64.hpp here.
+#include <boost/archive/iterators/binary_from_base64.hpp>
+
+#include <exceptions/exceptions.h>
+
+namespace boost {
+namespace archive {
+namespace iterators {
+
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// convert base16 characters to binary data
+
+namespace detail {
+
+template<class CharType>
+struct to_4_bit {
+ typedef CharType result_type;
+ CharType operator()(CharType t) const{
+ const char lookup_table[] = {
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 00-0f
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 10-1f
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 20-2f
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1, // 30-3f
+ -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 40-4f
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 50-5f
+ -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1 // 60-6f
+ };
+ // metrowerks trips this assertion - how come?
+ #if ! defined(__MWERKS__)
+ BOOST_STATIC_ASSERT(0x70 == sizeof(lookup_table));
+ #endif
+ signed char value = -1;
+ if((unsigned)t < sizeof(lookup_table))
+ value = lookup_table[(unsigned)t];
+ if(-1 == value) {
+ isc_throw(isc::BadValue,
+ "attempt to decode a value not in base16 char set");
+ }
+ return (value);
+ }
+};
+
+} // namespace detail
+
+// note: what we would like to do is
+// template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type>
+// typedef transform_iterator<
+// from_4_bit<CharType>,
+// transform_width<Base, 4, sizeof(Base::value_type) * 8, CharType>
+// > base16_from_binary;
+// but C++ won't accept this. Rather than using a "type generator" and
+// using a different syntax, make a derivation which should be equivalent.
+//
+// Another issue addressed here is that the transform_iterator doesn't have
+// a templated constructor. This makes it incompatible with the dataflow
+// ideal. This is also addressed here.
+
+template<
+ class Base,
+ class CharType = BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type
+>
+class binary_from_base16 : public
+ transform_iterator<
+ detail::to_4_bit<CharType>,
+ Base
+ >
+{
+ friend class boost::iterator_core_access;
+ typedef transform_iterator<
+ detail::to_4_bit<CharType>,
+ Base
+ > super_t;
+public:
+ // make composible buy using templated constructor
+ template<class T>
+ binary_from_base16(BOOST_PFTO_WRAPPER(T) start) :
+ super_t(
+ Base(BOOST_MAKE_PFTO_WRAPPER(static_cast<T>(start))),
+ detail::to_4_bit<CharType>()
+ )
+ {}
+ // intel 7.1 doesn't like default copy constructor
+ binary_from_base16(const binary_from_base16 & rhs) :
+ super_t(
+ Base(rhs.base_reference()),
+ detail::to_4_bit<CharType>()
+ )
+ {}
+// binary_from_base16(){};
+};
+
+} // namespace iterators
+} // namespace archive
+} // namespace boost
+
+#endif // BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE16_HPP
+
+// Local Variables:
+// mode: c++
+// End:
diff --git a/src/lib/util/coder/binary_from_base32hex.h b/src/lib/util/coder/binary_from_base32hex.h
new file mode 100644
index 0000000..1d83f54
--- /dev/null
+++ b/src/lib/util/coder/binary_from_base32hex.h
@@ -0,0 +1,123 @@
+#ifndef BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE32HEX_HPP
+#define BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE32HEX_HPP
+
+// MS compatible compilers support #pragma once
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// binary_from_base32hex.h (derived from boost binary_from_base64.hpp)
+
+// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#include <cassert>
+
+// We use the same boost header files used in "_from_base64". Since the
+// precise path to these headers may vary depending on the boost version we
+// simply include the base64 header here.
+#include <boost/archive/iterators/binary_from_base64.hpp>
+
+#include <exceptions/exceptions.h>
+
+namespace boost {
+namespace archive {
+namespace iterators {
+
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// convert base32hex characters to binary data
+
+namespace detail {
+
+template<class CharType>
+struct to_5_bit {
+ typedef CharType result_type;
+ CharType operator()(CharType t) const{
+ const char lookup_table[] = {
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 00-0f
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 10-1f
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 20-2f
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1, // 30-3f
+ -1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, // 40-4f
+ 25,26,27,28,29,30,31,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 50-5f
+ -1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, // 60-6f
+ 25,26,27,28,29,30,31,-1,-1,-1,-1,-1,-1,-1,-1,-1 // 70-7f
+ };
+ // metrowerks trips this assertion - how come?
+ #if ! defined(__MWERKS__)
+ BOOST_STATIC_ASSERT(0x80 == sizeof(lookup_table));
+ #endif
+ signed char value = -1;
+ if((unsigned)t < sizeof(lookup_table))
+ value = lookup_table[(unsigned)t];
+ if(-1 == value) {
+ isc_throw(isc::BadValue,
+ "attempt to decode a value not in base32hex char set");
+ }
+ return (value);
+ }
+};
+
+} // namespace detail
+
+// note: what we would like to do is
+// template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type>
+// typedef transform_iterator<
+// from_5_bit<CharType>,
+// transform_width<Base, 5, sizeof(Base::value_type) * 8, CharType>
+// > base32hex_from_binary;
+// but C++ won't accept this. Rather than using a "type generator" and
+// using a different syntax, make a derivation which should be equivalent.
+//
+// Another issue addressed here is that the transform_iterator doesn't have
+// a templated constructor. This makes it incompatible with the dataflow
+// ideal. This is also addressed here.
+
+template<
+ class Base,
+ class CharType = BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type
+>
+class binary_from_base32hex : public
+ transform_iterator<
+ detail::to_5_bit<CharType>,
+ Base
+ >
+{
+ friend class boost::iterator_core_access;
+ typedef transform_iterator<
+ detail::to_5_bit<CharType>,
+ Base
+ > super_t;
+public:
+ // make composible buy using templated constructor
+ template<class T>
+ binary_from_base32hex(BOOST_PFTO_WRAPPER(T) start) :
+ super_t(
+ Base(BOOST_MAKE_PFTO_WRAPPER(static_cast<T>(start))),
+ detail::to_5_bit<CharType>()
+ )
+ {}
+ // intel 7.1 doesn't like default copy constructor
+ binary_from_base32hex(const binary_from_base32hex & rhs) :
+ super_t(
+ Base(rhs.base_reference()),
+ detail::to_5_bit<CharType>()
+ )
+ {}
+// binary_from_base32hex(){};
+};
+
+} // namespace iterators
+} // namespace archive
+} // namespace boost
+
+#endif // BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE32HEX_HPP
+
+// Local Variables:
+// mode: c++
+// End:
diff --git a/src/lib/util/coder/hex.h b/src/lib/util/coder/hex.h
new file mode 100644
index 0000000..f930ff4
--- /dev/null
+++ b/src/lib/util/coder/hex.h
@@ -0,0 +1,65 @@
+// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __HEX_H
+#define __HEX_H 1
+
+#include <stdint.h>
+#include <string>
+#include <vector>
+
+//
+// Note: this helper module isn't specific to the DNS protocol per se.
+// We should probably move this to somewhere else, possibly in some common
+// utility area.
+//
+
+namespace isc {
+namespace util {
+namespace coder {
+/// \brief Encode binary data in the base16 ('hex') format.
+///
+/// The underlying implementation is shared with \c encodeBase64, and most of
+/// the description except the format (base16) equally applies.
+/// Another notable exception is that the base16 encoding doesn't require
+/// padding, so padding related considerations and the notion of canonical
+/// encoding don't apply.
+///
+/// \param binary A vector object storing the data to be encoded.
+/// \return A newly created string that stores base16 encoded value for
+/// binary.
+std::string encodeHex(const std::vector<uint8_t>& binary);
+
+/// \brief Decode a text encoded in the base16 ('hex') format into the
+/// original %data.
+///
+/// The underlying implementation is shared with \c decodeBase64, and most
+/// of the description except the format (base16) equally applies.
+/// Another notable exception is that the base16 encoding doesn't require
+/// padding, so padding related considerations and the notion of canonical
+/// encoding don't apply.
+///
+/// \param input A text encoded in the base16 format.
+/// \param result A vector in which the decoded %data is to be stored.
+void decodeHex(const std::string& input, std::vector<uint8_t>& result);
+
+} // namespace coder
+} // namespace util
+} // namespace isc
+
+#endif // __HEX_H
+
+// Local Variables:
+// mode: c++
+// End:
diff --git a/src/lib/util/coder/sha1.cc b/src/lib/util/coder/sha1.cc
new file mode 100644
index 0000000..8c963be
--- /dev/null
+++ b/src/lib/util/coder/sha1.cc
@@ -0,0 +1,492 @@
+/*
+ * Description:
+ * This file implements the Secure Hash Signature Standard
+ * algorithms as defined in the National Institute of Standards
+ * and Technology Federal Information Processing Standards
+ * Publication (FIPS PUB) 180-1 published on April 17, 1995, 180-2
+ * published on August 1, 2002, and the FIPS PUB 180-2 Change
+ * Notice published on February 28, 2004.
+ *
+ * A combined document showing all algorithms is available at
+ * http://csrc.nist.gov/publications/fips/
+ * fips180-2/fips180-2withchangenotice.pdf
+ *
+ * The SHA-1 algorithm produces a 160-bit message digest for a
+ * given data stream. It should take about 2**n steps to find a
+ * message with the same digest as a given message and
+ * 2**(n/2) to find any two messages with the same digest,
+ * when n is the digest size in bits. Therefore, this
+ * algorithm can serve as a means of providing a
+ * "fingerprint" for a message.
+ *
+ * Portability Issues:
+ * SHA-1 is defined in terms of 32-bit "words". This code
+ * uses <stdint.h> (included via "sha.h") to define 32 and 8
+ * bit unsigned integer types. If your C compiler does not
+ * support 32 bit unsigned integers, this code is not
+ * appropriate.
+ *
+ * Caveats:
+ * SHA-1 is designed to work with messages less than 2^64 bits
+ * long. This implementation uses SHA1Input() to hash the bits
+ * that are a multiple of the size of an 8-bit character, and then
+ * uses SHA1FinalBits() to hash the final few bits of the input.
+ *
+ * Authorship:
+ * This file is adapted from RFC 4634, by D. Eastlake et al.
+ * Copyright (C) The Internet Society (2006).
+ *
+ * Permission is granted for all uses, commercial and non-commercial,
+ * of the sample code found in Section 8. Royalty free license to
+ * use, copy, modify and distribute the software found in Section 8 is
+ * granted, provided that this document is identified in all material
+ * mentioning or referencing this software, and provided that
+ * redistributed derivative works do not contain misleading author or
+ * version information.
+ *
+ * The authors make no representations concerning either the
+ * merchantability of this software or the suitability of this
+ * software for any particular purpose. It is provided "as is"
+ * without express or implied warranty of any kind.
+ *
+ */
+#include <util/coder/sha1.h>
+
+namespace isc {
+namespace util {
+namespace coder {
+
+/* Local Function Prototyptes */
+static void SHA1Finalize(SHA1Context *, uint8_t Pad_Byte);
+static void SHA1PadMessage(SHA1Context *, uint8_t Pad_Byte);
+static void SHA1ProcessMessageBlock(SHA1Context *);
+
+/*
+ * Define functions used by SHA1 hash
+ */
+static inline uint32_t
+SHA_Ch(const uint32_t x, const uint32_t y, const uint32_t z) {
+ return (((x) & ((y) ^ (z))) ^ (z));
+}
+
+static inline uint32_t
+SHA_Maj(const uint32_t x, const uint32_t y, const uint32_t z) {
+ return (((x) & ((y) | (z))) | ((y) & (z)));
+}
+
+static inline uint32_t
+SHA_Parity(const uint32_t x, const uint32_t y, const uint32_t z) {
+ return ((x) ^ (y) ^ (z));
+}
+
+static inline int
+SHA1CircularShift(uint8_t bits, uint32_t word) {
+ return ((word << bits) | (word >> (32 - bits)));
+}
+
+static inline bool
+SHA1AddLength(SHA1Context *context, uint32_t length) {
+ uint32_t addTemp = context->Length_Low;
+ context->Length_Low += length;
+ if (context->Length_Low < addTemp && ++context->Length_High == 0) {
+ return (true);
+ } else {
+ return (false);
+ }
+}
+
+/*
+ * SHA1Reset
+ *
+ * Description:
+ * This function will initialize the SHA1Context in preparation
+ * for computing a new SHA1 message digest.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to reset.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+int
+SHA1Reset(SHA1Context *context) {
+ if (!context) {
+ return (SHA_NULL);
+ }
+
+ context->Length_Low = 0;
+ context->Length_High = 0;
+ context->Message_Block_Index = 0;
+
+ context->Intermediate_Hash[0] = 0x67452301;
+ context->Intermediate_Hash[1] = 0xEFCDAB89;
+ context->Intermediate_Hash[2] = 0x98BADCFE;
+ context->Intermediate_Hash[3] = 0x10325476;
+ context->Intermediate_Hash[4] = 0xC3D2E1F0;
+
+ context->Computed = 0;
+ context->Corrupted = 0;
+ return (SHA_SUCCESS);
+}
+
+
+/*
+ * SHA1Input
+ *
+ * Description:
+ * This function accepts an array of octets as the next portion
+ * of the message.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update
+ * message_array: [in]
+ * An array of characters representing the next portion of
+ * the message.
+ * length: [in]
+ * The length of the message in message_array
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+int
+SHA1Input(SHA1Context *context, const uint8_t *message_array, unsigned length) {
+ if (!length) {
+ return (SHA_SUCCESS);
+ }
+
+ if (!context || !message_array) {
+ return (SHA_NULL);
+ }
+
+ if (context->Computed) {
+ context->Corrupted = SHA_STATEERROR;
+ return (SHA_STATEERROR);
+ }
+
+ if (context->Corrupted) {
+ return (context->Corrupted);
+ }
+
+ while(length-- && !context->Corrupted) {
+ context->Message_Block[context->Message_Block_Index++] =
+ (*message_array & 0xFF);
+
+ if (!SHA1AddLength(context, 8) &&
+ (context->Message_Block_Index == SHA1_BLOCKSIZE))
+ {
+ SHA1ProcessMessageBlock(context);
+ }
+
+ message_array++;
+ }
+
+ return (SHA_SUCCESS);
+}
+
+/*
+ * SHA1FinalBits
+ *
+ * Description:
+ * This function will add in any final bits of the message.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update
+ * message_bits: [in]
+ * The final bits of the message, in the upper portion of the
+ * byte. (Use 0b###00000 instead of 0b00000### to input the
+ * three bits ###.)
+ * length: [in]
+ * The number of bits in message_bits, between 1 and 7.
+ *
+ * Returns:
+ * sha Error Code.
+ */
+int SHA1FinalBits(SHA1Context *context, const uint8_t message_bits,
+ unsigned int length)
+{
+ uint8_t masks[8] = {
+ /* 0 0b00000000 */ 0x00,
+ /* 1 0b10000000 */ 0x80,
+ /* 2 0b11000000 */ 0xC0,
+ /* 3 0b11100000 */ 0xE0,
+ /* 4 0b11110000 */ 0xF0,
+ /* 5 0b11111000 */ 0xF8,
+ /* 6 0b11111100 */ 0xFC,
+ /* 7 0b11111110 */ 0xFE
+ };
+ uint8_t markbit[8] = {
+ /* 0 0b10000000 */ 0x80,
+ /* 1 0b01000000 */ 0x40,
+ /* 2 0b00100000 */ 0x20,
+ /* 3 0b00010000 */ 0x10,
+ /* 4 0b00001000 */ 0x08,
+ /* 5 0b00000100 */ 0x04,
+ /* 6 0b00000010 */ 0x02,
+ /* 7 0b00000001 */ 0x01
+ };
+
+ if (!length) {
+ return (SHA_SUCCESS);
+ }
+
+ if (!context) {
+ return (SHA_NULL);
+ }
+
+ if (context->Computed || (length >= 8) || (length == 0)) {
+ context->Corrupted = SHA_STATEERROR;
+ return (SHA_STATEERROR);
+ }
+
+ if (context->Corrupted) {
+ return (context->Corrupted);
+ }
+
+ SHA1AddLength(context, length);
+ SHA1Finalize(context,
+ (uint8_t) ((message_bits & masks[length]) | markbit[length]));
+
+ return (SHA_SUCCESS);
+}
+
+/*
+ * SHA1Result
+ *
+ * Description:
+ * This function will return the 160-bit message digest into the
+ * Message_Digest array provided by the caller.
+ * NOTE: The first octet of hash is stored in the 0th element,
+ * the last octet of hash in the 19th element.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to use to calculate the SHA-1 hash.
+ * Message_Digest: [out]
+ * Where the digest is returned.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+int
+SHA1Result(SHA1Context *context, uint8_t Message_Digest[SHA1_HASHSIZE]) {
+ int i;
+
+ if (!context || !Message_Digest) {
+ return (SHA_NULL);
+ }
+
+ if (context->Corrupted) {
+ return (context->Corrupted);
+ }
+
+ if (!context->Computed) {
+ SHA1Finalize(context, 0x80);
+ }
+
+ for(i = 0; i < SHA1_HASHSIZE; ++i) {
+ Message_Digest[i] = context->Intermediate_Hash[i>>2]
+ >> 8 * (3 - (i & 0x03));
+ }
+
+ return (SHA_SUCCESS);
+}
+
+/*
+ * SHA1Finalize
+ *
+ * Description:
+ * This helper function finishes off the digest calculations.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The SHA context to update
+ * Pad_Byte: [in]
+ * The last byte to add to the digest before the 0-padding
+ * and length. This will contain the last bits of the message
+ * followed by another single bit. If the message was an
+ * exact multiple of 8-bits long, Pad_Byte will be 0x80.
+ *
+ * Returns:
+ * sha Error Code.
+ *
+ */
+static void SHA1Finalize(SHA1Context *context, uint8_t Pad_Byte) {
+ int i;
+ SHA1PadMessage(context, Pad_Byte);
+ /* message may be sensitive, clear it out */
+ for (i = 0; i < SHA1_BLOCKSIZE; ++i)
+ context->Message_Block[i] = 0;
+ context->Length_Low = 0; /* and clear length */
+ context->Length_High = 0;
+ context->Computed = 1;
+}
+
+/*
+ * SHA1PadMessage
+ *
+ * Description:
+ * According to the standard, the message must be padded to an even
+ * 512 bits. The first padding bit must be a '1'. The last 64
+ * bits represent the length of the original message. All bits in
+ * between should be 0. This function will pad the message
+ * according to those rules by filling the Message_Block array
+ * accordingly. It will also call the ProcessMessageBlock function
+ * provided appropriately. When it returns, it can be assumed that
+ * the message digest has been computed.
+ *
+ * Parameters:
+ * context: [in/out]
+ * The context to pad
+ * Pad_Byte: [in]
+ * The last byte to add to the digest before the 0-padding
+ * and length. This will contain the last bits of the message
+ * followed by another single bit. If the message was an
+ * exact multiple of 8-bits long, Pad_Byte will be 0x80.
+ *
+ * Returns:
+ * Nothing.
+ *
+ */
+static void SHA1PadMessage(SHA1Context *context, uint8_t Pad_Byte) {
+ /*
+ * Check to see if the current message block is too small to hold
+ * the initial padding bits and length. If so, we will pad the
+ * block, process it, and then continue padding into a second
+ * block.
+ */
+ if (context->Message_Block_Index >= (SHA1_BLOCKSIZE - 8)) {
+ context->Message_Block[context->Message_Block_Index++] = Pad_Byte;
+ while (context->Message_Block_Index < SHA1_BLOCKSIZE) {
+ context->Message_Block[context->Message_Block_Index++] = 0;
+ }
+
+ SHA1ProcessMessageBlock(context);
+ } else
+ context->Message_Block[context->Message_Block_Index++] = Pad_Byte;
+
+ while (context->Message_Block_Index < (SHA1_BLOCKSIZE - 8))
+ context->Message_Block[context->Message_Block_Index++] = 0;
+
+ /*
+ * Store the message length as the last 8 octets
+ */
+ context->Message_Block[56] = (uint8_t) (context->Length_High >> 24);
+ context->Message_Block[57] = (uint8_t) (context->Length_High >> 16);
+ context->Message_Block[58] = (uint8_t) (context->Length_High >> 8);
+ context->Message_Block[59] = (uint8_t) (context->Length_High);
+ context->Message_Block[60] = (uint8_t) (context->Length_Low >> 24);
+ context->Message_Block[61] = (uint8_t) (context->Length_Low >> 16);
+ context->Message_Block[62] = (uint8_t) (context->Length_Low >> 8);
+ context->Message_Block[63] = (uint8_t) (context->Length_Low);
+
+ SHA1ProcessMessageBlock(context);
+}
+
+/*
+ * SHA1ProcessMessageBlock
+ *
+ * Description:
+ * This helper function will process the next 512 bits of the
+ * message stored in the Message_Block array.
+ *
+ * Parameters:
+ * None.
+ *
+ * Returns:
+ * Nothing.
+ *
+ * Comments:
+ * Many of the variable names in this code, especially the
+ * single character names, were used because those were the
+ * names used in the publication.
+ *
+ *
+ */
+static void
+SHA1ProcessMessageBlock(SHA1Context *context) {
+ /* Constants defined in FIPS-180-2, section 4.2.1 */
+ const uint32_t K[] = {
+ 0x5A827999,
+ 0x6ED9EBA1,
+ 0x8F1BBCDC,
+ 0xCA62C1D6
+ };
+ int t; /* Loop counter */
+ uint32_t temp; /* Temporary word value */
+ uint32_t W[80]; /* Word sequence */
+ uint32_t A, B, C, D, E; /* Word buffers */
+
+ /*
+ * Initialize the first 16 words in the array W
+ */
+ for (t = 0; t < 16; t++) {
+ W[t] = ((uint32_t)context->Message_Block[t * 4]) << 24;
+ W[t] |= ((uint32_t)context->Message_Block[t * 4 + 1]) << 16;
+ W[t] |= ((uint32_t)context->Message_Block[t * 4 + 2]) << 8;
+ W[t] |= ((uint32_t)context->Message_Block[t * 4 + 3]);
+ }
+
+ for (t = 16; t < 80; t++) {
+ W[t] = SHA1CircularShift(1, W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
+ }
+
+ A = context->Intermediate_Hash[0];
+ B = context->Intermediate_Hash[1];
+ C = context->Intermediate_Hash[2];
+ D = context->Intermediate_Hash[3];
+ E = context->Intermediate_Hash[4];
+
+ for (t = 0; t < 20; t++) {
+ temp = SHA1CircularShift(5,A) + SHA_Ch(B, C, D) + E + W[t] + K[0];
+ E = D;
+ D = C;
+ C = SHA1CircularShift(30,B);
+ B = A;
+ A = temp;
+ }
+
+ for (t = 20; t < 40; t++) {
+ temp = SHA1CircularShift(5,A) + SHA_Parity(B, C, D) + E + W[t] + K[1];
+ E = D;
+ D = C;
+ C = SHA1CircularShift(30,B);
+ B = A;
+ A = temp;
+ }
+
+ for (t = 40; t < 60; t++) {
+ temp = SHA1CircularShift(5,A) + SHA_Maj(B, C, D) + E + W[t] + K[2];
+ E = D;
+ D = C;
+ C = SHA1CircularShift(30,B);
+ B = A;
+ A = temp;
+ }
+
+ for (t = 60; t < 80; t++) {
+ temp = SHA1CircularShift(5,A) + SHA_Parity(B, C, D) + E + W[t] + K[3];
+ E = D;
+ D = C;
+ C = SHA1CircularShift(30,B);
+ B = A;
+ A = temp;
+ }
+
+ context->Intermediate_Hash[0] += A;
+ context->Intermediate_Hash[1] += B;
+ context->Intermediate_Hash[2] += C;
+ context->Intermediate_Hash[3] += D;
+ context->Intermediate_Hash[4] += E;
+
+ context->Message_Block_Index = 0;
+}
+
+} // namespace coder
+} // namespace util
+} // namespace isc
diff --git a/src/lib/util/coder/sha1.h b/src/lib/util/coder/sha1.h
new file mode 100644
index 0000000..2a0b7dd
--- /dev/null
+++ b/src/lib/util/coder/sha1.h
@@ -0,0 +1,91 @@
+/*
+ * sha1.h
+ *
+ * Description:
+ * This is the header file for code which implements the Secure
+ * Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
+ * April 17, 1995.
+ *
+ * Many of the variable names in this code, especially the
+ * single character names, were used because those were the names
+ * used in the publication.
+ *
+ * Please read the file sha1.cc for more information.
+ *
+ * Authorship:
+ * This file is adapted from RFC 4634, by D. Eastlake et al.
+ * Copyright (C) The Internet Society (2006).
+ *
+ * Permission is granted for all uses, commercial and non-commercial,
+ * of the sample code found in Section 8. Royalty free license to
+ * use, copy, modify and distribute the software found in Section 8 is
+ * granted, provided that this document is identified in all material
+ * mentioning or referencing this software, and provided that
+ * redistributed derivative works do not contain misleading author or
+ * version information.
+ *
+ * The authors make no representations concerning either the
+ * merchantability of this software or the suitability of this
+ * software for any particular purpose. It is provided "as is"
+ * without express or implied warranty of any kind.
+ */
+
+#ifndef _SHA1_H_
+#define _SHA1_H_
+
+#include <stdint.h>
+
+namespace isc {
+namespace util {
+namespace coder {
+/*
+ * If you do not have the ISO standard stdint.h header file, then you
+ * must typdef the following:
+ * name meaning
+ * uint32_t unsigned 32 bit integer
+ * uint8_t unsigned 8 bit integer (i.e., unsigned char)
+ * int_least16_t integer of >= 16 bits
+ *
+ */
+
+enum {
+ SHA_SUCCESS = 0,
+ SHA_NULL, /* Null pointer parameter */
+ SHA_STATEERROR /* called Input after Result */
+};
+
+enum {
+ SHA1_HASHSIZE = 20,
+ SHA1_HASHBITS = 20,
+ SHA1_BLOCKSIZE = 64
+};
+
+/*
+ * This structure will hold context information for the SHA-1
+ * hashing operation
+ */
+typedef struct SHA1Context
+{
+ uint32_t Intermediate_Hash[SHA1_HASHSIZE/4]; /* Message Digest */
+ uint32_t Length_Low; /* Message length in bits */
+ uint32_t Length_High; /* Message length in bits */
+ int_least16_t Message_Block_Index; /* Index into message block array */
+ uint8_t Message_Block[64]; /* 512-bit message blocks */
+ int Computed; /* Is the digest computed? */
+ int Corrupted; /* Is the message digest corrupted? */
+} SHA1Context;
+
+/*
+ * Function Prototypes
+ */
+extern int SHA1Reset(SHA1Context *);
+extern int SHA1Input(SHA1Context *, const uint8_t *bytes,
+ unsigned int bytecount);
+extern int SHA1FinalBits(SHA1Context *, const uint8_t bits,
+ unsigned int bitcount);
+extern int SHA1Result(SHA1Context *, uint8_t Message_Digest[SHA1_HASHSIZE]);
+
+} // namespace coder
+} // namespace util
+} // namespace isc
+#endif
diff --git a/src/lib/util/coder/time_utilities.cc b/src/lib/util/coder/time_utilities.cc
new file mode 100644
index 0000000..4a58bcf
--- /dev/null
+++ b/src/lib/util/coder/time_utilities.cc
@@ -0,0 +1,212 @@
+// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <stdint.h>
+
+#include <sys/time.h>
+
+#include <string>
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+
+#include <stdio.h>
+#include <time.h>
+
+#include <exceptions/exceptions.h>
+
+#include <util/coder/time_utilities.h>
+
+using namespace std;
+
+namespace {
+int days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+inline bool
+isLeap(const int y) {
+ return ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0);
+}
+
+unsigned int
+yearSecs(const int year) {
+ return ((isLeap(year) ? 366 : 365 ) * 86400);
+}
+
+unsigned int
+monthSecs(const int month, const int year) {
+ return ((days[month] + ((month == 1 && isLeap(year)) ? 1 : 0 )) * 86400);
+}
+}
+
+namespace isc {
+namespace util {
+namespace coder {
+
+string
+timeToText64(uint64_t value) {
+ struct tm tm;
+ unsigned int secs;
+
+ // We cannot rely on gmtime() because time_t may not be of 64 bit
+ // integer. The following conversion logic is borrowed from BIND 9.
+ tm.tm_year = 70;
+ while ((secs = yearSecs(tm.tm_year + 1900)) <= value) {
+ value -= secs;
+ ++tm.tm_year;
+ if (tm.tm_year + 1900 > 9999) {
+ isc_throw(InvalidTime,
+ "Time value out of range (year > 9999): " <<
+ tm.tm_year + 1900);
+ }
+ }
+ tm.tm_mon = 0;
+ while ((secs = monthSecs(tm.tm_mon, tm.tm_year + 1900)) <= value) {
+ value -= secs;
+ tm.tm_mon++;
+ }
+ tm.tm_mday = 1;
+ while (86400 <= value) {
+ value -= 86400;
+ ++tm.tm_mday;
+ }
+ tm.tm_hour = 0;
+ while (3600 <= value) {
+ value -= 3600;
+ ++tm.tm_hour;
+ }
+ tm.tm_min = 0;
+ while (60 <= value) {
+ value -= 60;
+ ++tm.tm_min;
+ }
+ tm.tm_sec = value; // now t < 60, so this substitution is safe.
+
+ ostringstream oss;
+ oss << setfill('0')
+ << setw(4) << tm.tm_year + 1900
+ << setw(2) << tm.tm_mon + 1
+ << setw(2) << tm.tm_mday
+ << setw(2) << tm.tm_hour
+ << setw(2) << tm.tm_min
+ << setw(2) << tm.tm_sec;
+ return (oss.str());
+}
+
+// timeToText32() below uses the current system time. To test it with
+// unusual current time values we introduce the following function pointer;
+// when it's non NULL, we call it to get the (normally faked) current time.
+// Otherwise we use the standard gettimeofday(2). This hook is specifically
+// intended for testing purposes, so, even if it's visible outside of this
+// library, it's not even declared in a header file.
+namespace detail {
+int64_t (*gettimeFunction)() = NULL;
+}
+
+namespace {
+int64_t
+gettimeofdayWrapper() {
+ using namespace detail;
+ if (gettimeFunction != NULL) {
+ return (gettimeFunction());
+ }
+
+ struct timeval now;
+ gettimeofday(&now, NULL);
+
+ return (static_cast<int64_t>(now.tv_sec));
+}
+}
+
+string
+timeToText32(const uint32_t value) {
+ // We first adjust the time to the closest epoch based on the current time.
+ // Note that the following variables must be signed in order to handle
+ // time until year 2038 correctly.
+ const int64_t start = gettimeofdayWrapper() - 0x7fffffff;
+ int64_t base = 0;
+ int64_t t;
+ while ((t = (base + value)) < start) {
+ base += 0x100000000LL;
+ }
+
+ // Then convert it to text.
+ return (timeToText64(t));
+}
+
+namespace {
+const size_t DATE_LEN = 14; // YYYYMMDDHHmmSS
+
+inline void
+checkRange(const int min, const int max, const int value,
+ const string& valname)
+{
+ if ((value >= min) && (value <= max)) {
+ return;
+ }
+ isc_throw(InvalidTime, "Invalid " << valname << "value: " << value);
+}
+}
+
+uint64_t
+timeFromText64(const string& time_txt) {
+ // Confirm the source only consists digits. sscanf() allows some
+ // minor exceptions.
+ for (int i = 0; i < time_txt.length(); ++i) {
+ if (!isdigit(time_txt.at(i))) {
+ isc_throw(InvalidTime, "Couldn't convert non-numeric time value: "
+ << time_txt);
+ }
+ }
+
+ int year, month, day, hour, minute, second;
+ if (time_txt.length() != DATE_LEN ||
+ sscanf(time_txt.c_str(), "%4d%2d%2d%2d%2d%2d",
+ &year, &month, &day, &hour, &minute, &second) != 6)
+ {
+ isc_throw(InvalidTime, "Couldn't convert time value: " << time_txt);
+ }
+
+ checkRange(1970, 9999, year, "year");
+ checkRange(1, 12, month, "month");
+ checkRange(1, days[month - 1] + ((month == 2 && isLeap(year)) ? 1 : 0),
+ day, "day");
+ checkRange(0, 23, hour, "hour");
+ checkRange(0, 59, minute, "minute");
+ checkRange(0, 60, second, "second"); // 60 == leap second.
+
+ uint64_t timeval = second + (60 * minute) + (3600 * hour) +
+ ((day - 1) * 86400);
+ for (int m = 0; m < (month - 1); ++m) {
+ timeval += days[m] * 86400;
+ }
+ if (isLeap(year) && month > 2) {
+ timeval += 86400;
+ }
+ for (int y = 1970; y < year; ++y) {
+ timeval += ((isLeap(y) ? 366 : 365 ) * 86400);
+ }
+
+ return (timeval);
+}
+
+uint32_t
+timeFromText32(const string& time_txt) {
+ // The implicit conversion from uint64_t to uint32_t should just work here,
+ // because we only need to drop higher 32 bits.
+ return (timeFromText64(time_txt));
+}
+
+}
+}
+}
diff --git a/src/lib/util/coder/time_utilities.h b/src/lib/util/coder/time_utilities.h
new file mode 100644
index 0000000..297684a
--- /dev/null
+++ b/src/lib/util/coder/time_utilities.h
@@ -0,0 +1,147 @@
+// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __TIME_UTILITIES_H
+#define __TIME_UTILITIES_H 1
+
+#include <sys/types.h>
+#include <stdint.h>
+
+#include <exceptions/exceptions.h>
+
+//
+// Note: this helper module isn't specific to the DNS protocol per se.
+// We should probably move this to somewhere else, possibly in some common
+// utility area.
+//
+
+namespace isc {
+namespace util {
+namespace coder {
+
+///
+/// \brief A standard DNS (or ISC) module exception that is thrown if
+/// a time conversion function encounters bad input
+///
+class InvalidTime : public Exception {
+public:
+ InvalidTime(const char* file, size_t line, const char* what) :
+ isc::Exception(file, line, what) {}
+};
+
+///
+/// \name DNSSEC time conversion functions.
+///
+/// These functions convert between times represented in seconds (in integer)
+/// since epoch and those in the textual form used in the RRSIG records.
+/// For integers we provide both 32-bit and 64-bit versions.
+/// The RRSIG expiration and inception fields are both 32-bit unsigned
+/// integers, so 32-bit versions would be more useful for protocol operations.
+/// However, with 32-bit integers we need to take into account wrap-around
+/// points and compare values using the serial number arithmetic as specified
+/// in RFC4034, which would be more error prone. We therefore provide 64-bit
+/// versions, too.
+///
+/// The timezone is always UTC for these functions.
+//@{
+/// Convert textual DNSSEC time to integer, 64-bit version.
+///
+/// The textual form must only consist of digits and be in the form of
+/// YYYYMMDDHHmmSS, where:
+/// - YYYY must be between 1970 and 9999
+/// - MM must be between 01 and 12
+/// - DD must be between 01 and 31 and must be a valid day for the month
+/// represented in 'MM'. For example, if MM is 04, DD cannot be 31.
+/// DD can be 29 when MM is 02 only when YYYY is a leap year.
+/// - HH must be between 00 and 23
+/// - mm must be between 00 and 59
+/// - SS must be between 00 and 60
+///
+/// For all fields the range includes the begin and end values. Note that
+/// 60 is allowed for 'SS', intending a leap second, although in real operation
+/// it's unlikely to be specified.
+///
+/// If the given text is valid, this function converts it to an unsigned
+/// 64-bit number of seconds since epoch (1 January 1970 00:00:00) and returns
+/// the converted value. 64 bits are sufficient to represent all possible
+/// values for the valid format uniquely, so there is no overflow.
+///
+/// \note RFC4034 also defines the textual form of an unsigned decimal integer
+/// for the corresponding time in seconds. This function doesn't support
+/// this form, and if given it throws an exception of class \c InvalidTime.
+///
+/// \exception InvalidTime The given textual representation is invalid.
+///
+/// \param time_txt Textual time in the form of YYYYMMDDHHmmSS
+/// \return Seconds since epoch corresponding to \c time_txt
+uint64_t
+timeFromText64(const std::string& time_txt);
+
+/// Convert textual DNSSEC time to integer, 32-bit version.
+///
+/// This version is the same as \c timeFromText64() except that the return
+/// value is wrapped around to an unsigned 32-bit integer, simply dropping
+/// the upper 32 bits.
+uint32_t
+timeFromText32(const std::string& time_txt);
+
+/// Convert integral DNSSEC time to textual form, 64-bit version.
+///
+/// This function takes an integer that would be seconds since epoch and
+/// converts it in the form of YYYYMMDDHHmmSS. For example, if \c value is
+/// 0, it returns "19700101000000". If the value corresponds to a point
+/// of time on and after year 10,000, which cannot be represented in the
+/// YYYY... form, an exception of class \c InvalidTime will be thrown.
+///
+/// \exception InvalidTime The given time specifies on or after year 10,000.
+/// \exception Other A standard exception, if resource allocation for the
+/// returned text fails.
+///
+/// \param value Seconds since epoch to be converted.
+/// \return Textual representation of \c value in the form of YYYYMMDDHHmmSS.
+std::string
+timeToText64(uint64_t value);
+
+/// Convert integral DNSSEC time to textual form, 32-bit version.
+///
+/// This version is the same as \c timeToText64(), but the time value
+/// is expected to be the lower 32 bits of the full 64-bit value.
+/// These two will be different on and after a certain point of time
+/// in year 2106, so this function internally resolves the ambiguity
+/// using the current system time at the time of function call;
+/// it first identifies the range of [N*2^32 - 2^31, N*2^32 + 2^31)
+/// that contains the current time, and interprets \c value in the context
+/// of that range. It then applies the same process as \c timeToText64().
+///
+/// There is one important exception in this processing, however.
+/// Until 19 Jan 2038 03:14:08 (2^31 seconds since epoch), this range
+/// would contain time before epoch. In order to ensure the returned
+/// value is also a valid input to \c timeFromText, this function uses
+/// a special range [0, 2^32) until that time. As a result, all upper
+/// half of the 32-bit values are treated as a future time. For example,
+/// 2^32-1 (the highest value in 32-bit unsigned integers) will be converted
+/// to "21060207062815", instead of "19691231235959".
+std::string
+timeToText32(const uint32_t value);
+
+//@}
+}
+}
+}
+
+#endif // __DNSSECTIME_H
+
+// Local Variables:
+// mode: c++
+// End:
diff --git a/src/lib/util/compat/base16_from_binary.h b/src/lib/util/compat/base16_from_binary.h
deleted file mode 100644
index 8606c61..0000000
--- a/src/lib/util/compat/base16_from_binary.h
+++ /dev/null
@@ -1,108 +0,0 @@
-#ifndef BOOST_ARCHIVE_ITERATORS_BASE16_FROM_BINARY_HPP
-#define BOOST_ARCHIVE_ITERATORS_BASE16_FROM_BINARY_HPP
-
-// MS compatible compilers support #pragma once
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
-// base16_from_binary.h (derived from boost base64_from_binary.hpp)
-
-// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
-// Use, modification and distribution is subject to the Boost Software
-// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#include <cassert>
-
-#include <cstddef> // size_t
-#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
-#if defined(BOOST_NO_STDC_NAMESPACE)
-namespace std{
- using ::size_t;
-} // namespace std
-#endif
-
-// See base32hex_from_binary.h for why we need base64_from...hpp here.
-#include <boost/archive/iterators/base64_from_binary.hpp>
-
-namespace boost {
-namespace archive {
-namespace iterators {
-
-/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
-// convert binary integers to base16 characters
-
-namespace detail {
-
-template<class CharType>
-struct from_4_bit {
- typedef CharType result_type;
- CharType operator()(CharType t) const{
- const char * lookup_table =
- "0123456789"
- "ABCDEF";
- assert(t < 16);
- return (lookup_table[static_cast<size_t>(t)]);
- }
-};
-
-} // namespace detail
-
-// note: what we would like to do is
-// template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type>
-// typedef transform_iterator<
-// from_4_bit<CharType>,
-// transform_width<Base, 4, sizeof(Base::value_type) * 8, CharType>
-// > base16_from_binary;
-// but C++ won't accept this. Rather than using a "type generator" and
-// using a different syntax, make a derivation which should be equivalent.
-//
-// Another issue addressed here is that the transform_iterator doesn't have
-// a templated constructor. This makes it incompatible with the dataflow
-// ideal. This is also addressed here.
-
-//template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type>
-template<
- class Base,
- class CharType = BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type
->
-class base16_from_binary :
- public transform_iterator<
- detail::from_4_bit<CharType>,
- Base
- >
-{
- friend class boost::iterator_core_access;
- typedef transform_iterator<
- BOOST_DEDUCED_TYPENAME detail::from_4_bit<CharType>,
- Base
- > super_t;
-
-public:
- // make composible buy using templated constructor
- template<class T>
- base16_from_binary(BOOST_PFTO_WRAPPER(T) start) :
- super_t(
- Base(BOOST_MAKE_PFTO_WRAPPER(static_cast<T>(start))),
- detail::from_4_bit<CharType>()
- )
- {}
- // intel 7.1 doesn't like default copy constructor
- base16_from_binary(const base16_from_binary & rhs) :
- super_t(
- Base(rhs.base_reference()),
- detail::from_4_bit<CharType>()
- )
- {}
-// base16_from_binary(){};
-};
-
-} // namespace iterators
-} // namespace archive
-} // namespace boost
-
-#endif // BOOST_ARCHIVE_ITERATORS_BASE16_FROM_BINARY_HPP
diff --git a/src/lib/util/compat/base32hex.h b/src/lib/util/compat/base32hex.h
deleted file mode 100644
index d52679f..0000000
--- a/src/lib/util/compat/base32hex.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#ifndef __BASE32HEX_H
-#define __BASE32HEX_H 1
-
-#include <stdint.h>
-#include <string>
-#include <vector>
-
-//
-// Note: this helper module isn't specific to the DNS protocol per se.
-// We should probably move this to somewhere else, possibly in some common
-// utility area.
-//
-
-namespace isc {
-namespace util {
-namespace compat {
-
-/// \brief Encode binary data in the base32hex format.
-///
-/// The underlying implementation is shared with \c encodeBase64, and all
-/// description except the format (base32hex) equally applies.
-///
-/// Note: the encoding format is base32hex, not base32.
-///
-/// \param binary A vector object storing the data to be encoded.
-/// \return A newly created string that stores base32hex encoded value for
-/// binary.
-std::string encodeBase32Hex(const std::vector<uint8_t>& binary);
-
-/// \brief Decode a text encoded in the base32hex format into the
-/// original %data.
-///
-/// The underlying implementation is shared with \c decodeBase64, and all
-/// description except the format (base32hex) equally applies.
-///
-/// Note: the encoding format is base32hex, not base32.
-///
-/// \param input A text encoded in the base32hex format.
-/// \param result A vector in which the decoded %data is to be stored.
-void decodeBase32Hex(const std::string& input, std::vector<uint8_t>& result);
-
-} // namespace compat
-} // namespace util
-} // namespace isc
-
-#endif // __BASE32HEX_H
-
-// Local Variables:
-// mode: c++
-// End:
diff --git a/src/lib/util/compat/base32hex_from_binary.h b/src/lib/util/compat/base32hex_from_binary.h
deleted file mode 100644
index 5d16d04..0000000
--- a/src/lib/util/compat/base32hex_from_binary.h
+++ /dev/null
@@ -1,110 +0,0 @@
-#ifndef BOOST_ARCHIVE_ITERATORS_BASE32HEX_FROM_BINARY_HPP
-#define BOOST_ARCHIVE_ITERATORS_BASE32HEX_FROM_BINARY_HPP
-
-// MS compatible compilers support #pragma once
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
-// base32hex_from_binary.h (derived from boost base64_from_binary.hpp)
-
-// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
-// Use, modification and distribution is subject to the Boost Software
-// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#include <cassert>
-
-#include <cstddef> // size_t
-#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
-#if defined(BOOST_NO_STDC_NAMESPACE)
-namespace std{
- using ::size_t;
-} // namespace std
-#endif
-
-// We use the same boost header files used in "base64_from_". Since the
-// precise path to these headers may vary depending on the boost version we
-// simply include the base64 header here.
-#include <boost/archive/iterators/base64_from_binary.hpp>
-
-namespace boost {
-namespace archive {
-namespace iterators {
-
-/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
-// convert binary integers to base32hex characters
-
-namespace detail {
-
-template<class CharType>
-struct from_5_bit {
- typedef CharType result_type;
- CharType operator()(CharType t) const{
- const char * lookup_table =
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUV";
- assert(t < 32);
- return (lookup_table[static_cast<size_t>(t)]);
- }
-};
-
-} // namespace detail
-
-// note: what we would like to do is
-// template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type>
-// typedef transform_iterator<
-// from_5_bit<CharType>,
-// transform_width<Base, 5, sizeof(Base::value_type) * 8, CharType>
-// > base32hex_from_binary;
-// but C++ won't accept this. Rather than using a "type generator" and
-// using a different syntax, make a derivation which should be equivalent.
-//
-// Another issue addressed here is that the transform_iterator doesn't have
-// a templated constructor. This makes it incompatible with the dataflow
-// ideal. This is also addressed here.
-
-//template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type>
-template<
- class Base,
- class CharType = BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type
->
-class base32hex_from_binary :
- public transform_iterator<
- detail::from_5_bit<CharType>,
- Base
- >
-{
- friend class boost::iterator_core_access;
- typedef transform_iterator<
- BOOST_DEDUCED_TYPENAME detail::from_5_bit<CharType>,
- Base
- > super_t;
-
-public:
- // make composible buy using templated constructor
- template<class T>
- base32hex_from_binary(BOOST_PFTO_WRAPPER(T) start) :
- super_t(
- Base(BOOST_MAKE_PFTO_WRAPPER(static_cast<T>(start))),
- detail::from_5_bit<CharType>()
- )
- {}
- // intel 7.1 doesn't like default copy constructor
- base32hex_from_binary(const base32hex_from_binary & rhs) :
- super_t(
- Base(rhs.base_reference()),
- detail::from_5_bit<CharType>()
- )
- {}
-// base32hex_from_binary(){};
-};
-
-} // namespace iterators
-} // namespace archive
-} // namespace boost
-
-#endif // BOOST_ARCHIVE_ITERATORS_BASE32HEX_FROM_BINARY_HPP
diff --git a/src/lib/util/compat/base64.h b/src/lib/util/compat/base64.h
deleted file mode 100644
index 112ad23..0000000
--- a/src/lib/util/compat/base64.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#ifndef __BASE64_H
-#define __BASE64_H 1
-
-#include <stdint.h>
-#include <string>
-#include <vector>
-
-//
-// Note: this helper module isn't specific to the DNS protocol per se.
-// We should probably move this to somewhere else, possibly in some common
-// utility area.
-//
-
-namespace isc {
-namespace util {
-namespace compat {
-
-/// \brief Encode binary data in the base64 format.
-///
-/// This function returns a new \c std::string object that stores a text
-/// encoded in the base64 format for the given \c binary %data.
-/// The resulting string will be a valid, canonical form of base64
-/// representation as specified in RFC4648.
-///
-/// If memory allocation for the returned string fails, a corresponding
-/// standard exception will be thrown. This function never throws exceptions
-/// otherwise.
-///
-/// \param binary A vector object storing the data to be encoded.
-/// \return A newly created string that stores base64 encoded value for binary.
-std::string encodeBase64(const std::vector<uint8_t>& binary);
-
-/// \brief Decode a text encoded in the base64 format into the original %data.
-///
-/// The \c input argument must be a valid string represented in the base64
-/// format as specified in RFC4648. Space characters (spaces, tabs, newlines)
-/// can be included in \c input and will be ignored. Without spaces, the
-/// length of string must be a multiple of 4 bytes with necessary paddings.
-/// Also it must be encoded using the canonical encoding (see RFC4648).
-/// If any of these conditions is not met, an exception of class
-/// \c isc::BadValue will be thrown.
-///
-/// If \c result doesn't have sufficient capacity to store all decoded %data
-/// and memory allocation fails, a corresponding standard exception will be
-/// thrown. If the caller knows the necessary length (which can in theory
-/// be calculated from the input string), this situation can be avoided by
-/// reserving sufficient space for \c result beforehand.
-///
-/// Any existing %data in \c result will be removed. This is the case in some
-/// of the cases where an exception is thrown; that is, this function only
-/// provides the basic exception guarantee.
-///
-/// \param input A text encoded in the base64 format.
-/// \param result A vector in which the decoded %data is to be stored.
-void decodeBase64(const std::string& input, std::vector<uint8_t>& result);
-
-} // namespace compat
-} // namespace util
-} // namespace isc
-
-#endif // __BASE64_H
-
-// Local Variables:
-// mode: c++
-// End:
diff --git a/src/lib/util/compat/base_n.cc b/src/lib/util/compat/base_n.cc
deleted file mode 100644
index e35c784..0000000
--- a/src/lib/util/compat/base_n.cc
+++ /dev/null
@@ -1,398 +0,0 @@
-// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#include <stdint.h>
-#include <cassert>
-#include <iterator>
-#include <string>
-#include <vector>
-
-#include <boost/archive/iterators/base64_from_binary.hpp>
-#include <boost/archive/iterators/binary_from_base64.hpp>
-#include <boost/archive/iterators/transform_width.hpp>
-#include <boost/math/common_factor.hpp>
-
-#include <util/compat/base32hex_from_binary.h>
-#include <util/compat/binary_from_base32hex.h>
-#include <util/compat/base16_from_binary.h>
-#include <util/compat/binary_from_base16.h>
-#include <util/compat/base32hex.h>
-#include <util/compat/base64.h>
-
-#include <exceptions/exceptions.h>
-
-using namespace std;
-using namespace boost::archive::iterators;
-
-namespace isc {
-namespace util {
-namespace compat {
-
-// In the following anonymous namespace, we provide a generic framework
-// to encode/decode baseN format. We use the following tools:
-// - boost base64_from_binary/binary_from_base64: provide mapping table for
-// base64.
-// These classes take another iterator (Base) as a template argument, and
-// their dereference operator (operator*()) first retrieves an input value
-// from Base via Base::operator* and converts the value using their mapping
-// table. The converted value is returned as their own operator*.
-// - base{32hex,16}_from_binary/binary_from_base{32hex,16}: provide mapping
-// table for base32hex and base16. A straightforward variation of their
-// base64 counterparts.
-// - EncodeNormalizer/DecodeNormalizer: supplemental filter handling baseN
-// padding characters (=)
-// - boost transform_width: an iterator framework for handling data stream
-// per bit-group. It takes another iterator (Base) and output/input bit
-// numbers (BitsOut/BitsIn) template arguments. A transform_width object
-// internally maintains a bit stream, which can be retrieved per BitsOut
-// bits via its dereference operator (operator*()). It builds the stream
-// by internally iterating over the Base object via Base::operator++ and
-// Base::operator*, using the least BitsIn bits of the result of
-// Base::operator*. In our usage BitsIn for encoding and BitsOut for
-// decoding are always 8 (# of bits for one byte).
-//
-// Its dereference operator
-// retrieves BitsIn bits from the result of "*Base" (if necessary it
-// internally calls ++Base)
-//
-// A conceptual description of how the encoding and decoding work is as
-// follows:
-// Encoding:
-// input binary data => Normalizer (append sufficient number of 0 bits)
-// => transform_width (extract bit groups from the original
-// stream)
-// => baseXX_from_binary (convert each bit group to an
-// encoded byte using the mapping)
-// Decoding:
-// input baseXX text => Normalizer (convert '='s to the encoded characters
-// corresponding to 0, e.g. 'A's in base64)
-// => binary_from_baseXX (convert each encoded byte into
-// the original group bit)
-// => transform_width (build original byte stream by
-// concatenating the decoded bit
-// stream)
-//
-// Below, we define a set of templated classes to handle different parameters
-// for different encoding algorithms.
-namespace {
-// Common constants used for all baseN encoding.
-const char BASE_PADDING_CHAR = '=';
-const uint8_t BINARY_ZERO_CODE = 0;
-
-// EncodeNormalizer is an input iterator intended to be used as a filter
-// between the binary stream and baseXX_from_binary translator (via
-// transform_width). An EncodeNormalizer object is configured with two
-// iterators (base and base_end), specifying the head and end of the input
-// stream. It internally iterators over the original stream, and return
-// each byte of the stream intact via its dereference operator until it
-// reaches the end of the stream. After that the EncodeNormalizer object
-// will return 0 no matter how many times it is subsequently incremented.
-// This is necessary because the input binary stream may not contain
-// sufficient bits for a full encoded text while baseXX_from_binary expects
-// a sufficient length of input.
-// Note: this class is intended to be used within this implementation file,
-// and assumes "base < base_end" on construction without validating the
-// arguments. The behavior is undefined if this assumption doesn't hold.
-class EncodeNormalizer : public iterator<input_iterator_tag, uint8_t> {
-public:
- EncodeNormalizer(const vector<uint8_t>::const_iterator& base,
- const vector<uint8_t>::const_iterator& base_end) :
- base_(base), base_end_(base_end), in_pad_(false)
- {}
- EncodeNormalizer& operator++() {
- if (!in_pad_) {
- ++base_;
- }
- if (base_ == base_end_) {
- in_pad_ = true;
- }
- return (*this);
- }
- const uint8_t& operator*() const {
- if (in_pad_) {
- return (BINARY_ZERO_CODE);
- } else {
- return (*base_);
- }
- }
- bool operator==(const EncodeNormalizer& other) const {
- return (base_ == other.base_);
- }
-private:
- vector<uint8_t>::const_iterator base_;
- const vector<uint8_t>::const_iterator base_end_;
- bool in_pad_;
-};
-
-// DecodeNormalizer is an input iterator intended to be used as a filter
-// between the encoded baseX stream and binary_from_baseXX.
-// A DecodeNormalizer object is configured with three string iterators
-// (base, base_beinpad, and base_beginpad), specifying the head of the string,
-// the beginning position of baseX padding (when there's padding), and
-// end of the string, respectively. It internally iterators over the original
-// stream, and return each character of the encoded string via its dereference
-// operator until it reaches base_beginpad. After that the DecodeNormalizer
-// will return the encoding character corresponding to the all-0 value
-// (which is specified on construction via base_zero_code. see also
-// BaseZeroCode below). This translation is necessary because
-// binary_from_baseXX doesn't accept the padding character (i.e. '=').
-// Note: this class is intended to be used within this implementation file,
-// and for simplicity assumes "base < base_beginpad <= base_end" on
-// construction without validating the arguments. The behavior is undefined
-// if this assumption doesn't hold.
-class DecodeNormalizer : public iterator<input_iterator_tag, char> {
-public:
- DecodeNormalizer(const char base_zero_code,
- const string::const_iterator& base,
- const string::const_iterator& base_beginpad,
- const string::const_iterator& base_end) :
- base_zero_code_(base_zero_code),
- base_(base), base_beginpad_(base_beginpad), base_end_(base_end),
- in_pad_(false)
- {}
- DecodeNormalizer& operator++() {
- ++base_;
- while (base_ != base_end_ && isspace(*base_)) {
- ++base_;
- }
- if (base_ == base_beginpad_) {
- in_pad_ = true;
- }
- return (*this);
- }
- const char& operator*() const {
- if (in_pad_ && *base_ == BASE_PADDING_CHAR) {
- return (base_zero_code_);
- } else {
- return (*base_);
- }
- }
- bool operator==(const DecodeNormalizer& other) const {
- return (base_ == other.base_);
- }
-private:
- const char base_zero_code_;
- string::const_iterator base_;
- const string::const_iterator base_beginpad_;
- const string::const_iterator base_end_;
- bool in_pad_;
-};
-
-// BitsPerChunk: number of bits to be converted using the baseN mapping table.
-// e.g. 6 for base64.
-// BaseZeroCode: the byte character that represents a value of 0 in
-// the corresponding encoding. e.g. 'A' for base64.
-// Encoder: baseX_from_binary<transform_width<EncodeNormalizer,
-// BitsPerChunk, 8> >
-// Decoder: transform_width<binary_from_baseX<DecodeNormalizer>,
-// 8, BitsPerChunk>
-template <int BitsPerChunk, char BaseZeroCode,
- typename Encoder, typename Decoder>
-struct BaseNTransformer {
- static string encode(const vector<uint8_t>& binary);
- static void decode(const char* algorithm,
- const string& base64, vector<uint8_t>& result);
-
- // BITS_PER_GROUP is the number of bits for the smallest possible (non
- // empty) bit string that can be converted to a valid baseN encoded text
- // without padding. It's the least common multiple of 8 and BitsPerChunk,
- // e.g. 24 for base64.
- static const int BITS_PER_GROUP =
- boost::math::static_lcm<BitsPerChunk, 8>::value;
-
- // MAX_PADDING_CHARS is the maximum number of padding characters
- // that can appear in a valid baseN encoded text.
- // It's group_len - chars_for_byte, where group_len is the number of
- // encoded characters to represent BITS_PER_GROUP bits, and
- // chars_for_byte is the number of encoded character that is needed to
- // represent a single byte, which is ceil(8 / BitsPerChunk).
- // For example, for base64 we need two encoded characters to represent a
- // byte, and each group consists of 4 encoded characters, so
- // MAX_PADDING_CHARS is 4 - 2 = 2.
- static const int MAX_PADDING_CHARS =
- BITS_PER_GROUP / BitsPerChunk -
- (8 / BitsPerChunk + ((8 % BitsPerChunk) == 0 ? 0 : 1));
-};
-
-template <int BitsPerChunk, char BaseZeroCode,
- typename Encoder, typename Decoder>
-string
-BaseNTransformer<BitsPerChunk, BaseZeroCode, Encoder, Decoder>::encode(
- const vector<uint8_t>& binary)
-{
- // calculate the resulting length.
- size_t bits = binary.size() * 8;
- if (bits % BITS_PER_GROUP > 0) {
- bits += (BITS_PER_GROUP - (bits % BITS_PER_GROUP));
- }
- const size_t len = bits / BitsPerChunk;
-
- string result;
- result.reserve(len);
- result.assign(Encoder(EncodeNormalizer(binary.begin(), binary.end())),
- Encoder(EncodeNormalizer(binary.end(), binary.end())));
- assert(len >= result.length());
- result.append(len - result.length(), BASE_PADDING_CHAR);
- return (result);
-}
-
-template <int BitsPerChunk, char BaseZeroCode,
- typename Encoder, typename Decoder>
-void
-BaseNTransformer<BitsPerChunk, BaseZeroCode, Encoder, Decoder>::decode(
- const char* const algorithm,
- const string& input,
- vector<uint8_t>& result)
-{
- // enumerate the number of trailing padding characters (=), ignoring
- // white spaces. since baseN_from_binary doesn't accept padding,
- // we handle it explicitly.
- size_t padchars = 0;
- string::const_reverse_iterator srit = input.rbegin();
- string::const_reverse_iterator srit_end = input.rend();
- while (srit != srit_end) {
- char ch = *srit;
- if (ch == BASE_PADDING_CHAR) {
- if (++padchars > MAX_PADDING_CHARS) {
- isc_throw(BadValue, "Too many " << algorithm
- << " padding characters: " << input);
- }
- } else if (!isspace(ch)) {
- break;
- }
- ++srit;
- }
- // then calculate the number of padding bits corresponding to the padding
- // characters. In general, the padding bits consist of all-zero
- // trailing bits of the last encoded character followed by zero bits
- // represented by the padding characters:
- // 1st pad 2nd pad 3rd pad...
- // +++===== ======= ===... (+: from encoded chars, =: from pad chars)
- // 0000...0 0......0 000...
- // 0 7 8 15 16.... (bits)
- // The number of bits for the '==...' part is padchars * BitsPerChunk.
- // So the total number of padding bits is the smallest multiple of 8
- // that is >= padchars * BitsPerChunk.
- // (Below, note the common idiom of the bitwise AND with ~7. It clears the
- // lowest three bits, so has the effect of rounding the result down to the
- // nearest multiple of 8)
- const size_t padbits = (padchars * BitsPerChunk + 7) & ~7;
-
- // In some encoding algorithm, it could happen that a padding byte would
- // contain a full set of encoded bits, which is not allowed by definition
- // of padding. For example, if BitsPerChunk is 5, the following
- // representation could happen:
- // ++00000= (+: from encoded chars, 0: encoded char for '0', =: pad chars)
- // 0 7 (bits)
- // This must actually be encoded as follows:
- // ++======
- // 0 7 (bits)
- // The following check rejects this type of invalid encoding.
- if (padbits > BitsPerChunk * (padchars + 1)) {
- isc_throw(BadValue, "Invalid " << algorithm << "padding: " << input);
- }
-
- // convert the number of bits in bytes for convenience.
- const size_t padbytes = padbits / 8;
-
- try {
- result.assign(Decoder(DecodeNormalizer(BaseZeroCode, input.begin(),
- srit.base(), input.end())),
- Decoder(DecodeNormalizer(BaseZeroCode, input.end(),
- input.end(), input.end())));
- } catch (const dataflow_exception& ex) {
- // convert any boost exceptions into our local one.
- isc_throw(BadValue, ex.what());
- }
-
- // Confirm the original BaseX text is the canonical encoding of the
- // data, that is, that the first byte of padding is indeed 0.
- // (DecodeNormalizer and binary_from_baseXX ensure that the rest of the
- // padding is all zero).
- assert(result.size() >= padbytes);
- if (padbytes > 0 && *(result.end() - padbytes) != 0) {
- isc_throw(BadValue, "Non 0 bits included in " << algorithm
- << " padding: " << input);
- }
-
- // strip the padded zero-bit fields
- result.resize(result.size() - padbytes);
-}
-
-//
-// Instantiation for BASE-64
-//
-typedef
-base64_from_binary<transform_width<EncodeNormalizer, 6, 8> > base64_encoder;
-typedef
-transform_width<binary_from_base64<DecodeNormalizer>, 8, 6> base64_decoder;
-typedef BaseNTransformer<6, 'A', base64_encoder, base64_decoder>
-Base64Transformer;
-
-//
-// Instantiation for BASE-32HEX
-//
-typedef
-base32hex_from_binary<transform_width<EncodeNormalizer, 5, 8> >
-base32hex_encoder;
-typedef
-transform_width<binary_from_base32hex<DecodeNormalizer>, 8, 5>
-base32hex_decoder;
-typedef BaseNTransformer<5, '0', base32hex_encoder, base32hex_decoder>
-Base32HexTransformer;
-
-//
-// Instantiation for BASE-16 (HEX)
-//
-typedef
-base16_from_binary<transform_width<EncodeNormalizer, 4, 8> > base16_encoder;
-typedef
-transform_width<binary_from_base16<DecodeNormalizer>, 8, 4> base16_decoder;
-typedef BaseNTransformer<4, '0', base16_encoder, base16_decoder>
-Base16Transformer;
-}
-
-string
-encodeBase64(const vector<uint8_t>& binary) {
- return (Base64Transformer::encode(binary));
-}
-
-void
-decodeBase64(const string& input, vector<uint8_t>& result) {
- Base64Transformer::decode("base64", input, result);
-}
-
-string
-encodeBase32Hex(const vector<uint8_t>& binary) {
- return (Base32HexTransformer::encode(binary));
-}
-
-void
-decodeBase32Hex(const string& input, vector<uint8_t>& result) {
- Base32HexTransformer::decode("base32hex", input, result);
-}
-
-string
-encodeHex(const vector<uint8_t>& binary) {
- return (Base16Transformer::encode(binary));
-}
-
-void
-decodeHex(const string& input, vector<uint8_t>& result) {
- Base16Transformer::decode("base16", input, result);
-}
-
-} // namespace compat
-} // namespace util
-} // namespace isc
diff --git a/src/lib/util/compat/binary_from_base16.h b/src/lib/util/compat/binary_from_base16.h
deleted file mode 100644
index 50342f1..0000000
--- a/src/lib/util/compat/binary_from_base16.h
+++ /dev/null
@@ -1,120 +0,0 @@
-#ifndef BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE16_HPP
-#define BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE16_HPP
-
-// MS compatible compilers support #pragma once
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
-// binary_from_base16.h (derived from boost binary_from_base64.hpp)
-
-// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
-// Use, modification and distribution is subject to the Boost Software
-// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#include <cassert>
-
-// See binary_from_base32hex.h for why we need _from_base64.hpp here.
-#include <boost/archive/iterators/binary_from_base64.hpp>
-
-#include <exceptions/exceptions.h>
-
-namespace boost {
-namespace archive {
-namespace iterators {
-
-/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
-// convert base16 characters to binary data
-
-namespace detail {
-
-template<class CharType>
-struct to_4_bit {
- typedef CharType result_type;
- CharType operator()(CharType t) const{
- const char lookup_table[] = {
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 00-0f
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 10-1f
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 20-2f
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1, // 30-3f
- -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 40-4f
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 50-5f
- -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1 // 60-6f
- };
- // metrowerks trips this assertion - how come?
- #if ! defined(__MWERKS__)
- BOOST_STATIC_ASSERT(0x70 == sizeof(lookup_table));
- #endif
- signed char value = -1;
- if((unsigned)t < sizeof(lookup_table))
- value = lookup_table[(unsigned)t];
- if(-1 == value) {
- isc_throw(isc::BadValue,
- "attempt to decode a value not in base16 char set");
- }
- return (value);
- }
-};
-
-} // namespace detail
-
-// note: what we would like to do is
-// template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type>
-// typedef transform_iterator<
-// from_4_bit<CharType>,
-// transform_width<Base, 4, sizeof(Base::value_type) * 8, CharType>
-// > base16_from_binary;
-// but C++ won't accept this. Rather than using a "type generator" and
-// using a different syntax, make a derivation which should be equivalent.
-//
-// Another issue addressed here is that the transform_iterator doesn't have
-// a templated constructor. This makes it incompatible with the dataflow
-// ideal. This is also addressed here.
-
-template<
- class Base,
- class CharType = BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type
->
-class binary_from_base16 : public
- transform_iterator<
- detail::to_4_bit<CharType>,
- Base
- >
-{
- friend class boost::iterator_core_access;
- typedef transform_iterator<
- detail::to_4_bit<CharType>,
- Base
- > super_t;
-public:
- // make composible buy using templated constructor
- template<class T>
- binary_from_base16(BOOST_PFTO_WRAPPER(T) start) :
- super_t(
- Base(BOOST_MAKE_PFTO_WRAPPER(static_cast<T>(start))),
- detail::to_4_bit<CharType>()
- )
- {}
- // intel 7.1 doesn't like default copy constructor
- binary_from_base16(const binary_from_base16 & rhs) :
- super_t(
- Base(rhs.base_reference()),
- detail::to_4_bit<CharType>()
- )
- {}
-// binary_from_base16(){};
-};
-
-} // namespace iterators
-} // namespace archive
-} // namespace boost
-
-#endif // BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE16_HPP
-
-// Local Variables:
-// mode: c++
-// End:
diff --git a/src/lib/util/compat/binary_from_base32hex.h b/src/lib/util/compat/binary_from_base32hex.h
deleted file mode 100644
index 1d83f54..0000000
--- a/src/lib/util/compat/binary_from_base32hex.h
+++ /dev/null
@@ -1,123 +0,0 @@
-#ifndef BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE32HEX_HPP
-#define BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE32HEX_HPP
-
-// MS compatible compilers support #pragma once
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
-// binary_from_base32hex.h (derived from boost binary_from_base64.hpp)
-
-// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
-// Use, modification and distribution is subject to the Boost Software
-// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#include <cassert>
-
-// We use the same boost header files used in "_from_base64". Since the
-// precise path to these headers may vary depending on the boost version we
-// simply include the base64 header here.
-#include <boost/archive/iterators/binary_from_base64.hpp>
-
-#include <exceptions/exceptions.h>
-
-namespace boost {
-namespace archive {
-namespace iterators {
-
-/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
-// convert base32hex characters to binary data
-
-namespace detail {
-
-template<class CharType>
-struct to_5_bit {
- typedef CharType result_type;
- CharType operator()(CharType t) const{
- const char lookup_table[] = {
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 00-0f
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 10-1f
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 20-2f
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1, // 30-3f
- -1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, // 40-4f
- 25,26,27,28,29,30,31,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 50-5f
- -1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, // 60-6f
- 25,26,27,28,29,30,31,-1,-1,-1,-1,-1,-1,-1,-1,-1 // 70-7f
- };
- // metrowerks trips this assertion - how come?
- #if ! defined(__MWERKS__)
- BOOST_STATIC_ASSERT(0x80 == sizeof(lookup_table));
- #endif
- signed char value = -1;
- if((unsigned)t < sizeof(lookup_table))
- value = lookup_table[(unsigned)t];
- if(-1 == value) {
- isc_throw(isc::BadValue,
- "attempt to decode a value not in base32hex char set");
- }
- return (value);
- }
-};
-
-} // namespace detail
-
-// note: what we would like to do is
-// template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type>
-// typedef transform_iterator<
-// from_5_bit<CharType>,
-// transform_width<Base, 5, sizeof(Base::value_type) * 8, CharType>
-// > base32hex_from_binary;
-// but C++ won't accept this. Rather than using a "type generator" and
-// using a different syntax, make a derivation which should be equivalent.
-//
-// Another issue addressed here is that the transform_iterator doesn't have
-// a templated constructor. This makes it incompatible with the dataflow
-// ideal. This is also addressed here.
-
-template<
- class Base,
- class CharType = BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type
->
-class binary_from_base32hex : public
- transform_iterator<
- detail::to_5_bit<CharType>,
- Base
- >
-{
- friend class boost::iterator_core_access;
- typedef transform_iterator<
- detail::to_5_bit<CharType>,
- Base
- > super_t;
-public:
- // make composible buy using templated constructor
- template<class T>
- binary_from_base32hex(BOOST_PFTO_WRAPPER(T) start) :
- super_t(
- Base(BOOST_MAKE_PFTO_WRAPPER(static_cast<T>(start))),
- detail::to_5_bit<CharType>()
- )
- {}
- // intel 7.1 doesn't like default copy constructor
- binary_from_base32hex(const binary_from_base32hex & rhs) :
- super_t(
- Base(rhs.base_reference()),
- detail::to_5_bit<CharType>()
- )
- {}
-// binary_from_base32hex(){};
-};
-
-} // namespace iterators
-} // namespace archive
-} // namespace boost
-
-#endif // BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE32HEX_HPP
-
-// Local Variables:
-// mode: c++
-// End:
diff --git a/src/lib/util/compat/hex.h b/src/lib/util/compat/hex.h
deleted file mode 100644
index 57fc486..0000000
--- a/src/lib/util/compat/hex.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#ifndef __HEX_H
-#define __HEX_H 1
-
-#include <stdint.h>
-#include <string>
-#include <vector>
-
-//
-// Note: this helper module isn't specific to the DNS protocol per se.
-// We should probably move this to somewhere else, possibly in some common
-// utility area.
-//
-
-namespace isc {
-namespace util {
-namespace compat {
-/// \brief Encode binary data in the base16 ('hex') format.
-///
-/// The underlying implementation is shared with \c encodeBase64, and most of
-/// the description except the format (base16) equally applies.
-/// Another notable exception is that the base16 encoding doesn't require
-/// padding, so padding related considerations and the notion of canonical
-/// encoding don't apply.
-///
-/// \param binary A vector object storing the data to be encoded.
-/// \return A newly created string that stores base16 encoded value for
-/// binary.
-std::string encodeHex(const std::vector<uint8_t>& binary);
-
-/// \brief Decode a text encoded in the base16 ('hex') format into the
-/// original %data.
-///
-/// The underlying implementation is shared with \c decodeBase64, and most
-/// of the description except the format (base16) equally applies.
-/// Another notable exception is that the base16 encoding doesn't require
-/// padding, so padding related considerations and the notion of canonical
-/// encoding don't apply.
-///
-/// \param input A text encoded in the base16 format.
-/// \param result A vector in which the decoded %data is to be stored.
-void decodeHex(const std::string& input, std::vector<uint8_t>& result);
-
-} // namespace compat
-} // namespace util
-} // namespace isc
-
-#endif // __HEX_H
-
-// Local Variables:
-// mode: c++
-// End:
diff --git a/src/lib/util/compat/sha1.cc b/src/lib/util/compat/sha1.cc
deleted file mode 100644
index 519ce57..0000000
--- a/src/lib/util/compat/sha1.cc
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- * Description:
- * This file implements the Secure Hash Signature Standard
- * algorithms as defined in the National Institute of Standards
- * and Technology Federal Information Processing Standards
- * Publication (FIPS PUB) 180-1 published on April 17, 1995, 180-2
- * published on August 1, 2002, and the FIPS PUB 180-2 Change
- * Notice published on February 28, 2004.
- *
- * A combined document showing all algorithms is available at
- * http://csrc.nist.gov/publications/fips/
- * fips180-2/fips180-2withchangenotice.pdf
- *
- * The SHA-1 algorithm produces a 160-bit message digest for a
- * given data stream. It should take about 2**n steps to find a
- * message with the same digest as a given message and
- * 2**(n/2) to find any two messages with the same digest,
- * when n is the digest size in bits. Therefore, this
- * algorithm can serve as a means of providing a
- * "fingerprint" for a message.
- *
- * Portability Issues:
- * SHA-1 is defined in terms of 32-bit "words". This code
- * uses <stdint.h> (included via "sha.h") to define 32 and 8
- * bit unsigned integer types. If your C compiler does not
- * support 32 bit unsigned integers, this code is not
- * appropriate.
- *
- * Caveats:
- * SHA-1 is designed to work with messages less than 2^64 bits
- * long. This implementation uses SHA1Input() to hash the bits
- * that are a multiple of the size of an 8-bit character, and then
- * uses SHA1FinalBits() to hash the final few bits of the input.
- *
- * Authorship:
- * This file is adapted from RFC 4634, by D. Eastlake et al.
- * Copyright (C) The Internet Society (2006).
- *
- * Permission is granted for all uses, commercial and non-commercial,
- * of the sample code found in Section 8. Royalty free license to
- * use, copy, modify and distribute the software found in Section 8 is
- * granted, provided that this document is identified in all material
- * mentioning or referencing this software, and provided that
- * redistributed derivative works do not contain misleading author or
- * version information.
- *
- * The authors make no representations concerning either the
- * merchantability of this software or the suitability of this
- * software for any particular purpose. It is provided "as is"
- * without express or implied warranty of any kind.
- *
- */
-#include <util/compat/sha1.h>
-
-/* Local Function Prototyptes */
-static void SHA1Finalize(SHA1Context *, uint8_t Pad_Byte);
-static void SHA1PadMessage(SHA1Context *, uint8_t Pad_Byte);
-static void SHA1ProcessMessageBlock(SHA1Context *);
-
-/*
- * Define functions used by SHA1 hash
- */
-static inline uint32_t
-SHA_Ch(const uint32_t x, const uint32_t y, const uint32_t z) {
- return (((x) & ((y) ^ (z))) ^ (z));
-}
-
-static inline uint32_t
-SHA_Maj(const uint32_t x, const uint32_t y, const uint32_t z) {
- return (((x) & ((y) | (z))) | ((y) & (z)));
-}
-
-static inline uint32_t
-SHA_Parity(const uint32_t x, const uint32_t y, const uint32_t z) {
- return ((x) ^ (y) ^ (z));
-}
-
-static inline int
-SHA1CircularShift(uint8_t bits, uint32_t word) {
- return ((word << bits) | (word >> (32 - bits)));
-}
-
-static inline bool
-SHA1AddLength(SHA1Context *context, uint32_t length) {
- uint32_t addTemp = context->Length_Low;
- context->Length_Low += length;
- if (context->Length_Low < addTemp && ++context->Length_High == 0) {
- return (true);
- } else {
- return (false);
- }
-}
-
-/*
- * SHA1Reset
- *
- * Description:
- * This function will initialize the SHA1Context in preparation
- * for computing a new SHA1 message digest.
- *
- * Parameters:
- * context: [in/out]
- * The context to reset.
- *
- * Returns:
- * sha Error Code.
- *
- */
-int
-SHA1Reset(SHA1Context *context) {
- if (!context) {
- return (SHA_NULL);
- }
-
- context->Length_Low = 0;
- context->Length_High = 0;
- context->Message_Block_Index = 0;
-
- context->Intermediate_Hash[0] = 0x67452301;
- context->Intermediate_Hash[1] = 0xEFCDAB89;
- context->Intermediate_Hash[2] = 0x98BADCFE;
- context->Intermediate_Hash[3] = 0x10325476;
- context->Intermediate_Hash[4] = 0xC3D2E1F0;
-
- context->Computed = 0;
- context->Corrupted = 0;
- return (SHA_SUCCESS);
-}
-
-
-/*
- * SHA1Input
- *
- * Description:
- * This function accepts an array of octets as the next portion
- * of the message.
- *
- * Parameters:
- * context: [in/out]
- * The SHA context to update
- * message_array: [in]
- * An array of characters representing the next portion of
- * the message.
- * length: [in]
- * The length of the message in message_array
- *
- * Returns:
- * sha Error Code.
- *
- */
-int
-SHA1Input(SHA1Context *context, const uint8_t *message_array, unsigned length) {
- if (!length) {
- return (SHA_SUCCESS);
- }
-
- if (!context || !message_array) {
- return (SHA_NULL);
- }
-
- if (context->Computed) {
- context->Corrupted = SHA_STATEERROR;
- return (SHA_STATEERROR);
- }
-
- if (context->Corrupted) {
- return (context->Corrupted);
- }
-
- while(length-- && !context->Corrupted) {
- context->Message_Block[context->Message_Block_Index++] =
- (*message_array & 0xFF);
-
- if (!SHA1AddLength(context, 8) &&
- (context->Message_Block_Index == SHA1_BLOCKSIZE))
- {
- SHA1ProcessMessageBlock(context);
- }
-
- message_array++;
- }
-
- return (SHA_SUCCESS);
-}
-
-/*
- * SHA1FinalBits
- *
- * Description:
- * This function will add in any final bits of the message.
- *
- * Parameters:
- * context: [in/out]
- * The SHA context to update
- * message_bits: [in]
- * The final bits of the message, in the upper portion of the
- * byte. (Use 0b###00000 instead of 0b00000### to input the
- * three bits ###.)
- * length: [in]
- * The number of bits in message_bits, between 1 and 7.
- *
- * Returns:
- * sha Error Code.
- */
-int SHA1FinalBits(SHA1Context *context, const uint8_t message_bits,
- unsigned int length)
-{
- uint8_t masks[8] = {
- /* 0 0b00000000 */ 0x00,
- /* 1 0b10000000 */ 0x80,
- /* 2 0b11000000 */ 0xC0,
- /* 3 0b11100000 */ 0xE0,
- /* 4 0b11110000 */ 0xF0,
- /* 5 0b11111000 */ 0xF8,
- /* 6 0b11111100 */ 0xFC,
- /* 7 0b11111110 */ 0xFE
- };
- uint8_t markbit[8] = {
- /* 0 0b10000000 */ 0x80,
- /* 1 0b01000000 */ 0x40,
- /* 2 0b00100000 */ 0x20,
- /* 3 0b00010000 */ 0x10,
- /* 4 0b00001000 */ 0x08,
- /* 5 0b00000100 */ 0x04,
- /* 6 0b00000010 */ 0x02,
- /* 7 0b00000001 */ 0x01
- };
-
- if (!length) {
- return (SHA_SUCCESS);
- }
-
- if (!context) {
- return (SHA_NULL);
- }
-
- if (context->Computed || (length >= 8) || (length == 0)) {
- context->Corrupted = SHA_STATEERROR;
- return (SHA_STATEERROR);
- }
-
- if (context->Corrupted) {
- return (context->Corrupted);
- }
-
- SHA1AddLength(context, length);
- SHA1Finalize(context,
- (uint8_t) ((message_bits & masks[length]) | markbit[length]));
-
- return (SHA_SUCCESS);
-}
-
-/*
- * SHA1Result
- *
- * Description:
- * This function will return the 160-bit message digest into the
- * Message_Digest array provided by the caller.
- * NOTE: The first octet of hash is stored in the 0th element,
- * the last octet of hash in the 19th element.
- *
- * Parameters:
- * context: [in/out]
- * The context to use to calculate the SHA-1 hash.
- * Message_Digest: [out]
- * Where the digest is returned.
- *
- * Returns:
- * sha Error Code.
- *
- */
-int
-SHA1Result(SHA1Context *context, uint8_t Message_Digest[SHA1_HASHSIZE]) {
- int i;
-
- if (!context || !Message_Digest) {
- return (SHA_NULL);
- }
-
- if (context->Corrupted) {
- return (context->Corrupted);
- }
-
- if (!context->Computed) {
- SHA1Finalize(context, 0x80);
- }
-
- for(i = 0; i < SHA1_HASHSIZE; ++i) {
- Message_Digest[i] = context->Intermediate_Hash[i>>2]
- >> 8 * (3 - (i & 0x03));
- }
-
- return (SHA_SUCCESS);
-}
-
-/*
- * SHA1Finalize
- *
- * Description:
- * This helper function finishes off the digest calculations.
- *
- * Parameters:
- * context: [in/out]
- * The SHA context to update
- * Pad_Byte: [in]
- * The last byte to add to the digest before the 0-padding
- * and length. This will contain the last bits of the message
- * followed by another single bit. If the message was an
- * exact multiple of 8-bits long, Pad_Byte will be 0x80.
- *
- * Returns:
- * sha Error Code.
- *
- */
-static void SHA1Finalize(SHA1Context *context, uint8_t Pad_Byte) {
- int i;
- SHA1PadMessage(context, Pad_Byte);
- /* message may be sensitive, clear it out */
- for (i = 0; i < SHA1_BLOCKSIZE; ++i)
- context->Message_Block[i] = 0;
- context->Length_Low = 0; /* and clear length */
- context->Length_High = 0;
- context->Computed = 1;
-}
-
-/*
- * SHA1PadMessage
- *
- * Description:
- * According to the standard, the message must be padded to an even
- * 512 bits. The first padding bit must be a '1'. The last 64
- * bits represent the length of the original message. All bits in
- * between should be 0. This function will pad the message
- * according to those rules by filling the Message_Block array
- * accordingly. It will also call the ProcessMessageBlock function
- * provided appropriately. When it returns, it can be assumed that
- * the message digest has been computed.
- *
- * Parameters:
- * context: [in/out]
- * The context to pad
- * Pad_Byte: [in]
- * The last byte to add to the digest before the 0-padding
- * and length. This will contain the last bits of the message
- * followed by another single bit. If the message was an
- * exact multiple of 8-bits long, Pad_Byte will be 0x80.
- *
- * Returns:
- * Nothing.
- *
- */
-static void SHA1PadMessage(SHA1Context *context, uint8_t Pad_Byte) {
- /*
- * Check to see if the current message block is too small to hold
- * the initial padding bits and length. If so, we will pad the
- * block, process it, and then continue padding into a second
- * block.
- */
- if (context->Message_Block_Index >= (SHA1_BLOCKSIZE - 8)) {
- context->Message_Block[context->Message_Block_Index++] = Pad_Byte;
- while (context->Message_Block_Index < SHA1_BLOCKSIZE) {
- context->Message_Block[context->Message_Block_Index++] = 0;
- }
-
- SHA1ProcessMessageBlock(context);
- } else
- context->Message_Block[context->Message_Block_Index++] = Pad_Byte;
-
- while (context->Message_Block_Index < (SHA1_BLOCKSIZE - 8))
- context->Message_Block[context->Message_Block_Index++] = 0;
-
- /*
- * Store the message length as the last 8 octets
- */
- context->Message_Block[56] = (uint8_t) (context->Length_High >> 24);
- context->Message_Block[57] = (uint8_t) (context->Length_High >> 16);
- context->Message_Block[58] = (uint8_t) (context->Length_High >> 8);
- context->Message_Block[59] = (uint8_t) (context->Length_High);
- context->Message_Block[60] = (uint8_t) (context->Length_Low >> 24);
- context->Message_Block[61] = (uint8_t) (context->Length_Low >> 16);
- context->Message_Block[62] = (uint8_t) (context->Length_Low >> 8);
- context->Message_Block[63] = (uint8_t) (context->Length_Low);
-
- SHA1ProcessMessageBlock(context);
-}
-
-/*
- * SHA1ProcessMessageBlock
- *
- * Description:
- * This helper function will process the next 512 bits of the
- * message stored in the Message_Block array.
- *
- * Parameters:
- * None.
- *
- * Returns:
- * Nothing.
- *
- * Comments:
- * Many of the variable names in this code, especially the
- * single character names, were used because those were the
- * names used in the publication.
- *
- *
- */
-static void
-SHA1ProcessMessageBlock(SHA1Context *context) {
- /* Constants defined in FIPS-180-2, section 4.2.1 */
- const uint32_t K[] = {
- 0x5A827999,
- 0x6ED9EBA1,
- 0x8F1BBCDC,
- 0xCA62C1D6
- };
- int t; /* Loop counter */
- uint32_t temp; /* Temporary word value */
- uint32_t W[80]; /* Word sequence */
- uint32_t A, B, C, D, E; /* Word buffers */
-
- /*
- * Initialize the first 16 words in the array W
- */
- for (t = 0; t < 16; t++) {
- W[t] = ((uint32_t)context->Message_Block[t * 4]) << 24;
- W[t] |= ((uint32_t)context->Message_Block[t * 4 + 1]) << 16;
- W[t] |= ((uint32_t)context->Message_Block[t * 4 + 2]) << 8;
- W[t] |= ((uint32_t)context->Message_Block[t * 4 + 3]);
- }
-
- for (t = 16; t < 80; t++) {
- W[t] = SHA1CircularShift(1, W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
- }
-
- A = context->Intermediate_Hash[0];
- B = context->Intermediate_Hash[1];
- C = context->Intermediate_Hash[2];
- D = context->Intermediate_Hash[3];
- E = context->Intermediate_Hash[4];
-
- for (t = 0; t < 20; t++) {
- temp = SHA1CircularShift(5,A) + SHA_Ch(B, C, D) + E + W[t] + K[0];
- E = D;
- D = C;
- C = SHA1CircularShift(30,B);
- B = A;
- A = temp;
- }
-
- for (t = 20; t < 40; t++) {
- temp = SHA1CircularShift(5,A) + SHA_Parity(B, C, D) + E + W[t] + K[1];
- E = D;
- D = C;
- C = SHA1CircularShift(30,B);
- B = A;
- A = temp;
- }
-
- for (t = 40; t < 60; t++) {
- temp = SHA1CircularShift(5,A) + SHA_Maj(B, C, D) + E + W[t] + K[2];
- E = D;
- D = C;
- C = SHA1CircularShift(30,B);
- B = A;
- A = temp;
- }
-
- for (t = 60; t < 80; t++) {
- temp = SHA1CircularShift(5,A) + SHA_Parity(B, C, D) + E + W[t] + K[3];
- E = D;
- D = C;
- C = SHA1CircularShift(30,B);
- B = A;
- A = temp;
- }
-
- context->Intermediate_Hash[0] += A;
- context->Intermediate_Hash[1] += B;
- context->Intermediate_Hash[2] += C;
- context->Intermediate_Hash[3] += D;
- context->Intermediate_Hash[4] += E;
-
- context->Message_Block_Index = 0;
-}
diff --git a/src/lib/util/compat/sha1.h b/src/lib/util/compat/sha1.h
deleted file mode 100644
index f0f45f3..0000000
--- a/src/lib/util/compat/sha1.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * sha1.h
- *
- * Description:
- * This is the header file for code which implements the Secure
- * Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
- * April 17, 1995.
- *
- * Many of the variable names in this code, especially the
- * single character names, were used because those were the names
- * used in the publication.
- *
- * Please read the file sha1.cc for more information.
- *
- * Authorship:
- * This file is adapted from RFC 4634, by D. Eastlake et al.
- * Copyright (C) The Internet Society (2006).
- *
- * Permission is granted for all uses, commercial and non-commercial,
- * of the sample code found in Section 8. Royalty free license to
- * use, copy, modify and distribute the software found in Section 8 is
- * granted, provided that this document is identified in all material
- * mentioning or referencing this software, and provided that
- * redistributed derivative works do not contain misleading author or
- * version information.
- *
- * The authors make no representations concerning either the
- * merchantability of this software or the suitability of this
- * software for any particular purpose. It is provided "as is"
- * without express or implied warranty of any kind.
- */
-
-#ifndef _SHA1_H_
-#define _SHA1_H_
-
-#include <stdint.h>
-/*
- * If you do not have the ISO standard stdint.h header file, then you
- * must typdef the following:
- * name meaning
- * uint32_t unsigned 32 bit integer
- * uint8_t unsigned 8 bit integer (i.e., unsigned char)
- * int_least16_t integer of >= 16 bits
- *
- */
-
-enum {
- SHA_SUCCESS = 0,
- SHA_NULL, /* Null pointer parameter */
- SHA_STATEERROR /* called Input after Result */
-};
-
-enum {
- SHA1_HASHSIZE = 20,
- SHA1_HASHBITS = 20,
- SHA1_BLOCKSIZE = 64
-};
-
-/*
- * This structure will hold context information for the SHA-1
- * hashing operation
- */
-typedef struct SHA1Context
-{
- uint32_t Intermediate_Hash[SHA1_HASHSIZE/4]; /* Message Digest */
- uint32_t Length_Low; /* Message length in bits */
- uint32_t Length_High; /* Message length in bits */
- int_least16_t Message_Block_Index; /* Index into message block array */
- uint8_t Message_Block[64]; /* 512-bit message blocks */
- int Computed; /* Is the digest computed? */
- int Corrupted; /* Is the message digest corrupted? */
-} SHA1Context;
-
-/*
- * Function Prototypes
- */
-extern int SHA1Reset(SHA1Context *);
-extern int SHA1Input(SHA1Context *, const uint8_t *bytes,
- unsigned int bytecount);
-extern int SHA1FinalBits(SHA1Context *, const uint8_t bits,
- unsigned int bitcount);
-extern int SHA1Result(SHA1Context *, uint8_t Message_Digest[SHA1_HASHSIZE]);
-
-#endif
diff --git a/src/lib/util/compat/time_utilities.cc b/src/lib/util/compat/time_utilities.cc
deleted file mode 100644
index 35e7526..0000000
--- a/src/lib/util/compat/time_utilities.cc
+++ /dev/null
@@ -1,212 +0,0 @@
-// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#include <stdint.h>
-
-#include <sys/time.h>
-
-#include <string>
-#include <iomanip>
-#include <iostream>
-#include <sstream>
-
-#include <stdio.h>
-#include <time.h>
-
-#include <exceptions/exceptions.h>
-
-#include <util/compat/time_utilities.h>
-
-using namespace std;
-
-namespace {
-int days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
-
-inline bool
-isLeap(const int y) {
- return ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0);
-}
-
-unsigned int
-yearSecs(const int year) {
- return ((isLeap(year) ? 366 : 365 ) * 86400);
-}
-
-unsigned int
-monthSecs(const int month, const int year) {
- return ((days[month] + ((month == 1 && isLeap(year)) ? 1 : 0 )) * 86400);
-}
-}
-
-namespace isc {
-namespace util {
-namespace compat {
-
-string
-timeToText64(uint64_t value) {
- struct tm tm;
- unsigned int secs;
-
- // We cannot rely on gmtime() because time_t may not be of 64 bit
- // integer. The following conversion logic is borrowed from BIND 9.
- tm.tm_year = 70;
- while ((secs = yearSecs(tm.tm_year + 1900)) <= value) {
- value -= secs;
- ++tm.tm_year;
- if (tm.tm_year + 1900 > 9999) {
- isc_throw(InvalidTime,
- "Time value out of range (year > 9999): " <<
- tm.tm_year + 1900);
- }
- }
- tm.tm_mon = 0;
- while ((secs = monthSecs(tm.tm_mon, tm.tm_year + 1900)) <= value) {
- value -= secs;
- tm.tm_mon++;
- }
- tm.tm_mday = 1;
- while (86400 <= value) {
- value -= 86400;
- ++tm.tm_mday;
- }
- tm.tm_hour = 0;
- while (3600 <= value) {
- value -= 3600;
- ++tm.tm_hour;
- }
- tm.tm_min = 0;
- while (60 <= value) {
- value -= 60;
- ++tm.tm_min;
- }
- tm.tm_sec = value; // now t < 60, so this substitution is safe.
-
- ostringstream oss;
- oss << setfill('0')
- << setw(4) << tm.tm_year + 1900
- << setw(2) << tm.tm_mon + 1
- << setw(2) << tm.tm_mday
- << setw(2) << tm.tm_hour
- << setw(2) << tm.tm_min
- << setw(2) << tm.tm_sec;
- return (oss.str());
-}
-
-// timeToText32() below uses the current system time. To test it with
-// unusual current time values we introduce the following function pointer;
-// when it's non NULL, we call it to get the (normally faked) current time.
-// Otherwise we use the standard gettimeofday(2). This hook is specifically
-// intended for testing purposes, so, even if it's visible outside of this
-// library, it's not even declared in a header file.
-namespace detail {
-int64_t (*gettimeFunction)() = NULL;
-}
-
-namespace {
-int64_t
-gettimeofdayWrapper() {
- using namespace detail;
- if (gettimeFunction != NULL) {
- return (gettimeFunction());
- }
-
- struct timeval now;
- gettimeofday(&now, NULL);
-
- return (static_cast<int64_t>(now.tv_sec));
-}
-}
-
-string
-timeToText32(const uint32_t value) {
- // We first adjust the time to the closest epoch based on the current time.
- // Note that the following variables must be signed in order to handle
- // time until year 2038 correctly.
- const int64_t start = gettimeofdayWrapper() - 0x7fffffff;
- int64_t base = 0;
- int64_t t;
- while ((t = (base + value)) < start) {
- base += 0x100000000LL;
- }
-
- // Then convert it to text.
- return (timeToText64(t));
-}
-
-namespace {
-const size_t DATE_LEN = 14; // YYYYMMDDHHmmSS
-
-inline void
-checkRange(const int min, const int max, const int value,
- const string& valname)
-{
- if ((value >= min) && (value <= max)) {
- return;
- }
- isc_throw(InvalidTime, "Invalid " << valname << "value: " << value);
-}
-}
-
-uint64_t
-timeFromText64(const string& time_txt) {
- // Confirm the source only consists digits. sscanf() allows some
- // minor exceptions.
- for (int i = 0; i < time_txt.length(); ++i) {
- if (!isdigit(time_txt.at(i))) {
- isc_throw(InvalidTime, "Couldn't convert non-numeric time value: "
- << time_txt);
- }
- }
-
- int year, month, day, hour, minute, second;
- if (time_txt.length() != DATE_LEN ||
- sscanf(time_txt.c_str(), "%4d%2d%2d%2d%2d%2d",
- &year, &month, &day, &hour, &minute, &second) != 6)
- {
- isc_throw(InvalidTime, "Couldn't convert time value: " << time_txt);
- }
-
- checkRange(1970, 9999, year, "year");
- checkRange(1, 12, month, "month");
- checkRange(1, days[month - 1] + ((month == 2 && isLeap(year)) ? 1 : 0),
- day, "day");
- checkRange(0, 23, hour, "hour");
- checkRange(0, 59, minute, "minute");
- checkRange(0, 60, second, "second"); // 60 == leap second.
-
- uint64_t timeval = second + (60 * minute) + (3600 * hour) +
- ((day - 1) * 86400);
- for (int m = 0; m < (month - 1); ++m) {
- timeval += days[m] * 86400;
- }
- if (isLeap(year) && month > 2) {
- timeval += 86400;
- }
- for (int y = 1970; y < year; ++y) {
- timeval += ((isLeap(y) ? 366 : 365 ) * 86400);
- }
-
- return (timeval);
-}
-
-uint32_t
-timeFromText32(const string& time_txt) {
- // The implicit conversion from uint64_t to uint32_t should just work here,
- // because we only need to drop higher 32 bits.
- return (timeFromText64(time_txt));
-}
-
-}
-}
-}
diff --git a/src/lib/util/compat/time_utilities.h b/src/lib/util/compat/time_utilities.h
deleted file mode 100644
index 64218a8..0000000
--- a/src/lib/util/compat/time_utilities.h
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#ifndef __TIME_UTILITIES_H
-#define __TIME_UTILITIES_H 1
-
-#include <sys/types.h>
-#include <stdint.h>
-
-#include <exceptions/exceptions.h>
-
-//
-// Note: this helper module isn't specific to the DNS protocol per se.
-// We should probably move this to somewhere else, possibly in some common
-// utility area.
-//
-
-namespace isc {
-namespace util {
-namespace compat {
-
-///
-/// \brief A standard DNS (or ISC) module exception that is thrown if
-/// a time conversion function encounters bad input
-///
-class InvalidTime : public Exception {
-public:
- InvalidTime(const char* file, size_t line, const char* what) :
- isc::Exception(file, line, what) {}
-};
-
-///
-/// \name DNSSEC time conversion functions.
-///
-/// These functions convert between times represented in seconds (in integer)
-/// since epoch and those in the textual form used in the RRSIG records.
-/// For integers we provide both 32-bit and 64-bit versions.
-/// The RRSIG expiration and inception fields are both 32-bit unsigned
-/// integers, so 32-bit versions would be more useful for protocol operations.
-/// However, with 32-bit integers we need to take into account wrap-around
-/// points and compare values using the serial number arithmetic as specified
-/// in RFC4034, which would be more error prone. We therefore provide 64-bit
-/// versions, too.
-///
-/// The timezone is always UTC for these functions.
-//@{
-/// Convert textual DNSSEC time to integer, 64-bit version.
-///
-/// The textual form must only consist of digits and be in the form of
-/// YYYYMMDDHHmmSS, where:
-/// - YYYY must be between 1970 and 9999
-/// - MM must be between 01 and 12
-/// - DD must be between 01 and 31 and must be a valid day for the month
-/// represented in 'MM'. For example, if MM is 04, DD cannot be 31.
-/// DD can be 29 when MM is 02 only when YYYY is a leap year.
-/// - HH must be between 00 and 23
-/// - mm must be between 00 and 59
-/// - SS must be between 00 and 60
-///
-/// For all fields the range includes the begin and end values. Note that
-/// 60 is allowed for 'SS', intending a leap second, although in real operation
-/// it's unlikely to be specified.
-///
-/// If the given text is valid, this function converts it to an unsigned
-/// 64-bit number of seconds since epoch (1 January 1970 00:00:00) and returns
-/// the converted value. 64 bits are sufficient to represent all possible
-/// values for the valid format uniquely, so there is no overflow.
-///
-/// \note RFC4034 also defines the textual form of an unsigned decimal integer
-/// for the corresponding time in seconds. This function doesn't support
-/// this form, and if given it throws an exception of class \c InvalidTime.
-///
-/// \exception InvalidTime The given textual representation is invalid.
-///
-/// \param time_txt Textual time in the form of YYYYMMDDHHmmSS
-/// \return Seconds since epoch corresponding to \c time_txt
-uint64_t
-timeFromText64(const std::string& time_txt);
-
-/// Convert textual DNSSEC time to integer, 32-bit version.
-///
-/// This version is the same as \c timeFromText64() except that the return
-/// value is wrapped around to an unsigned 32-bit integer, simply dropping
-/// the upper 32 bits.
-uint32_t
-timeFromText32(const std::string& time_txt);
-
-/// Convert integral DNSSEC time to textual form, 64-bit version.
-///
-/// This function takes an integer that would be seconds since epoch and
-/// converts it in the form of YYYYMMDDHHmmSS. For example, if \c value is
-/// 0, it returns "19700101000000". If the value corresponds to a point
-/// of time on and after year 10,000, which cannot be represented in the
-/// YYYY... form, an exception of class \c InvalidTime will be thrown.
-///
-/// \exception InvalidTime The given time specifies on or after year 10,000.
-/// \exception Other A standard exception, if resource allocation for the
-/// returned text fails.
-///
-/// \param value Seconds since epoch to be converted.
-/// \return Textual representation of \c value in the form of YYYYMMDDHHmmSS.
-std::string
-timeToText64(uint64_t value);
-
-/// Convert integral DNSSEC time to textual form, 32-bit version.
-///
-/// This version is the same as \c timeToText64(), but the time value
-/// is expected to be the lower 32 bits of the full 64-bit value.
-/// These two will be different on and after a certain point of time
-/// in year 2106, so this function internally resolves the ambiguity
-/// using the current system time at the time of function call;
-/// it first identifies the range of [N*2^32 - 2^31, N*2^32 + 2^31)
-/// that contains the current time, and interprets \c value in the context
-/// of that range. It then applies the same process as \c timeToText64().
-///
-/// There is one important exception in this processing, however.
-/// Until 19 Jan 2038 03:14:08 (2^31 seconds since epoch), this range
-/// would contain time before epoch. In order to ensure the returned
-/// value is also a valid input to \c timeFromText, this function uses
-/// a special range [0, 2^32) until that time. As a result, all upper
-/// half of the 32-bit values are treated as a future time. For example,
-/// 2^32-1 (the highest value in 32-bit unsigned integers) will be converted
-/// to "21060207062815", instead of "19691231235959".
-std::string
-timeToText32(const uint32_t value);
-
-//@}
-}
-}
-}
-
-#endif // __DNSSECTIME_H
-
-// Local Variables:
-// mode: c++
-// End:
diff --git a/src/lib/util/filename.cc b/src/lib/util/filename.cc
index e46ad6f..1f2e5db 100644
--- a/src/lib/util/filename.cc
+++ b/src/lib/util/filename.cc
@@ -90,9 +90,9 @@ Filename::expandWithDefault(const string& defname) const {
string def_extension("");
// Normalize the input string.
- string copy_defname = isc::strutil::trim(defname);
+ string copy_defname = isc::util::str::trim(defname);
#ifdef WIN32
- isc::strutil::normalizeSlash(copy_defname);
+ isc::util::str::normalizeSlash(copy_defname);
#endif
// Split into the components
@@ -116,9 +116,9 @@ Filename::useAsDefault(const string& name) const {
string name_extension("");
// Normalize the input string.
- string copy_name = isc::strutil::trim(name);
+ string copy_name = isc::util::str::trim(name);
#ifdef WIN32
- isc::strutil::normalizeSlash(copy_name);
+ isc::util::str::normalizeSlash(copy_name);
#endif
// Split into the components
diff --git a/src/lib/util/filename.h b/src/lib/util/filename.h
index e8fbf62..984ecb0 100644
--- a/src/lib/util/filename.h
+++ b/src/lib/util/filename.h
@@ -69,9 +69,9 @@ public:
///
/// \param name New name to replaced currently stored name
void setName(const std::string& name) {
- full_name_ = isc::strutil::trim(name);
+ full_name_ = isc::util::str::trim(name);
#ifdef WIN32
- isc::strutil::normalizeSlash(full_name_);
+ isc::util::str::normalizeSlash(full_name_);
#endif
split(full_name_, directory_, name_, extension_);
}
diff --git a/src/lib/util/io/buffer.h b/src/lib/util/io/buffer.h
deleted file mode 100644
index 41ac0ac..0000000
--- a/src/lib/util/io/buffer.h
+++ /dev/null
@@ -1,448 +0,0 @@
-// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#ifndef __BUFFER_H
-#define __BUFFER_H 1
-
-#include <vector>
-
-#include <string.h>
-
-#include <stdint.h>
-
-#include <exceptions/exceptions.h>
-
-#include <boost/shared_ptr.hpp>
-
-namespace isc {
-namespace util {
-namespace io {
-
-///
-/// \brief A standard DNS module exception that is thrown if an out-of-range
-/// buffer operation is being performed.
-///
-class InvalidBufferPosition : public Exception {
-public:
- InvalidBufferPosition(const char* file, size_t line, const char* what) :
- isc::Exception(file, line, what) {}
-};
-
-///\brief The \c InputBuffer class is a buffer abstraction for manipulating
-/// read-only data.
-///
-/// The main purpose of this class is to provide a safe placeholder for
-/// examining wire-format data received from a network.
-///
-/// 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 BIND10 DNS library. One common usage of this
-/// class for an application would therefore be something like this:
-///
-/// \code unsigned char buf[1024];
-/// struct sockaddr addr;
-/// socklen_t addrlen = sizeof(addr);
-/// int cc = recvfrom(s, buf, sizeof(buf), 0, &addr, &addrlen);
-/// InputBuffer buffer(buf, cc);
-/// // pass the buffer to a DNS message object to parse the message \endcode
-///
-/// Other BIND10 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.
-///
-/// 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 responsibility to ensure
-/// the data remains valid throughout the lifetime of the \c InputBuffer
-/// object. Likewise, this object generally assumes the data isn't modified
-/// throughout its lifetime; if the application modifies the data while this
-/// object retains a 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.
-///
-/// 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 DNS message can be
-/// as large as a few KB. Alternatively, we could allow the object to allocate
-/// memory internally and expose it to the application to store network data
-/// in it. This is also a bad design, however, in that we would effectively
-/// break the abstraction employed in the class, and do so by publishing
-/// "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.
-///
-/// 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 will take place from the
-/// head of the unread data. An object of this class internally holds (a
-/// notion of) where the next read operation should start. We call it the
-/// <em>read position</em> in this document.
-class InputBuffer {
-public:
- ///
- /// \name Constructors and Destructor
- //@{
- /// \brief Constructor from variable length of data.
- ///
- /// 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.
- /// \param len The length of the data in bytes.
- InputBuffer(const void* data, size_t len) :
- position_(0), data_(static_cast<const uint8_t*>(data)), len_(len) {}
- //@}
-
- ///
- /// \name Getter Methods
- //@{
- /// \brief Return the length of the data stored in the buffer.
- size_t getLength() const { return (len_); }
- /// \brief Return the current read position.
- size_t getPosition() const { return (position_); }
- //@}
-
- ///
- /// \name Setter Methods
- ///
- //@{
- /// \brief Set the read position of the buffer to the given value.
- ///
- /// The new position must be in the valid range of the buffer; otherwise
- /// an exception of class \c isc::dns::InvalidBufferPosition will be thrown.
- /// \param position The new position (offset from the beginning of the
- /// buffer).
- void setPosition(size_t position)
- {
- if (position > len_)
- isc_throw(InvalidBufferPosition, "position is too large");
- position_ = position;
- }
- //@}
-
- ///
- /// \name Methods for reading data from the buffer.
- //@{
- /// \brief Read an unsigned 8-bit integer from the buffer and return it.
- ///
- /// If the remaining length of the buffer is smaller than 8-bit, an
- /// exception of class \c isc::dns::InvalidBufferPosition will be thrown.
- uint8_t readUint8()
- {
- if (position_ + sizeof(uint8_t) > len_) {
- isc_throw(InvalidBufferPosition, "read beyond end of buffer");
- }
-
- return (data_[position_++]);
- }
- /// \brief Read an unsigned 16-bit integer in network byte order from the
- /// buffer, convert it to host byte order, and return it.
- ///
- /// If the remaining length of the buffer is smaller than 16-bit, an
- /// exception of class \c isc::dns::InvalidBufferPosition will be thrown.
- uint16_t readUint16()
- {
- uint16_t data;
- const uint8_t* cp;
-
- if (position_ + sizeof(data) > len_) {
- isc_throw(InvalidBufferPosition, "read beyond end of buffer");
- }
-
- cp = &data_[position_];
- data = ((unsigned int)(cp[0])) << 8;
- data |= ((unsigned int)(cp[1]));
- position_ += sizeof(data);
-
- return (data);
- }
- /// \brief Read an unsigned 32-bit integer in network byte order from the
- /// buffer, convert it to host byte order, and return it.
- ///
- /// If the remaining length of the buffer is smaller than 32-bit, an
- /// exception of class \c isc::dns::InvalidBufferPosition will be thrown.
- uint32_t readUint32()
- {
- uint32_t data;
- const uint8_t* cp;
-
- if (position_ + sizeof(data) > len_) {
- isc_throw(InvalidBufferPosition, "read beyond end of buffer");
- }
-
- cp = &data_[position_];
- data = ((unsigned int)(cp[0])) << 24;
- data |= ((unsigned int)(cp[1])) << 16;
- data |= ((unsigned int)(cp[2])) << 8;
- data |= ((unsigned int)(cp[3]));
- position_ += sizeof(data);
-
- return (data);
- }
- /// \brief Read data of the specified length from the buffer and copy it to
- /// the caller supplied buffer.
- ///
- /// 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::dns::InvalidBufferPosition will
- /// be thrown.
- void readData(void* data, size_t len)
- {
- if (position_ + len > len_) {
- isc_throw(InvalidBufferPosition, "read beyond end of buffer");
- }
-
- memcpy(data, &data_[position_], len);
- position_ += len;
- }
- //@}
-
-private:
- size_t position_;
-
- // XXX: The following must be private, but for a short term workaround with
- // Boost.Python binding, we changed it to protected. We should soon
- // revisit it.
-protected:
- const uint8_t* data_;
- size_t len_;
-};
-
-///
-///\brief The \c OutputBuffer class is a buffer abstraction for manipulating
-/// mutable data.
-///
-/// 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.
-///
-/// 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:
-///
-/// \code OutputBuffer buffer(4096); // give a sufficiently large initial size
-/// // pass the buffer to a DNS message object to construct a wire-format
-/// // DNS message.
-/// struct sockaddr to;
-/// sendto(s, buffer.getData(), buffer.getLength(), 0, &to, sizeof(to));
-/// \endcode
-///
-/// where the \c getData() 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 encapsulated "handle" of an object to its user.
-/// Unfortunately, there is no easy way to avoid this without involving
-/// expensive data copy if we want to use this object with a legacy API such as
-/// a BSD socket interface. And, indeed, this is one major purpose for this
-/// object. Applications should use this method only under 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.
-///
-/// 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 more memory and copying
-/// data. It is therefore recommended to construct the buffer object with a
-/// sufficiently large initial 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.
-///
-/// 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 operation will take place from
-/// the end of the buffer. Other methods to emulate "random access" are also
-/// provided (e.g., \c writeUint16At()). The normal write operations are
-/// normally exception-free as this class automatically extends the buffer
-/// when necessary. However, in extreme cases such as an attempt of 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.
-///
-/// 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
-/// a concrete derived class. That way we can provide flexibility for future
-/// extension such as more efficient 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
-/// 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 {
-public:
- ///
- /// \name Constructors and Destructor
- ///
- //@{
- /// \brief Constructor from the initial size of the buffer.
- ///
- /// \param len The initial length of the buffer in bytes.
- OutputBuffer(size_t len) { data_.reserve(len); }
- //@}
-
- ///
- /// \name Getter Methods
- ///
- //@{
- /// \brief Return the current capacity of the buffer.
- size_t getCapacity() const { return (data_.capacity()); }
- /// \brief Return a pointer to the head of the data stored in the buffer.
- ///
- /// The caller can assume that the subsequent \c getLength() bytes are
- /// identical to the stored data of the buffer.
- ///
- /// Note: The pointer returned by this method may be invalidated after a
- /// subsequent write operation.
- const void* getData() const { return (&data_[0]); }
- /// \brief Return the length of data written in the buffer.
- size_t getLength() const { return (data_.size()); }
- /// \brief Return the value of the buffer at the specified position.
- ///
- /// \c pos must specify the valid position of the buffer; otherwise an
- /// exception class of \c InvalidBufferPosition will be thrown.
- ///
- /// \param pos The position in the buffer to be returned.
- const uint8_t& operator[](size_t pos) const
- {
- if (pos >= data_.size()) {
- isc_throw(InvalidBufferPosition, "read at invalid position");
- }
- return (data_[pos]);
- }
- //@}
-
- ///
- /// \name Methods for writing data into the buffer.
- ///
- //@{
- /// \brief Insert a specified length of gap at the end of the buffer.
- ///
- /// 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 \ref writeUint16At().
- /// \param len The length of the gap to be inserted in bytes.
- void skip(size_t len) { data_.insert(data_.end(), len, 0); }
-
- /// \brief Trim the specified length of data from the end of the buffer.
- ///
- /// The specified length must not exceed the current data size of the
- /// buffer; otherwise an exception of class \c isc::OutOfRange will
- /// be thrown.
- ///
- /// \param len The length of data that should be trimmed.
- void trim(size_t len)
- {
- if (len > data_.size()) {
- isc_throw(OutOfRange, "trimming too large from output buffer");
- }
- data_.resize(data_.size() - len);
- }
- /// \brief Clear buffer content.
- ///
- /// This method can be used to re-initialize and reuse the buffer without
- /// constructing a new one.
- void clear() { data_.clear(); }
- /// \brief Write an unsigned 8-bit integer into the buffer.
- ///
- /// \param data The 8-bit integer to be written into the buffer.
- void writeUint8(uint8_t data) { data_.push_back(data); }
-
- /// \brief Write an unsigned 8-bit integer into the buffer.
- ///
- /// The position must be lower than the size of the buffer,
- /// otherwise an exception of class \c isc::dns::InvalidBufferPosition
- /// will be thrown.
- ///
- /// \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) {
- if (pos + sizeof(data) > data_.size()) {
- isc_throw(InvalidBufferPosition, "write at invalid position");
- }
- data_[pos] = data;
- }
-
- /// \brief Write an unsigned 16-bit integer in host byte order into the
- /// buffer in network byte order.
- ///
- /// \param data The 16-bit integer to be written into the buffer.
- void writeUint16(uint16_t data)
- {
- data_.push_back(static_cast<uint8_t>((data & 0xff00U) >> 8));
- data_.push_back(static_cast<uint8_t>(data & 0x00ffU));
- }
- /// \brief Write an unsigned 16-bit integer in host byte order at the
- /// specified position of the buffer in network byte order.
- ///
- /// 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::dns::InvalidBufferPosition will
- /// be thrown.
- /// 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) > data_.size()) {
- isc_throw(InvalidBufferPosition, "write at invalid position");
- }
-
- data_[pos] = static_cast<uint8_t>((data & 0xff00U) >> 8);
- data_[pos + 1] = static_cast<uint8_t>(data & 0x00ffU);
- }
- /// \brief Write an unsigned 32-bit integer in host byte order
- /// into the buffer in network byte order.
- ///
- /// \param data The 32-bit integer to be written into the buffer.
- void writeUint32(uint32_t data)
- {
- data_.push_back(static_cast<uint8_t>((data & 0xff000000) >> 24));
- data_.push_back(static_cast<uint8_t>((data & 0x00ff0000) >> 16));
- data_.push_back(static_cast<uint8_t>((data & 0x0000ff00) >> 8));
- data_.push_back(static_cast<uint8_t>(data & 0x000000ff));
- }
- /// \brief Copy an arbitrary length of data into the buffer.
- ///
- /// 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)
- {
- const uint8_t* cp = static_cast<const uint8_t*>(data);
- data_.insert(data_.end(), cp, cp + len);
- }
- //@}
-
-private:
- std::vector<uint8_t> data_;
-};
-
-/// \brief Pointer-like types pointing to \c InputBuffer or \c OutputBuffer
-///
-/// These types are expected to be used as an argument in asynchronous
-/// callback functions. The internal reference-counting will ensure that
-/// that ongoing state information will not be lost if the object
-/// that originated the asynchronous call falls out of scope.
-typedef boost::shared_ptr<InputBuffer> InputBufferPtr;
-typedef boost::shared_ptr<OutputBuffer> OutputBufferPtr;
-
-} // namespace io
-} // namespace util
-} // namespace isc
-#endif // __BUFFER_H
-
-// Local Variables:
-// mode: c++
-// End:
diff --git a/src/lib/util/io/io_utilities.h b/src/lib/util/io/io_utilities.h
deleted file mode 100644
index 40b200c..0000000
--- a/src/lib/util/io/io_utilities.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#ifndef __IO_UTILITIES_H
-#define __IO_UTILITIES_H
-
-#include <cstddef>
-
-namespace isc {
-namespace util {
-namespace io {
-
-/// \brief Read Unsigned 16-Bit Integer from Buffer
-///
-/// This is essentially a copy of the isc::util::InputBuffer::readUint16. It
-/// should really be moved into a separate library.
-///
-/// \param buffer Data buffer at least two bytes long of which the first two
-/// bytes are assumed to represent a 16-bit integer in network-byte
-/// order.
-///
-/// \return Value of 16-bit integer
-inline uint16_t
-readUint16(const void* buffer) {
- const uint8_t* byte_buffer = static_cast<const uint8_t*>(buffer);
-
- uint16_t result = (static_cast<uint16_t>(byte_buffer[0])) << 8;
- result |= static_cast<uint16_t>(byte_buffer[1]);
-
- return (result);
-}
-
-/// \brief Write Unisgned 16-Bit Integer to Buffer
-///
-/// This is essentially a copy of isc::util::OutputBuffer::writeUint16. It
-/// should really be moved into a separate library.
-///
-/// \param value 16-bit value to convert
-/// \param buffer Data buffer at least two bytes long into which the 16-bit
-/// value is written in network-byte order.
-
-inline void
-writeUint16(uint16_t value, void* buffer) {
- uint8_t* byte_buffer = static_cast<uint8_t*>(buffer);
-
- byte_buffer[0] = static_cast<uint8_t>((value & 0xff00U) >> 8);
- byte_buffer[1] = static_cast<uint8_t>(value & 0x00ffU);
-}
-
-} // namespace io
-} // namespace util
-} // namespace isc
-
-#endif // __ASIOLINK_UTILITIES_H
diff --git a/src/lib/util/io_utilities.h b/src/lib/util/io_utilities.h
new file mode 100644
index 0000000..ecab3ce
--- /dev/null
+++ b/src/lib/util/io_utilities.h
@@ -0,0 +1,63 @@
+// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __IO_UTILITIES_H
+#define __IO_UTILITIES_H
+
+#include <cstddef>
+
+namespace isc {
+namespace util {
+
+/// \brief Read Unsigned 16-Bit Integer from Buffer
+///
+/// This is essentially a copy of the isc::util::InputBuffer::readUint16. It
+/// should really be moved into a separate library.
+///
+/// \param buffer Data buffer at least two bytes long of which the first two
+/// bytes are assumed to represent a 16-bit integer in network-byte
+/// order.
+///
+/// \return Value of 16-bit integer
+inline uint16_t
+readUint16(const void* buffer) {
+ const uint8_t* byte_buffer = static_cast<const uint8_t*>(buffer);
+
+ uint16_t result = (static_cast<uint16_t>(byte_buffer[0])) << 8;
+ result |= static_cast<uint16_t>(byte_buffer[1]);
+
+ return (result);
+}
+
+/// \brief Write Unisgned 16-Bit Integer to Buffer
+///
+/// This is essentially a copy of isc::util::OutputBuffer::writeUint16. It
+/// should really be moved into a separate library.
+///
+/// \param value 16-bit value to convert
+/// \param buffer Data buffer at least two bytes long into which the 16-bit
+/// value is written in network-byte order.
+
+inline void
+writeUint16(uint16_t value, void* buffer) {
+ uint8_t* byte_buffer = static_cast<uint8_t*>(buffer);
+
+ byte_buffer[0] = static_cast<uint8_t>((value & 0xff00U) >> 8);
+ byte_buffer[1] = static_cast<uint8_t>(value & 0x00ffU);
+}
+
+} // namespace util
+} // namespace isc
+
+#endif // __ASIOLINK_UTILITIES_H
diff --git a/src/lib/util/locks.h b/src/lib/util/locks.h
index 98197c3..c9fc82d 100644
--- a/src/lib/util/locks.h
+++ b/src/lib/util/locks.h
@@ -38,6 +38,7 @@
#ifndef USE_BOOST_THREADS
namespace isc {
+namespace util {
namespace locks {
class mutex {
@@ -64,8 +65,9 @@ public:
void unlock() {}
};
-}
-}
+} // namespace locks
+} // namespace util
+} // namespace isc
#else // USE_BOOST_THREADS
@@ -88,6 +90,7 @@ public:
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
namespace isc {
+namespace util {
namespace locks {
typedef boost::mutex mutex;
@@ -107,8 +110,9 @@ public:
scoped_lock(T& mtype) : boost::interprocess::scoped_lock<T>(mtype) { }
};
-}
-}
+} // namespace locks
+} // namespace util
+} // namespace isc
#endif // USE_BOOST_THREADS
diff --git a/src/lib/util/lru_list.h b/src/lib/util/lru_list.h
index 19462d5..797c3c9 100644
--- a/src/lib/util/lru_list.h
+++ b/src/lib/util/lru_list.h
@@ -146,7 +146,7 @@ public:
}
private:
- isc::locks::mutex mutex_; ///< List protection
+ locks::mutex mutex_; ///< List protection
std::list<boost::shared_ptr<T> > lru_; ///< The LRU list itself
uint32_t max_size_; ///< Max size of the list
uint32_t count_; ///< Count of elements
@@ -158,7 +158,7 @@ template <typename T>
void LruList<T>::add(boost::shared_ptr<T>& element) {
// Protect list against concurrent access
- isc::locks::scoped_lock<isc::locks::mutex> lock(mutex_);
+ locks::scoped_lock<locks::mutex> lock(mutex_);
// Add the entry and set its pointer field to point into the list.
// insert() is used to get the pointer.
@@ -207,7 +207,7 @@ void LruList<T>::remove(boost::shared_ptr<T>& element) {
if (element->iteratorValid()) {
// Is valid, so protect list against concurrent access
- isc::locks::scoped_lock<isc::locks::mutex> lock(mutex_);
+ locks::scoped_lock<locks::mutex> lock(mutex_);
lru_.erase(element->getLruIterator()); // Remove element from list
element->invalidateIterator(); // Invalidate pointer
@@ -223,7 +223,7 @@ void LruList<T>::touch(boost::shared_ptr<T>& element) {
if (element->iteratorValid()) {
// Protect list against concurrent access
- isc::locks::scoped_lock<isc::locks::mutex> lock(mutex_);
+ locks::scoped_lock<locks::mutex> lock(mutex_);
// Move the element to the end of the list.
lru_.splice(lru_.end(), lru_, element->getLruIterator());
@@ -239,7 +239,7 @@ void LruList<T>::touch(boost::shared_ptr<T>& element) {
template <typename T>
void LruList<T>::clear() {
// Protect list against concurrent access
- isc::locks::scoped_lock<isc::locks::mutex> lock(mutex_);
+ locks::scoped_lock<locks::mutex> lock(mutex_);
// ... and update the count while we have the mutex.
count_ = 0;
diff --git a/src/lib/util/strutil.cc b/src/lib/util/strutil.cc
index 25e0fbe..161f9ac 100644
--- a/src/lib/util/strutil.cc
+++ b/src/lib/util/strutil.cc
@@ -20,7 +20,8 @@
using namespace std;
namespace isc {
-namespace strutil {
+namespace util {
+namespace str {
// Normalize slashes
@@ -131,5 +132,6 @@ format(const std::string& format, const std::vector<std::string>& args) {
return (result);
}
-} // namespace strutil
+} // namespace str
+} // namespace util
} // namespace isc
diff --git a/src/lib/util/strutil.h b/src/lib/util/strutil.h
index 087410f..e044c15 100644
--- a/src/lib/util/strutil.h
+++ b/src/lib/util/strutil.h
@@ -21,7 +21,8 @@
#include <vector>
namespace isc {
-namespace strutil {
+namespace util {
+namespace str {
/// \brief A Set of C++ Utilities for Manipulating Strings
@@ -97,7 +98,7 @@ inline char toUpper(char chr) {
/// \param text String to be upper-cased.
inline void uppercase(std::string& text) {
std::transform(text.begin(), text.end(), text.begin(),
- isc::strutil::toUpper);
+ isc::util::str::toUpper);
}
/// \brief Lowercase Character
@@ -121,7 +122,7 @@ inline char toLower(char chr) {
/// \param text String to be lower-cased.
inline void lowercase(std::string& text) {
std::transform(text.begin(), text.end(), text.begin(),
- isc::strutil::toLower);
+ isc::util::str::toLower);
}
@@ -139,7 +140,8 @@ std::string format(const std::string& format,
const std::vector<std::string>& args);
-} // namespace strutil
+} // namespace str
+} // namespace util
} // namespace isc
#endif // __STRUTIL_H
diff --git a/src/lib/util/tests/base32hex_unittest.cc b/src/lib/util/tests/base32hex_unittest.cc
index 80ab82c..8fa2c0b 100644
--- a/src/lib/util/tests/base32hex_unittest.cc
+++ b/src/lib/util/tests/base32hex_unittest.cc
@@ -21,13 +21,13 @@
#include <exceptions/exceptions.h>
-#include <util/compat/base32hex.h>
+#include <util/coder/base32hex.h>
#include <gtest/gtest.h>
using namespace std;
using namespace isc;
-using namespace isc::util::compat;
+using namespace isc::util::coder;
namespace {
diff --git a/src/lib/util/tests/base64_unittest.cc b/src/lib/util/tests/base64_unittest.cc
index 4aa095a..ad96e40 100644
--- a/src/lib/util/tests/base64_unittest.cc
+++ b/src/lib/util/tests/base64_unittest.cc
@@ -18,13 +18,13 @@
#include <exceptions/exceptions.h>
-#include <util/compat/base64.h>
+#include <util/coder/base64.h>
#include <gtest/gtest.h>
using namespace std;
using namespace isc;
-using namespace isc::util::compat;
+using namespace isc::util::coder;
namespace {
diff --git a/src/lib/util/tests/buffer_unittest.cc b/src/lib/util/tests/buffer_unittest.cc
index ba62e5c..7578370 100644
--- a/src/lib/util/tests/buffer_unittest.cc
+++ b/src/lib/util/tests/buffer_unittest.cc
@@ -14,7 +14,7 @@
#include <exceptions/exceptions.h>
-#include <util/io/buffer.h>
+#include <util/buffer.h>
#include <gtest/gtest.h>
@@ -22,8 +22,8 @@ using namespace isc;
namespace {
-using isc::util::io::InputBuffer;
-using isc::util::io::OutputBuffer;
+using isc::util::InputBuffer;
+using isc::util::OutputBuffer;
class BufferTest : public ::testing::Test {
protected:
@@ -64,20 +64,20 @@ TEST_F(BufferTest, inputBufferRead) {
}
TEST_F(BufferTest, inputBufferException) {
- EXPECT_THROW(ibuffer.setPosition(6), isc::util::io::InvalidBufferPosition);
+ EXPECT_THROW(ibuffer.setPosition(6), isc::util::InvalidBufferPosition);
ibuffer.setPosition(sizeof(testdata));
- EXPECT_THROW(ibuffer.readUint8(), isc::util::io::InvalidBufferPosition);
+ EXPECT_THROW(ibuffer.readUint8(), isc::util::InvalidBufferPosition);
ibuffer.setPosition(sizeof(testdata) - 1);
- EXPECT_THROW(ibuffer.readUint16(), isc::util::io::InvalidBufferPosition);
+ EXPECT_THROW(ibuffer.readUint16(), isc::util::InvalidBufferPosition);
ibuffer.setPosition(sizeof(testdata) - 3);
- EXPECT_THROW(ibuffer.readUint32(), isc::util::io::InvalidBufferPosition);
+ EXPECT_THROW(ibuffer.readUint32(), isc::util::InvalidBufferPosition);
ibuffer.setPosition(sizeof(testdata) - 4);
EXPECT_THROW(ibuffer.readData(vdata, sizeof(vdata)),
- isc::util::io::InvalidBufferPosition);
+ isc::util::InvalidBufferPosition);
}
TEST_F(BufferTest, outputBufferExtend) {
@@ -145,15 +145,15 @@ TEST_F(BufferTest, outputBufferWriteat) {
EXPECT_EQ(3, *(cp + 3));
EXPECT_THROW(obuffer.writeUint8At(data16, 5),
- isc::util::io::InvalidBufferPosition);
+ isc::util::InvalidBufferPosition);
EXPECT_THROW(obuffer.writeUint8At(data16, 4),
- isc::util::io::InvalidBufferPosition);
+ isc::util::InvalidBufferPosition);
EXPECT_THROW(obuffer.writeUint16At(data16, 3),
- isc::util::io::InvalidBufferPosition);
+ isc::util::InvalidBufferPosition);
EXPECT_THROW(obuffer.writeUint16At(data16, 4),
- isc::util::io::InvalidBufferPosition);
+ isc::util::InvalidBufferPosition);
EXPECT_THROW(obuffer.writeUint16At(data16, 5),
- isc::util::io::InvalidBufferPosition);
+ isc::util::InvalidBufferPosition);
}
TEST_F(BufferTest, outputBufferSkip) {
@@ -182,7 +182,7 @@ TEST_F(BufferTest, outputBufferReadat) {
for (int i = 0; i < sizeof(testdata); i ++) {
EXPECT_EQ(testdata[i], obuffer[i]);
}
- EXPECT_THROW(obuffer[sizeof(testdata)], isc::util::io::InvalidBufferPosition);
+ EXPECT_THROW(obuffer[sizeof(testdata)], isc::util::InvalidBufferPosition);
}
TEST_F(BufferTest, outputBufferClear) {
diff --git a/src/lib/util/tests/hex_unittest.cc b/src/lib/util/tests/hex_unittest.cc
index 82b5d5f..1845519 100644
--- a/src/lib/util/tests/hex_unittest.cc
+++ b/src/lib/util/tests/hex_unittest.cc
@@ -19,13 +19,13 @@
#include <exceptions/exceptions.h>
-#include <util/compat/hex.h>
+#include <util/coder/hex.h>
#include <gtest/gtest.h>
using namespace std;
using namespace isc;
-using namespace isc::util::compat;
+using namespace isc::util::coder;
namespace {
const string hex_txt("DEADBEEFDECADE");
diff --git a/src/lib/util/tests/io_utilities_unittest.cc b/src/lib/util/tests/io_utilities_unittest.cc
index ffe1274..4aad560 100644
--- a/src/lib/util/tests/io_utilities_unittest.cc
+++ b/src/lib/util/tests/io_utilities_unittest.cc
@@ -21,10 +21,10 @@
#include <gtest/gtest.h>
-#include <util/io/buffer.h>
-#include <util/io/io_utilities.h>
+#include <util/buffer.h>
+#include <util/io_utilities.h>
-using namespace isc::util::io;
+using namespace isc::util;
TEST(asioutil, readUint16) {
diff --git a/src/lib/util/tests/sha1_unittest.cc b/src/lib/util/tests/sha1_unittest.cc
index e546cb8..0c0d2be 100644
--- a/src/lib/util/tests/sha1_unittest.cc
+++ b/src/lib/util/tests/sha1_unittest.cc
@@ -15,7 +15,7 @@
#include <stdint.h>
#include <string>
-#include <util/compat/sha1.h>
+#include <util/coder/sha1.h>
#include <gtest/gtest.h>
@@ -24,7 +24,9 @@
//using isc::UnitTestUtil;
using namespace std;
-namespace {
+namespace isc {
+namespace util {
+namespace coder {
class Sha1Test : public ::testing::Test {
protected:
Sha1Test() {}
@@ -103,5 +105,8 @@ TEST_F(Sha1Test, Test4) {
EXPECT_EQ(digest[i], expected[i]);
}
}
-}
+
+} // namespace coder
+} // namespace util
+} // namespace isc
diff --git a/src/lib/util/tests/strutil_unittest.cc b/src/lib/util/tests/strutil_unittest.cc
index e1b751c..cd3a9ca 100644
--- a/src/lib/util/tests/strutil_unittest.cc
+++ b/src/lib/util/tests/strutil_unittest.cc
@@ -19,6 +19,7 @@
#include <util/strutil.h>
using namespace isc;
+using namespace isc::util;
using namespace std;
class StringUtilTest : public ::testing::Test {
@@ -34,15 +35,15 @@ protected:
TEST_F(StringUtilTest, Slash) {
string instring = "";
- isc::strutil::normalizeSlash(instring);
+ isc::util::str::normalizeSlash(instring);
EXPECT_EQ("", instring);
instring = "C:\\A\\B\\C.D";
- isc::strutil::normalizeSlash(instring);
+ isc::util::str::normalizeSlash(instring);
EXPECT_EQ("C:/A/B/C.D", instring);
instring = "// \\ //";
- isc::strutil::normalizeSlash(instring);
+ isc::util::str::normalizeSlash(instring);
EXPECT_EQ("// / //", instring);
}
@@ -51,19 +52,19 @@ TEST_F(StringUtilTest, Slash) {
TEST_F(StringUtilTest, Trim) {
// Empty and full string.
- EXPECT_EQ("", isc::strutil::trim(""));
- EXPECT_EQ("abcxyz", isc::strutil::trim("abcxyz"));
+ EXPECT_EQ("", isc::util::str::trim(""));
+ EXPECT_EQ("abcxyz", isc::util::str::trim("abcxyz"));
// Trim right-most blanks
- EXPECT_EQ("ABC", isc::strutil::trim("ABC "));
- EXPECT_EQ("ABC", isc::strutil::trim("ABC\t\t \n\t"));
+ EXPECT_EQ("ABC", isc::util::str::trim("ABC "));
+ EXPECT_EQ("ABC", isc::util::str::trim("ABC\t\t \n\t"));
// Left-most blank trimming
- EXPECT_EQ("XYZ", isc::strutil::trim(" XYZ"));
- EXPECT_EQ("XYZ", isc::strutil::trim("\t\t \tXYZ"));
+ EXPECT_EQ("XYZ", isc::util::str::trim(" XYZ"));
+ EXPECT_EQ("XYZ", isc::util::str::trim("\t\t \tXYZ"));
// Right and left, with embedded spaces
- EXPECT_EQ("MN \t OP", isc::strutil::trim("\t\tMN \t OP \t"));
+ EXPECT_EQ("MN \t OP", isc::util::str::trim("\t\tMN \t OP \t"));
}
// Check tokenization. Note that ASSERT_EQ is used to check the size of the
@@ -76,49 +77,49 @@ TEST_F(StringUtilTest, Tokens) {
// Default delimiters
// Degenerate cases
- result = isc::strutil::tokens(""); // Empty string
+ result = isc::util::str::tokens(""); // Empty string
EXPECT_EQ(0, result.size());
- result = isc::strutil::tokens(" \n "); // String is all delimiters
+ result = isc::util::str::tokens(" \n "); // String is all delimiters
EXPECT_EQ(0, result.size());
- result = isc::strutil::tokens("abc"); // String has no delimiters
+ result = isc::util::str::tokens("abc"); // String has no delimiters
ASSERT_EQ(1, result.size());
EXPECT_EQ(string("abc"), result[0]);
// String containing leading and/or trailing delimiters, no embedded ones.
- result = isc::strutil::tokens("\txyz"); // One leading delimiter
+ result = isc::util::str::tokens("\txyz"); // One leading delimiter
ASSERT_EQ(1, result.size());
EXPECT_EQ(string("xyz"), result[0]);
- result = isc::strutil::tokens("\t \nxyz"); // Multiple leading delimiters
+ result = isc::util::str::tokens("\t \nxyz"); // Multiple leading delimiters
ASSERT_EQ(1, result.size());
EXPECT_EQ(string("xyz"), result[0]);
- result = isc::strutil::tokens("xyz\n"); // One trailing delimiter
+ result = isc::util::str::tokens("xyz\n"); // One trailing delimiter
ASSERT_EQ(1, result.size());
EXPECT_EQ(string("xyz"), result[0]);
- result = isc::strutil::tokens("xyz \t"); // Multiple trailing
+ result = isc::util::str::tokens("xyz \t"); // Multiple trailing
ASSERT_EQ(1, result.size());
EXPECT_EQ(string("xyz"), result[0]);
- result = isc::strutil::tokens("\t xyz \n"); // Leading and trailing
+ result = isc::util::str::tokens("\t xyz \n"); // Leading and trailing
ASSERT_EQ(1, result.size());
EXPECT_EQ(string("xyz"), result[0]);
// Embedded delimiters
- result = isc::strutil::tokens("abc\ndef"); // 2 tokens, one separator
+ result = isc::util::str::tokens("abc\ndef"); // 2 tokens, one separator
ASSERT_EQ(2, result.size());
EXPECT_EQ(string("abc"), result[0]);
EXPECT_EQ(string("def"), result[1]);
- result = isc::strutil::tokens("abc\t\t\ndef"); // 2 tokens, 3 separators
+ result = isc::util::str::tokens("abc\t\t\ndef"); // 2 tokens, 3 separators
ASSERT_EQ(2, result.size());
EXPECT_EQ(string("abc"), result[0]);
EXPECT_EQ(string("def"), result[1]);
- result = isc::strutil::tokens("abc\n \tdef\t\tghi");
+ result = isc::util::str::tokens("abc\n \tdef\t\tghi");
ASSERT_EQ(3, result.size()); // Multiple tokens, many delims
EXPECT_EQ(string("abc"), result[0]);
EXPECT_EQ(string("def"), result[1]);
@@ -126,14 +127,14 @@ TEST_F(StringUtilTest, Tokens) {
// Embedded and non-embedded delimiters
- result = isc::strutil::tokens("\t\t \nabc\n \tdef\t\tghi \n\n");
+ result = isc::util::str::tokens("\t\t \nabc\n \tdef\t\tghi \n\n");
ASSERT_EQ(3, result.size()); // Multiple tokens, many delims
EXPECT_EQ(string("abc"), result[0]);
EXPECT_EQ(string("def"), result[1]);
EXPECT_EQ(string("ghi"), result[2]);
// Non-default delimiter
- result = isc::strutil::tokens("alpha/beta/ /gamma//delta/epsilon/", "/");
+ result = isc::util::str::tokens("alpha/beta/ /gamma//delta/epsilon/", "/");
ASSERT_EQ(6, result.size());
EXPECT_EQ(string("alpha"), result[0]);
EXPECT_EQ(string("beta"), result[1]);
@@ -143,7 +144,7 @@ TEST_F(StringUtilTest, Tokens) {
EXPECT_EQ(string("epsilon"), result[5]);
// Non-default delimiters (plural)
- result = isc::strutil::tokens("+*--alpha*beta+ -gamma**delta+epsilon-+**",
+ result = isc::util::str::tokens("+*--alpha*beta+ -gamma**delta+epsilon-+**",
"*+-");
ASSERT_EQ(6, result.size());
EXPECT_EQ(string("alpha"), result[0]);
@@ -162,11 +163,11 @@ TEST_F(StringUtilTest, ChangeCase) {
string lower("abcdefghijklmno123[]{=+--+]}");
string test = mixed;
- isc::strutil::lowercase(test);
+ isc::util::str::lowercase(test);
EXPECT_EQ(lower, test);
test = mixed;
- isc::strutil::uppercase(test);
+ isc::util::str::uppercase(test);
EXPECT_EQ(upper, test);
}
@@ -180,35 +181,35 @@ TEST_F(StringUtilTest, Formatting) {
args.push_back("arg3");
string format1 = "This is a string with no tokens";
- EXPECT_EQ(format1, isc::strutil::format(format1, args));
+ EXPECT_EQ(format1, isc::util::str::format(format1, args));
string format2 = ""; // Empty string
- EXPECT_EQ(format2, isc::strutil::format(format2, args));
+ EXPECT_EQ(format2, isc::util::str::format(format2, args));
string format3 = " "; // Empty string
- EXPECT_EQ(format3, isc::strutil::format(format3, args));
+ EXPECT_EQ(format3, isc::util::str::format(format3, args));
string format4 = "String with %d non-string tokens %lf";
- EXPECT_EQ(format4, isc::strutil::format(format4, args));
+ EXPECT_EQ(format4, isc::util::str::format(format4, args));
string format5 = "String with %s correct %s number of tokens %s";
string result5 = "String with arg1 correct arg2 number of tokens arg3";
- EXPECT_EQ(result5, isc::strutil::format(format5, args));
+ EXPECT_EQ(result5, isc::util::str::format(format5, args));
string format6 = "String with %s too %s few tokens";
string result6 = "String with arg1 too arg2 few tokens";
- EXPECT_EQ(result6, isc::strutil::format(format6, args));
+ EXPECT_EQ(result6, isc::util::str::format(format6, args));
string format7 = "String with %s too %s many %s tokens %s !";
string result7 = "String with arg1 too arg2 many arg3 tokens %s !";
- EXPECT_EQ(result7, isc::strutil::format(format7, args));
+ EXPECT_EQ(result7, isc::util::str::format(format7, args));
string format8 = "String with embedded%s%s%stokens";
string result8 = "String with embeddedarg1arg2arg3tokens";
- EXPECT_EQ(result8, isc::strutil::format(format8, args));
+ EXPECT_EQ(result8, isc::util::str::format(format8, args));
// Handle an empty vector
args.clear();
string format9 = "%s %s";
- EXPECT_EQ(format9, isc::strutil::format(format9, args));
+ EXPECT_EQ(format9, isc::util::str::format(format9, args));
}
diff --git a/src/lib/util/tests/time_utilities_unittest.cc b/src/lib/util/tests/time_utilities_unittest.cc
index 8a16708..f0c9ff7 100644
--- a/src/lib/util/tests/time_utilities_unittest.cc
+++ b/src/lib/util/tests/time_utilities_unittest.cc
@@ -16,17 +16,17 @@
#include <time.h>
-#include <util/compat/time_utilities.h>
+#include <util/coder/time_utilities.h>
#include <gtest/gtest.h>
using namespace std;
-using namespace isc::util::compat;
+using namespace isc::util::coder;
// See time_utilities.cc
namespace isc {
namespace util {
-namespace compat {
+namespace coder {
namespace detail {
extern int64_t (*gettimeFunction)();
}
More information about the bind10-changes
mailing list