Browse Source

[trac703] Merge branch 'master' into trac703

... master being updated shortly after the last merge.
Conflicts:
	src/lib/asiodns/io_fetch.cc
	src/lib/asiodns/io_fetch.h
Stephen Morris 14 years ago
parent
commit
17106327ef
100 changed files with 671 additions and 448 deletions
  1. 2 0
      configure.ac
  2. 1 0
      src/bin/auth/Makefile.am
  3. 3 2
      src/bin/auth/auth_srv.cc
  4. 14 14
      src/bin/auth/auth_srv.h
  5. 1 0
      src/bin/auth/benchmarks/Makefile.am
  6. 3 1
      src/bin/auth/benchmarks/query_bench.cc
  7. 3 1
      src/bin/auth/main.cc
  8. 1 0
      src/bin/auth/tests/Makefile.am
  9. 2 1
      src/bin/auth/tests/auth_srv_unittest.cc
  10. 1 1
      src/bin/auth/tests/command_unittest.cc
  11. 2 1
      src/bin/auth/tests/config_unittest.cc
  12. 3 0
      src/bin/resolver/Makefile.am
  13. 3 1
      src/bin/resolver/main.cc
  14. 5 3
      src/bin/resolver/resolver.cc
  15. 20 20
      src/bin/resolver/resolver.h
  16. 1 1
      src/bin/resolver/response_scrubber.cc
  17. 2 2
      src/bin/resolver/response_scrubber.h
  18. 1 0
      src/bin/resolver/tests/Makefile.am
  19. 3 1
      src/bin/resolver/tests/resolver_config_unittest.cc
  20. 3 1
      src/bin/resolver/tests/response_scrubber_unittest.cc
  21. 1 1
      src/lib/Makefile.am
  22. 33 0
      src/lib/asiodns/Makefile.am
  23. 157 0
      src/lib/asiodns/README
  24. 14 12
      src/lib/asiolink/asiodef.cc
  25. 23 0
      src/lib/asiodns/asiodef.h
  26. 2 2
      src/lib/asiolink/asiodef.msg
  27. 23 0
      src/lib/asiodns/asiodns.h
  28. 7 3
      src/lib/asiolink/dns_answer.h
  29. 6 4
      src/lib/asiolink/dns_lookup.h
  30. 5 3
      src/lib/asiolink/dns_server.h
  31. 9 8
      src/lib/asiolink/dns_service.cc
  32. 11 9
      src/lib/asiolink/dns_service.h
  33. 33 31
      src/lib/asiolink/io_fetch.cc
  34. 12 8
      src/lib/asiolink/io_fetch.h
  35. 6 4
      src/lib/asiolink/qid_gen.cc
  36. 4 2
      src/lib/asiolink/qid_gen.h
  37. 6 4
      src/lib/asiolink/tcp_server.cc
  38. 12 8
      src/lib/asiolink/tcp_server.h
  39. 50 0
      src/lib/asiodns/tests/Makefile.am
  40. 6 5
      src/lib/asiolink/tests/dns_server_unittest.cc
  41. 6 3
      src/lib/asiolink/tests/io_fetch_unittest.cc
  42. 3 1
      src/lib/asiolink/tests/io_service_unittest.cc
  43. 4 4
      src/lib/asiolink/tests/qid_gen_unittest.cc
  44. 28 0
      src/lib/asiodns/tests/run_unittests.cc
  45. 6 3
      src/lib/asiolink/udp_server.cc
  46. 8 6
      src/lib/asiolink/udp_server.h
  47. 0 11
      src/lib/asiolink/Makefile.am
  48. 0 160
      src/lib/asiolink/README
  49. 0 21
      src/lib/asiolink/asiodef.h
  50. 0 9
      src/lib/asiolink/asiolink.h
  51. 2 0
      src/lib/asiolink/asiolink_utilities.h
  52. 2 0
      src/lib/asiolink/dummy_io_cb.h
  53. 3 1
      src/lib/asiolink/interval_timer.cc
  54. 3 1
      src/lib/asiolink/interval_timer.h
  55. 3 1
      src/lib/asiolink/io_address.cc
  56. 3 1
      src/lib/asiolink/io_address.h
  57. 2 1
      src/lib/asiolink/io_asio_socket.h
  58. 3 1
      src/lib/asiolink/io_endpoint.cc
  59. 3 1
      src/lib/asiolink/io_endpoint.h
  60. 3 1
      src/lib/asiolink/io_error.h
  61. 3 1
      src/lib/asiolink/io_message.h
  62. 3 1
      src/lib/asiolink/io_service.cc
  63. 3 1
      src/lib/asiolink/io_service.h
  64. 3 3
      src/lib/asiolink/io_socket.cc
  65. 2 0
      src/lib/asiolink/io_socket.h
  66. 3 1
      src/lib/asiolink/simple_callback.h
  67. 3 1
      src/lib/asiolink/tcp_endpoint.h
  68. 2 0
      src/lib/asiolink/tcp_socket.h
  69. 0 4
      src/lib/asiolink/tests/Makefile.am
  70. 1 1
      src/lib/asiolink/tests/asiolink_utilities_unittest.cc
  71. 1 1
      src/lib/asiolink/tests/interval_timer_unittest.cc
  72. 1 1
      src/lib/asiolink/tests/io_address_unittest.cc
  73. 1 1
      src/lib/asiolink/tests/io_endpoint_unittest.cc
  74. 1 1
      src/lib/asiolink/tests/io_socket_unittest.cc
  75. 1 1
      src/lib/asiolink/tests/tcp_endpoint_unittest.cc
  76. 1 1
      src/lib/asiolink/tests/tcp_socket_unittest.cc
  77. 1 1
      src/lib/asiolink/tests/udp_endpoint_unittest.cc
  78. 1 1
      src/lib/asiolink/tests/udp_socket_unittest.cc
  79. 3 1
      src/lib/asiolink/udp_endpoint.h
  80. 2 0
      src/lib/asiolink/udp_socket.h
  81. 1 1
      src/lib/nsas/glue_hints.cc
  82. 1 1
      src/lib/nsas/nameserver_entry.cc
  83. 1 1
      src/lib/nsas/tests/address_entry_unittest.cc
  84. 2 2
      src/lib/nsas/tests/nameserver_address_unittest.cc
  85. 1 1
      src/lib/nsas/tests/nameserver_entry_unittest.cc
  86. 1 1
      src/lib/nsas/tests/zone_entry_unittest.cc
  87. 7 6
      src/lib/resolve/recursive_query.cc
  88. 10 9
      src/lib/resolve/recursive_query.h
  89. 3 3
      src/lib/resolve/resolver_callback.h
  90. 1 0
      src/lib/resolve/tests/Makefile.am
  91. 4 3
      src/lib/resolve/tests/recursive_query_unittest.cc
  92. 7 4
      src/lib/resolve/tests/recursive_query_unittest_2.cc
  93. 4 4
      src/lib/resolve/tests/resolver_callback_unittest.cc
  94. 4 3
      src/lib/server_common/portconfig.cc
  95. 4 2
      src/lib/server_common/portconfig.h
  96. 2 1
      src/lib/server_common/tests/Makefile.am
  97. 3 1
      src/lib/server_common/tests/portconfig_unittest.cc
  98. 2 2
      src/lib/testutils/mockups.h
  99. 1 1
      src/lib/testutils/srv_test.cc
  100. 0 0
      tests/tools/badpacket/Makefile.am

+ 2 - 0
configure.ac

@@ -644,6 +644,8 @@ AC_CONFIG_FILES([Makefile
                  src/lib/Makefile
                  src/lib/asiolink/Makefile
                  src/lib/asiolink/tests/Makefile
+                 src/lib/asiodns/Makefile
+                 src/lib/asiodns/tests/Makefile
                  src/lib/bench/Makefile
                  src/lib/bench/example/Makefile
                  src/lib/bench/tests/Makefile

+ 1 - 0
src/bin/auth/Makefile.am

@@ -49,6 +49,7 @@ b10_auth_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
 b10_auth_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
 b10_auth_LDADD += $(top_builddir)/src/lib/cc/libcc.la
 b10_auth_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
+b10_auth_LDADD += $(top_builddir)/src/lib/asiodns/libasiodns.la
 b10_auth_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 b10_auth_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
 b10_auth_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la

+ 3 - 2
src/bin/auth/auth_srv.cc

@@ -68,7 +68,8 @@ using namespace isc::dns::rdata;
 using namespace isc::data;
 using namespace isc::config;
 using namespace isc::xfr;
-using namespace asiolink;
+using namespace isc::asiolink;
+using namespace isc::asiodns;
 using namespace isc::server_common::portconfig;
 
 class AuthSrvImpl {
@@ -766,6 +767,6 @@ AuthSrv::setListenAddresses(const AddressList& addresses) {
 }
 
 void
-AuthSrv::setDNSService(asiolink::DNSService& dnss) {
+AuthSrv::setDNSService(isc::asiodns::DNSService& dnss) {
     dnss_ = &dnss;
 }

+ 14 - 14
src/bin/auth/auth_srv.h

@@ -26,11 +26,11 @@
 #include <dns/message.h>
 #include <dns/buffer.h>
 
+#include <asiodns/dns_server.h>
+#include <asiodns/dns_lookup.h>
+#include <asiodns/dns_answer.h>
 #include <asiolink/io_message.h>
 #include <asiolink/io_service.h>
-#include <asiolink/dns_server.h>
-#include <asiolink/dns_lookup.h>
-#include <asiolink/dns_answer.h>
 #include <asiolink/simple_callback.h>
 
 #include <asiolink/asiolink.h>
@@ -116,10 +116,10 @@ public:
     /// \param server Pointer to the \c DNSServer
     ///
     /// \throw isc::Unexpected Protocol type of \a message is unexpected
-    void processMessage(const asiolink::IOMessage& io_message,
+    void processMessage(const isc::asiolink::IOMessage& io_message,
                         isc::dns::MessagePtr message,
                         isc::dns::OutputBufferPtr buffer,
-                        asiolink::DNSServer* server);
+                        isc::asiodns::DNSServer* server);
 
     /// \brief Set verbose flag
     ///
@@ -202,16 +202,16 @@ public:
     void setConfigSession(isc::config::ModuleCCSession* config_session);
 
     /// \brief Return this object's ASIO IO Service queue
-    asiolink::IOService& getIOService();
+    isc::asiolink::IOService& getIOService();
 
     /// \brief Return pointer to the DNS Lookup callback function
-    asiolink::DNSLookup* getDNSLookupProvider() const { return (dns_lookup_); }
+    isc::asiodns::DNSLookup* getDNSLookupProvider() const { return (dns_lookup_); }
 
     /// \brief Return pointer to the DNS Answer callback function
-    asiolink::DNSAnswer* getDNSAnswerProvider() const { return (dns_answer_); }
+    isc::asiodns::DNSAnswer* getDNSAnswerProvider() const { return (dns_answer_); }
 
     /// \brief Return pointer to the Checkin callback function
-    asiolink::SimpleCallback* getCheckinProvider() const { return (checkin_); }
+    isc::asiolink::SimpleCallback* getCheckinProvider() const { return (checkin_); }
 
     /// \brief Set or update the size (number of slots) of hot spot cache.
     ///
@@ -372,15 +372,15 @@ public:
         const;
 
     /// \brief Assign an ASIO DNS Service queue to this Auth object
-    void setDNSService(asiolink::DNSService& dnss);
+    void setDNSService(isc::asiodns::DNSService& dnss);
 
 
 private:
     AuthSrvImpl* impl_;
-    asiolink::SimpleCallback* checkin_;
-    asiolink::DNSLookup* dns_lookup_;
-    asiolink::DNSAnswer* dns_answer_;
-    asiolink::DNSService* dnss_;
+    isc::asiolink::SimpleCallback* checkin_;
+    isc::asiodns::DNSLookup* dns_lookup_;
+    isc::asiodns::DNSAnswer* dns_answer_;
+    isc::asiodns::DNSService* dnss_;
 };
 
 #endif // __AUTH_SRV_H

+ 1 - 0
src/bin/auth/benchmarks/Makefile.am

@@ -22,6 +22,7 @@ query_bench_LDADD += $(top_builddir)/src/lib/cc/libcc.la
 query_bench_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
 query_bench_LDADD += $(top_builddir)/src/lib/log/liblog.la
 query_bench_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
+query_bench_LDADD += $(top_builddir)/src/lib/asiodns/libasiodns.la
 query_bench_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 query_bench_LDADD += $(top_builddir)/src/lib/server_common/libserver_common.la
 query_bench_LDADD += $(SQLITE_LIBS)

+ 3 - 1
src/bin/auth/benchmarks/query_bench.cc

@@ -36,6 +36,7 @@
 #include <auth/auth_config.h>
 #include <auth/query.h>
 
+#include <asiodns/asiodns.h>
 #include <asiolink/asiolink.h>
 
 using namespace std;
@@ -45,7 +46,8 @@ using namespace isc::auth;
 using namespace isc::dns;
 using namespace isc::xfr;
 using namespace isc::bench;
-using namespace asiolink;
+using namespace isc::asiodns;
+using namespace isc::asiolink;
 
 namespace {
 // Commonly used constant:

+ 3 - 1
src/bin/auth/main.cc

@@ -43,6 +43,7 @@
 #include <auth/command.h>
 #include <auth/change_user.h>
 #include <auth/auth_srv.h>
+#include <asiodns/asiodns.h>
 #include <asiolink/asiolink.h>
 #include <log/dummylog.h>
 
@@ -52,7 +53,8 @@ using namespace isc::cc;
 using namespace isc::config;
 using namespace isc::dns;
 using namespace isc::xfr;
-using namespace asiolink;
+using namespace isc::asiolink;
+using namespace isc::asiodns;
 
 namespace {
 

+ 1 - 0
src/bin/auth/tests/Makefile.am

@@ -45,6 +45,7 @@ run_unittests_LDADD += $(SQLITE_LIBS)
 run_unittests_LDADD += $(top_builddir)/src/lib/testutils/libtestutils.la
 run_unittests_LDADD +=  $(top_builddir)/src/lib/datasrc/libdatasrc.la
 run_unittests_LDADD +=  $(top_builddir)/src/lib/dns/libdns++.la
+run_unittests_LDADD += $(top_builddir)/src/lib/asiodns/libasiodns.la
 run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 run_unittests_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
 run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la

+ 2 - 1
src/bin/auth/tests/auth_srv_unittest.cc

@@ -44,7 +44,8 @@ using namespace isc::dns;
 using namespace isc::dns::rdata;
 using namespace isc::data;
 using namespace isc::xfr;
-using namespace asiolink;
+using namespace isc::asiodns;
+using namespace isc::asiolink;
 using namespace isc::testutils;
 using namespace isc::server_common::portconfig;
 using isc::UnitTestUtil;

+ 1 - 1
src/bin/auth/tests/command_unittest.cc

@@ -99,7 +99,7 @@ AuthConmmandTest::stopServer() {
 }
 
 TEST_F(AuthConmmandTest, shutdown) {
-    asiolink::IntervalTimer itimer(server.getIOService());
+    isc::asiolink::IntervalTimer itimer(server.getIOService());
     itimer.setup(boost::bind(&AuthConmmandTest::stopServer, this), 1);
     server.getIOService().run();
     EXPECT_EQ(0, rcode);

+ 2 - 1
src/bin/auth/tests/config_unittest.cc

@@ -35,7 +35,8 @@
 using namespace isc::dns;
 using namespace isc::data;
 using namespace isc::datasrc;
-using namespace asiolink;
+using namespace isc::asiodns;
+using namespace isc::asiolink;
 
 namespace {
 class AuthConfigTest : public ::testing::Test {

+ 3 - 0
src/bin/resolver/Makefile.am

@@ -4,6 +4,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
 AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
 AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
 AM_CPPFLAGS += -I$(top_srcdir)/src/lib/cc -I$(top_builddir)/src/lib/cc
+AM_CPPFLAGS += -I$(top_srcdir)/src/lib/asiodns
+AM_CPPFLAGS += -I$(top_builddir)/src/lib/asiodns
 AM_CPPFLAGS += -I$(top_srcdir)/src/lib/asiolink
 AM_CPPFLAGS += -I$(top_builddir)/src/lib/asiolink
 AM_CPPFLAGS += $(BOOST_INCLUDES)
@@ -45,6 +47,7 @@ b10_resolver_LDADD =  $(top_builddir)/src/lib/dns/libdns++.la
 b10_resolver_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
 b10_resolver_LDADD += $(top_builddir)/src/lib/cc/libcc.la
 b10_resolver_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
+b10_resolver_LDADD += $(top_builddir)/src/lib/asiodns/libasiodns.la
 b10_resolver_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 b10_resolver_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
 b10_resolver_LDADD += $(top_builddir)/src/lib/log/liblog.la

+ 3 - 1
src/bin/resolver/main.cc

@@ -27,6 +27,7 @@
 
 #include <boost/foreach.hpp>
 
+#include <asiodns/asiodns.h>
 #include <asiolink/asiolink.h>
 
 #include <exceptions/exceptions.h>
@@ -58,7 +59,8 @@ using namespace isc::cc;
 using namespace isc::config;
 using namespace isc::data;
 using isc::log::dlog;
-using namespace asiolink;
+using namespace isc::asiodns;
+using namespace isc::asiolink;
 
 namespace {
 

+ 5 - 3
src/bin/resolver/resolver.cc

@@ -20,6 +20,7 @@
 #include <vector>
 #include <cassert>
 
+#include <asiodns/asiodns.h>
 #include <asiolink/asiolink.h>
 
 #include <boost/foreach.hpp>
@@ -54,7 +55,8 @@ using namespace isc::dns;
 using namespace isc::data;
 using namespace isc::config;
 using isc::log::dlog;
-using namespace asiolink;
+using namespace isc::asiodns;
+using namespace isc::asiolink;
 using namespace isc::server_common::portconfig;
 
 class ResolverImpl {
@@ -295,7 +297,7 @@ public:
             edns_response->setUDPSize(Message::DEFAULT_MAX_EDNS0_UDPSIZE);
             answer_message->setEDNS(edns_response);
         }
-        
+
         if (io_message.getSocket().getProtocol() == IPPROTO_UDP) {
             if (edns) {
                 renderer.setLengthLimit(edns->getUDPSize());
@@ -345,7 +347,7 @@ Resolver::~Resolver() {
 }
 
 void
-Resolver::setDNSService(asiolink::DNSService& dnss) {
+Resolver::setDNSService(isc::asiodns::DNSService& dnss) {
     dnss_ = &dnss;
 }
 

+ 20 - 20
src/bin/resolver/resolver.h

@@ -24,12 +24,12 @@
 #include <dns/message.h>
 #include <dns/buffer.h>
 
+#include <asiodns/dns_server.h>
+#include <asiodns/dns_service.h>
+#include <asiodns/dns_lookup.h>
+#include <asiodns/dns_answer.h>
 #include <asiolink/io_message.h>
 #include <asiolink/io_service.h>
-#include <asiolink/dns_server.h>
-#include <asiolink/dns_service.h>
-#include <asiolink/dns_lookup.h>
-#include <asiolink/dns_answer.h>
 #include <asiolink/simple_callback.h>
 
 #include <nsas/nameserver_address_store.h>
@@ -82,11 +82,11 @@ public:
     /// shall return to the client
     /// \param buffer Pointer to an \c OutputBuffer for the resposne
     /// \param server Pointer to the \c DNSServer
-    void processMessage(const asiolink::IOMessage& io_message,
+    void processMessage(const isc::asiolink::IOMessage& io_message,
                         isc::dns::MessagePtr query_message,
                         isc::dns::MessagePtr answer_message,
                         isc::dns::OutputBufferPtr buffer,
-                        asiolink::DNSServer* server);
+                        isc::asiodns::DNSServer* server);
 
     /// \brief Set and get the config session
     isc::config::ModuleCCSession* getConfigSession() const;
@@ -96,16 +96,16 @@ public:
     isc::data::ConstElementPtr updateConfig(isc::data::ConstElementPtr config);
 
     /// \brief Assign an ASIO IO Service queue to this Resolver object
-    void setDNSService(asiolink::DNSService& dnss);
-    
+    void setDNSService(isc::asiodns::DNSService& dnss);
+
     /// \brief Assign a NameserverAddressStore to this Resolver object
     void setNameserverAddressStore(isc::nsas::NameserverAddressStore &nsas);
-    
+
     /// \brief Assign a cache to this Resolver object
     void setCache(isc::cache::ResolverCache& cache);
 
     /// \brief Return this object's ASIO IO Service queue
-    asiolink::DNSService& getDNSService() const { return (*dnss_); }
+    isc::asiodns::DNSService& getDNSService() const { return (*dnss_); }
 
     /// \brief Returns this object's NSAS
     isc::nsas::NameserverAddressStore& getNameserverAddressStore() const {
@@ -116,15 +116,15 @@ public:
     isc::cache::ResolverCache& getResolverCache() const {
         return *cache_;
     };
-    
+
     /// \brief Return pointer to the DNS Lookup callback function
-    asiolink::DNSLookup* getDNSLookupProvider() { return (dns_lookup_); }
+    isc::asiodns::DNSLookup* getDNSLookupProvider() { return (dns_lookup_); }
 
     /// \brief Return pointer to the DNS Answer callback function
-    asiolink::DNSAnswer* getDNSAnswerProvider() { return (dns_answer_); }
+    isc::asiodns::DNSAnswer* getDNSAnswerProvider() { return (dns_answer_); }
 
     /// \brief Return pointer to the Checkin callback function
-    asiolink::SimpleCallback* getCheckinProvider() { return (checkin_); }
+    isc::asiolink::SimpleCallback* getCheckinProvider() { return (checkin_); }
 
     /**
      * \brief Tell the Resolver that is has already been configured
@@ -238,10 +238,10 @@ public:
 
 private:
     ResolverImpl* impl_;
-    asiolink::DNSService* dnss_;
-    asiolink::SimpleCallback* checkin_;
-    asiolink::DNSLookup* dns_lookup_;
-    asiolink::DNSAnswer* dns_answer_;
+    isc::asiodns::DNSService* dnss_;
+    isc::asiolink::SimpleCallback* checkin_;
+    isc::asiodns::DNSLookup* dns_lookup_;
+    isc::asiodns::DNSAnswer* dns_answer_;
     isc::nsas::NameserverAddressStore* nsas_;
     isc::cache::ResolverCache* cache_;
     // This value is initally false, and will be set to true
@@ -252,6 +252,6 @@ private:
 
 #endif // __RESOLVER_H
 
-// Local Variables: 
+// Local Variables:
 // mode: c++
-// End: 
+// End:

+ 1 - 1
src/bin/resolver/response_scrubber.cc

@@ -26,7 +26,7 @@ using namespace std;
 // Compare addresses etc.
 
 ResponseScrubber::Category ResponseScrubber::addressCheck(
-    const asiolink::IOEndpoint& to, const asiolink::IOEndpoint& from)
+    const isc::asiolink::IOEndpoint& to, const isc::asiolink::IOEndpoint& from)
 {
     if (from.getProtocol() == to.getProtocol()) {
         if (from.getAddress() == to.getAddress()) {

+ 2 - 2
src/bin/resolver/response_scrubber.h

@@ -282,8 +282,8 @@ public:
     ///
     /// \return SUCCESS if the two endpoints match, otherwise an error status
     /// indicating what was incorrect.
-    static Category addressCheck(const asiolink::IOEndpoint& to,
-        const asiolink::IOEndpoint& from);
+    static Category addressCheck(const isc::asiolink::IOEndpoint& to,
+        const isc::asiolink::IOEndpoint& from);
 
     /// \brief Check QID
     ///

+ 1 - 0
src/bin/resolver/tests/Makefile.am

@@ -31,6 +31,7 @@ run_unittests_LDADD += $(SQLITE_LIBS)
 run_unittests_LDADD += $(top_builddir)/src/lib/testutils/libtestutils.la
 run_unittests_LDADD += $(top_builddir)/src/lib/datasrc/libdatasrc.la
 run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
+run_unittests_LDADD += $(top_builddir)/src/lib/asiodns/libasiodns.la
 run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 run_unittests_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
 run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la

+ 3 - 1
src/bin/resolver/tests/resolver_config_unittest.cc

@@ -20,6 +20,7 @@
 
 #include <cc/data.h>
 
+#include <asiodns/asiodns.h>
 #include <asiolink/asiolink.h>
 
 #include <resolver/resolver.h>
@@ -31,7 +32,8 @@
 using namespace std;
 using namespace isc::data;
 using namespace isc::testutils;
-using namespace asiolink;
+using namespace isc::asiodns;
+using namespace isc::asiolink;
 using isc::UnitTestUtil;
 
 namespace {

+ 3 - 1
src/bin/resolver/tests/response_scrubber_unittest.cc

@@ -41,6 +41,7 @@
 // Class for endpoint checks.  The family of the endpoint is set in the
 // constructor; the address family by the string provided for the address.
 
+namespace isc {
 namespace asiolink {
 
 class GenericEndpoint : public IOEndpoint {
@@ -73,13 +74,14 @@ private:
     short       protocol_;      // Protocol of the endpoint
     };
 }
+}
 
 using namespace asio::ip;
 using namespace isc::dns;
 using namespace rdata;
 using namespace isc::dns::rdata::generic;
 using namespace isc::dns::rdata::in;
-using namespace asiolink;
+using namespace isc::asiolink;
 
 // Test class
 

+ 1 - 1
src/lib/Makefile.am

@@ -1,2 +1,2 @@
 SUBDIRS = exceptions dns cc config util python xfr bench log asiolink \
-          nsas cache resolve testutils datasrc server_common
+          asiodns nsas cache resolve testutils datasrc server_common

+ 33 - 0
src/lib/asiodns/Makefile.am

@@ -0,0 +1,33 @@
+SUBDIRS = . tests
+
+AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
+AM_CPPFLAGS += -I$(top_srcdir)/src/lib/asiolink -I$(top_builddir)/src/lib/asiolink
+
+AM_CXXFLAGS = $(B10_CXXFLAGS)
+
+CLEANFILES = *.gcno *.gcda
+
+lib_LTLIBRARIES = libasiodns.la
+libasiodns_la_SOURCES = dns_answer.h
+libasiodns_la_SOURCES += asiodef.cc asiodef.h
+libasiodns_la_SOURCES += dns_lookup.h
+libasiodns_la_SOURCES += dns_server.h
+libasiodns_la_SOURCES += dns_service.cc dns_service.h
+libasiodns_la_SOURCES += tcp_server.cc tcp_server.h
+libasiodns_la_SOURCES += udp_server.cc udp_server.h
+libasiodns_la_SOURCES += io_fetch.cc io_fetch.h
+libasiodns_la_SOURCES += qid_gen.cc qid_gen.h
+
+EXTRA_DIST = asiodef.msg
+
+# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
+# B10_CXXFLAGS)
+libasiodns_la_CXXFLAGS = $(AM_CXXFLAGS)
+if USE_CLANGPP
+# Same for clang++, but we need to turn off -Werror completely.
+libasiodns_la_CXXFLAGS += -Wno-error
+endif
+libasiodns_la_CPPFLAGS = $(AM_CPPFLAGS)
+libasiodns_la_LIBADD = $(top_builddir)/src/lib/log/liblog.la

+ 157 - 0
src/lib/asiodns/README

@@ -0,0 +1,157 @@
+The asiodns library is intended to provide an abstraction layer between
+BIND10 modules and asiolink library.
+
+These DNS server and client routines are written using the "stackless
+coroutine" pattern invented by Chris Kohlhoff and described at
+http://blog.think-async.com/2010/03/potted-guide-to-stackless-coroutines.html.
+This is intended to simplify development a bit, since it allows the
+routines to be written in a straightfowrard step-step-step fashion rather
+than as a complex chain of separate handler functions.
+
+Coroutine objects (i.e., UDPServer, TCPServer and IOFetch) are objects
+with reenterable operator() members.  When an instance of one of these
+classes is called as a function, it resumes at the position where it left
+off.  Thus, a UDPServer can issue an asynchronous I/O call and specify
+itself as the handler object; when the call completes, the UDPServer
+carries on at the same position.  As a result, the code can look as
+if it were using synchronous, not asynchronous, I/O, providing some of
+the benefit of threading but with minimal switching overhead.
+
+So, in simplified form, the behavior of a DNS Server is:
+
+  REENTER:
+    while true:
+      YIELD packet = read_packet
+      FORK
+      if not parent:
+        break
+
+    # This callback informs the caller that a packet has arrived, and
+    # gives it a chance to update configuration, etc
+    SimpleCallback(packet)
+    YIELD answer = DNSLookup(packet, this)
+    response = DNSAnswer(answer)
+    YIELD send(response)
+
+At each "YIELD" point, the coroutine initiates an asynchronous operation,
+then pauses and turns over control to some other task on the ASIO service
+queue.  When the operation completes, the coroutine resumes.
+
+DNSLookup, DNSAnswer and SimpleCallback define callback methods
+used by a DNS Server to communicate with the module that called it.
+They are abstract-only classes whose concrete implementations
+are supplied by the calling module.
+
+The DNSLookup callback always runs asynchronously.  Concrete
+implementations must be sure to call the server's "resume" method when
+it is finished.
+
+In an authoritative server, the DNSLookup implementation would examine
+the query, look up the answer, then call "resume".  (See the diagram
+in doc/auth_process.jpg.)
+
+In a recursive server, the DNSLookup impelemtation would initiate a
+DNSQuery, which in turn would be responsible for calling the server's
+"resume" method.  (See the diagram in doc/recursive_process.jpg.)
+
+A DNSQuery object is intended to handle resolution of a query over
+the network when the local authoritative data sources or cache are not
+sufficient.  The plan is that it will make use of subsidiary DNSFetch
+calls to get data from particular authoritative servers, and when it has
+gotten a complete answer, it calls "resume".
+
+In current form, however, DNSQuery is much simpler; it forwards queries
+to a single upstream resolver and passes the answers back to the client.
+It is constructed with the address of the forward server.  Queries are
+initiated with the question to ask the forward server, a buffer into
+which to write the answer, and a pointer to the coroutine to be resumed
+when the answer has arrived.  In simplified form, the DNSQuery routine is:
+
+  REENTER:
+    render the question into a wire-format query packet
+    YIELD send(query)
+    YIELD response = read_packet
+    server->resume
+
+Currently, DNSQuery is only implemented for UDP queries.  In future work
+it will be necessary to write code to fall back to TCP when circumstances
+require it.
+
+
+Upstream Fetches
+================
+Upstream fetches (queries by the resolver on behalf of a client) are made
+using a slightly-modified version of the pattern described above.
+
+Sockets
+-------
+First, it will be useful to understand the class hierarchy used in the
+fetch logic:
+
+        IOSocket
+           |
+      IOAsioSocket
+           |
+     +-----+-----+                
+     |           |
+UDPSocket    TCPSocket
+
+IOSocket is a wrapper class for a socket and is used by the authoritative
+server code.  It is an abstract base class, providing little more that the ability to hold the socket and to return the protocol in use.
+
+Built on this is IOAsioSocket, which adds the open, close, asyncSend and
+asyncReceive methods.  This is a template class, which takes as template
+argument the class of the object that will be used as the callback when the
+asynchronous operation completes. This object can be of any type, but must
+include an operator() method with the signature:
+
+   operator()(asio::error_code ec, size_t length)
+
+... the two arguments being the status of the completed I/O operation and
+the number of bytes transferred. (In the case of the open method, the second
+argument will be zero.)
+
+Finally, the TCPSocket and UDPSocket classes provide the body of the
+asynchronous operations.
+
+Fetch Sequence
+--------------
+The fetch is implemented by the IOFetch class, which takes as argument the
+protocol to use.  The sequence is:
+
+  REENTER:
+    render the question into a wire-format query packet
+    open()                           // Open socket and optionally connect
+    if (! synchronous) {
+        YIELD;
+    }
+    YIELD asyncSend(query)           // Send query 
+    do {
+        YIELD asyncReceive(response) // Read response
+    } while (! complete(response))
+    close()                          // Drop connection and close socket
+    server->resume
+
+The open() method opens a socket for use.  On TCP, it also makes a
+connection to the remote end.  So under UDP the operation will complete
+immediately, but under TCP it could take a long time.  One solution would be
+for the open operation to post an event to the I/O queue; then both cases
+could be regarded as being equivalent, with the completion being signalled
+by the posting of the completion event.  However UDP is the most common case
+and that would involve extra overhead.  So the open() returns a status
+indicating whether the operation completed asynchronously.  If it did, the
+code yields back to the coroutine; if not the yield is bypassed.
+
+The asynchronous send is straightforward, invoking the underlying ASIO
+function.  (Note that the address/port is supplied to both the open() and
+asyncSend() methods - it is used by the TCPSocket in open() and by the
+UDPSocket in asyncSend().)
+
+The asyncReceive() method issues an asynchronous read and waits for completion.
+The fetch object keeps track of the amount of data received so far and when
+the receive completes it calls a method on the socket to determine if the
+entire message has been received.  (This will always be the case for UDP.  On
+TCP though, the message is preceded by a count field as several reads may be
+required to read all the data.)  The fetch loops until all the data is read.
+
+Finally, the socket is closed and the server called to resume operation.

+ 14 - 12
src/lib/asiolink/asiodef.cc

@@ -4,18 +4,20 @@
 #include <log/message_types.h>
 #include <log/message_initializer.h>
 
-namespace asiolink {
-
-extern const isc::log::MessageID ASIO_FETCHCOMP = "FETCHCOMP";
-extern const isc::log::MessageID ASIO_FETCHSTOP = "FETCHSTOP";
-extern const isc::log::MessageID ASIO_OPENSOCK = "OPENSOCK";
-extern const isc::log::MessageID ASIO_RECVSOCK = "RECVSOCK";
-extern const isc::log::MessageID ASIO_RECVTMO = "RECVTMO";
-extern const isc::log::MessageID ASIO_SENDSOCK = "SENDSOCK";
-extern const isc::log::MessageID ASIO_UNKORIGIN = "UNKORIGIN";
-extern const isc::log::MessageID ASIO_UNKRESULT = "UNKRESULT";
-
-} // namespace asiolink
+namespace isc {
+namespace asiodns {
+
+extern const isc::log::MessageID ASIODNS_FETCHCOMP = "FETCHCOMP";
+extern const isc::log::MessageID ASIODNS_FETCHSTOP = "FETCHSTOP";
+extern const isc::log::MessageID ASIODNS_OPENSOCK = "OPENSOCK";
+extern const isc::log::MessageID ASIODNS_RECVSOCK = "RECVSOCK";
+extern const isc::log::MessageID ASIODNS_RECVTMO = "RECVTMO";
+extern const isc::log::MessageID ASIODNS_SENDSOCK = "SENDSOCK";
+extern const isc::log::MessageID ASIODNS_UNKORIGIN = "UNKORIGIN";
+extern const isc::log::MessageID ASIODNS_UNKRESULT = "UNKRESULT";
+
+} // namespace asiodns
+} // namespace isc
 
 namespace {
 

+ 23 - 0
src/lib/asiodns/asiodef.h

@@ -0,0 +1,23 @@
+// File created from asiodef.msg on Mon Feb 28 17:15:30 2011
+
+#ifndef __ASIODEF_H
+#define __ASIODEF_H
+
+#include <log/message_types.h>
+
+namespace isc {
+namespace asiodns {
+
+extern const isc::log::MessageID ASIODNS_FETCHCOMP;
+extern const isc::log::MessageID ASIODNS_FETCHSTOP;
+extern const isc::log::MessageID ASIODNS_OPENSOCK;
+extern const isc::log::MessageID ASIODNS_RECVSOCK;
+extern const isc::log::MessageID ASIODNS_RECVTMO;
+extern const isc::log::MessageID ASIODNS_SENDSOCK;
+extern const isc::log::MessageID ASIODNS_UNKORIGIN;
+extern const isc::log::MessageID ASIODNS_UNKRESULT;
+
+} // namespace asiodns
+} // namespace isc
+
+#endif // __ASIODEF_H

+ 2 - 2
src/lib/asiolink/asiodef.msg

@@ -12,8 +12,8 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-$PREFIX ASIO_
-$NAMESPACE asiolink
+$PREFIX ASIODNS_
+$NAMESPACE isc::asiodns
 
 FETCHCOMP   upstream fetch to %s(%d) has now completed
 + A debug message, this records the the upstream fetch (a query made by the

+ 23 - 0
src/lib/asiodns/asiodns.h

@@ -0,0 +1,23 @@
+// 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 __ASIODNS_H
+#define __ASIODNS_H 1
+
+#include <asiodns/dns_service.h>
+#include <asiodns/dns_server.h>
+#include <asiodns/dns_lookup.h>
+#include <asiodns/dns_answer.h>
+
+#endif // __ASIODNS_H

+ 7 - 3
src/lib/asiolink/dns_answer.h

@@ -16,8 +16,11 @@
 #define __ASIOLINK_DNS_ANSWER_H 1
 
 #include <asiolink/io_message.h>
+#include <dns/buffer.h>
+#include <dns/message.h>
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 /// \brief The \c DNSAnswer class is an abstract base class for a DNS
 /// Answer provider function.
@@ -63,11 +66,12 @@ public:
     /// \param answer_message The DNS MessagePtr of the answer we are
     /// building
     /// \param buffer Intermediate data results are put here
-    virtual void operator()(const IOMessage& io_message,
+    virtual void operator()(const asiolink::IOMessage& io_message,
                             isc::dns::MessagePtr query_message,
                             isc::dns::MessagePtr answer_message,
                             isc::dns::OutputBufferPtr buffer) const = 0;
 };
 
-}      // namespace asiolink
+}      // namespace asiodns
+}      // namespace isc
 #endif // __ASIOLINK_DNS_ANSWER_H

+ 6 - 4
src/lib/asiolink/dns_lookup.h

@@ -16,11 +16,12 @@
 #define __ASIOLINK_DNS_LOOKUP_H 1
 
 #include <asiolink/io_message.h>
-#include <asiolink/dns_server.h>
+#include <asiodns/dns_server.h>
 #include <dns/buffer.h>
 #include <dns/message.h>
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 /// \brief The \c DNSLookup class is an abstract base class for a DNS
 /// Lookup provider function.
@@ -67,7 +68,7 @@ public:
     ///                       this MessagePtr
     /// \param buffer The final answer is put here
     /// \param server DNSServer object to use
-    virtual void operator()(const IOMessage& io_message,
+    virtual void operator()(const asiolink::IOMessage& io_message,
                             isc::dns::MessagePtr message,
                             isc::dns::MessagePtr answer_message,
                             isc::dns::OutputBufferPtr buffer,
@@ -79,5 +80,6 @@ private:
     DNSLookup* self_;
 };
 
-}      // namespace asiolink
+}      // namespace asiodns
+}      // namespace isc
 #endif // __ASIOLINK_DNS_LOOKUP_H

+ 5 - 3
src/lib/asiolink/dns_server.h

@@ -17,7 +17,8 @@
 
 #include <asiolink/io_message.h>
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 /// \brief The \c DNSServer class is a wrapper (and base class) for
 /// classes which provide DNS server functionality.
@@ -34,7 +35,7 @@ namespace asiolink {
 /// instantiated through a base class) are sometimes passed by
 /// reference (as this superclass); calls to methods in the base
 /// class are then rerouted via this pointer to methods in the derived
-/// class.  This allows code from outside asiolink, with no specific
+/// class.  This allows code from outside asiodns, with no specific
 /// knowledge of \c TCPServer or \c UDPServer, to access their methods.
 ///
 /// This class is both assignable and copy-constructable.  Its subclasses
@@ -151,5 +152,6 @@ private:
 };
 
 
-}      // asiolink
+} // namespace asiodns
+} // namespace isc
 #endif // __ASIOLINK_DNS_SERVER_H

+ 9 - 8
src/lib/asiolink/dns_service.cc

@@ -23,11 +23,11 @@
 #include <log/dummylog.h>
 
 #include <asio.hpp>
-#include <asiolink/dns_service.h>
+#include <dns_service.h>
 #include <asiolink/io_service.h>
 #include <asiolink/io_service.h>
-#include <asiolink/tcp_server.h>
-#include <asiolink/udp_server.h>
+#include <tcp_server.h>
+#include <udp_server.h>
 
 #include <log/dummylog.h>
 
@@ -36,9 +36,11 @@
 
 using isc::log::dlog;
 
-namespace asiolink {
+using namespace isc::asiolink;
+
+namespace isc {
+namespace asiodns {
 
-class SimpleCallback;
 class DNSLookup;
 class DNSAnswer;
 
@@ -195,6 +197,5 @@ DNSService::clearServers() {
     impl_->servers_.clear();
 }
 
-
-
-} // namespace asiolink
+} // namespace asiodns
+} // namespace isc

+ 11 - 9
src/lib/asiolink/dns_service.h

@@ -18,10 +18,11 @@
 #include <resolve/resolver_interface.h>
 
 #include <asiolink/io_service.h>
+#include <asiolink/simple_callback.h>
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
-class SimpleCallback;
 class DNSLookup;
 class DNSAnswer;
 class DNSServiceImpl;
@@ -54,8 +55,8 @@ public:
     /// \param checkin Provider for cc-channel events (see \c SimpleCallback)
     /// \param lookup The lookup provider (see \c DNSLookup)
     /// \param answer The answer provider (see \c DNSAnswer)
-    DNSService(IOService& io_service, const char& port,
-               const char& address, SimpleCallback* checkin,
+    DNSService(asiolink::IOService& io_service, const char& port,
+               const char& address, isc::asiolink::SimpleCallback* checkin,
                DNSLookup* lookup, DNSAnswer* answer);
     /// \brief The constructor with a specific port on which the services
     /// listen on.
@@ -71,14 +72,14 @@ public:
     /// \param checkin Provider for cc-channel events (see \c SimpleCallback)
     /// \param lookup The lookup provider (see \c DNSLookup)
     /// \param answer The answer provider (see \c DNSAnswer)
-    DNSService(IOService& io_service, const char& port,
+    DNSService(asiolink::IOService& io_service, const char& port,
                const bool use_ipv4, const bool use_ipv6,
-               SimpleCallback* checkin, DNSLookup* lookup,
+               isc::asiolink::SimpleCallback* checkin, DNSLookup* lookup,
                DNSAnswer* answer);
     /// \brief The constructor without any servers.
     ///
     /// Use addServer() to add some servers.
-    DNSService(IOService& io_service, SimpleCallback* checkin,
+    DNSService(asiolink::IOService& io_service, isc::asiolink::SimpleCallback* checkin,
                DNSLookup* lookup, DNSAnswer* answer);
     /// \brief The destructor.
     ~DNSService();
@@ -105,8 +106,9 @@ public:
 
 private:
     DNSServiceImpl* impl_;
-    IOService& io_service_;
+    asiolink::IOService& io_service_;
 };
 
-}      // namespace asiolink
+} // namespace asiodns
+} // namespace isc
 #endif // __ASIOLINK_DNS_SERVICE_H

+ 33 - 31
src/lib/asiolink/io_fetch.cc

@@ -14,45 +14,46 @@
 
 #include <config.h>
 
-#include <unistd.h>             // for some IPC/network system calls
-#include <sys/socket.h>
 #include <netinet/in.h>
+#include <stdint.h>
+#include <sys/socket.h>
+#include <unistd.h>             // for some IPC/network system calls
 
 #include <boost/bind.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
 
-#include <dns/message.h>
-#include <dns/messagerenderer.h>
-#include <dns/opcode.h>
-#include <dns/rcode.h>
-#include <log/logger.h>
-
-#include <asiolink/qid_gen.h>
-
 #include <asio.hpp>
 #include <asio/deadline_timer.hpp>
 
-#include <asiolink/asiodef.h>
 #include <asiolink/io_address.h>
 #include <asiolink/io_asio_socket.h>
 #include <asiolink/io_endpoint.h>
-#include <asiolink/io_fetch.h>
 #include <asiolink/io_service.h>
 #include <asiolink/tcp_endpoint.h>
 #include <asiolink/tcp_socket.h>
 #include <asiolink/udp_endpoint.h>
 #include <asiolink/udp_socket.h>
-#include <asiolink/qid_gen.h>
 
-#include <stdint.h>
+#include <dns/message.h>
+#include <dns/messagerenderer.h>
+#include <dns/opcode.h>
+#include <dns/rcode.h>
+#include <log/logger.h>
+
+#include <asiodns/asiodef.h>
+#include <asiodns/io_fetch.h>
+#include <asiodns/qid_gen.h>
+
 
 using namespace asio;
+using namespace isc::asiolink;
 using namespace isc::dns;
 using namespace isc::log;
 using namespace std;
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 /// Use the ASIO logger
 
@@ -138,7 +139,6 @@ struct IOFetchData {
         question(query),
         msgbuf(new isc::dns::OutputBuffer(512)),
         received(buff),
-
         callback(cb),
         timer(service.get_io_service()),
         protocol(proto),
@@ -148,7 +148,7 @@ struct IOFetchData {
         stopped(false),
         timeout(wait),
         packet(false),
-        origin(ASIO_UNKORIGIN),
+        origin(ASIODNS_UNKORIGIN),
         staging(),
         qid(QidGenerator::getInstance().generateQid())
     {}
@@ -182,7 +182,8 @@ IOFetch::IOFetch(Protocol protocol, IOService& service,
     OutputBufferPtr& buff, Callback* cb, int wait)
     :
     data_(new IOFetchData(protocol, service,
-          isc::dns::Question(isc::dns::Name("dummy.example.org"), isc::dns::RRClass::IN(), isc::dns::RRType::A()),
+          isc::dns::Question(isc::dns::Name("dummy.example.org"),
+                             isc::dns::RRClass::IN(), isc::dns::RRType::A()),
           address, port, buff, cb, wait))
 {
     data_->msgbuf = outpkt;
@@ -244,7 +245,7 @@ IOFetch::operator()(asio::error_code ec, size_t length) {
 
         // Open a connection to the target system.  For speed, if the operation
         // is synchronous (i.e. UDP operation) we bypass the yield.
-        data_->origin = ASIO_OPENSOCK;
+        data_->origin = ASIODNS_OPENSOCK;
         if (data_->socket->isOpenSynchronous()) {
             data_->socket->open(data_->remote_snd.get(), *this);
         } else {
@@ -254,7 +255,7 @@ IOFetch::operator()(asio::error_code ec, size_t length) {
         do {
             // Begin an asynchronous send, and then yield.  When the send completes,
             // we will resume immediately after this point.
-            data_->origin = ASIO_SENDSOCK;
+            data_->origin = ASIODNS_SENDSOCK;
             CORO_YIELD data_->socket->asyncSend(data_->msgbuf->getData(),
                 data_->msgbuf->getLength(), data_->remote_snd.get(), *this);
     
@@ -277,7 +278,7 @@ IOFetch::operator()(asio::error_code ec, size_t length) {
             // received all the data before copying it back to the user's buffer.
             // And we want to minimise the amount of copying...
     
-            data_->origin = ASIO_RECVSOCK;
+            data_->origin = ASIODNS_RECVSOCK;
             data_->cumulative = 0;          // No data yet received
             data_->offset = 0;              // First data into start of buffer
             data_->received->clear();       // Clear the receive buffer
@@ -293,7 +294,7 @@ IOFetch::operator()(asio::error_code ec, size_t length) {
 
         // Finished with this socket, so close it.  This will not generate an
         // I/O error, but reset the origin to unknown in case we change this.
-        data_->origin = ASIO_UNKORIGIN;
+        data_->origin = ASIODNS_UNKORIGIN;
         data_->socket->close();
 
         /// We are done
@@ -336,7 +337,7 @@ IOFetch::stop(Result result) {
         switch (result) {
             case TIME_OUT:
                 if (logger.isDebugEnabled(1)) {
-                    logger.debug(20, ASIO_RECVTMO,
+                    logger.debug(20, ASIODNS_RECVTMO,
                                  data_->remote_snd->getAddress().toText().c_str(),
                                  static_cast<int>(data_->remote_snd->getPort()));
                 }
@@ -344,7 +345,7 @@ IOFetch::stop(Result result) {
 
             case SUCCESS:
                 if (logger.isDebugEnabled(50)) {
-                    logger.debug(30, ASIO_FETCHCOMP,
+                    logger.debug(30, ASIODNS_FETCHCOMP,
                                  data_->remote_rcv->getAddress().toText().c_str(),
                                  static_cast<int>(data_->remote_rcv->getPort()));
                 }
@@ -354,13 +355,13 @@ IOFetch::stop(Result result) {
                 // Fetch has been stopped for some other reason.  This is
                 // allowed but as it is unusual it is logged, but with a lower
                 // debug level than a timeout (which is totally normal).
-                logger.debug(1, ASIO_FETCHSTOP,
+                logger.debug(1, ASIODNS_FETCHSTOP,
                              data_->remote_snd->getAddress().toText().c_str(),
                              static_cast<int>(data_->remote_snd->getPort()));
                 break;
 
             default:
-                logger.error(ASIO_UNKRESULT, static_cast<int>(result),
+                logger.error(ASIODNS_UNKRESULT, static_cast<int>(result),
                              data_->remote_snd->getAddress().toText().c_str(),
                              static_cast<int>(data_->remote_snd->getPort()));
         }
@@ -384,10 +385,10 @@ IOFetch::stop(Result result) {
 void IOFetch::logIOFailure(asio::error_code ec) {
 
     // Should only get here with a known error code.
-    assert((data_->origin == ASIO_OPENSOCK) ||
-           (data_->origin == ASIO_SENDSOCK) ||
-           (data_->origin == ASIO_RECVSOCK) ||
-           (data_->origin == ASIO_UNKORIGIN));
+    assert((data_->origin == ASIODNS_OPENSOCK) ||
+           (data_->origin == ASIODNS_SENDSOCK) ||
+           (data_->origin == ASIODNS_RECVSOCK) ||
+           (data_->origin == ASIODNS_UNKORIGIN));
 
     static const char* PROTOCOL[2] = {"TCP", "UDP"};
     logger.error(data_->origin,
@@ -398,5 +399,6 @@ void IOFetch::logIOFailure(asio::error_code ec) {
                  static_cast<int>(data_->remote_snd->getPort()));
 }
 
-} // namespace asiolink
+} // namespace asiodns
+} // namespace isc {
 

+ 12 - 8
src/lib/asiolink/io_fetch.h

@@ -24,16 +24,17 @@
 #include <coroutine.h>
 
 #include <asio/error_code.hpp>
+#include <asiolink/io_address.h>
+#include <asiolink/io_service.h>
 
 #include <dns/buffer.h>
 #include <dns/question.h>
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 // Forward declarations
-class IOAddress;
 class IOFetchData;
-class IOService;
 
 /// \brief Upstream Fetch Processing
 ///
@@ -129,8 +130,9 @@ public:
     ///        and deleting it if necessary.
     /// \param wait Timeout for the fetch (in ms).  The default value of
     ///        -1 indicates no timeout.
-    IOFetch(Protocol protocol, IOService& service,
-        const isc::dns::Question& question, const IOAddress& address,
+    IOFetch(Protocol protocol, isc::asiolink::IOService& service,
+        const isc::dns::Question& question,
+        const isc::asiolink::IOAddress& address,
         uint16_t port, isc::dns::OutputBufferPtr& buff, Callback* cb,
         int wait = -1);
 
@@ -153,8 +155,9 @@ public:
     /// (default = 53)
     /// \param wait Timeout for the fetch (in ms).  The default value of
     ///     -1 indicates no timeout.
-    IOFetch(Protocol protocol, IOService& service,
-        isc::dns::OutputBufferPtr& outpkt, const IOAddress& address,
+    IOFetch(Protocol protocol, isc::asiolink::IOService& service,
+        isc::dns::OutputBufferPtr& outpkt,
+        const isc::asiolink::IOAddress& address,
         uint16_t port, isc::dns::OutputBufferPtr& buff, Callback* cb,
         int wait = -1);
 
@@ -195,6 +198,7 @@ private:
 
 };
 
-} // namespace asiolink
+} // namespace asiodns
+} // namespace isc
 
 #endif // __IO_FETCH_H

+ 6 - 4
src/lib/asiolink/qid_gen.cc

@@ -18,15 +18,16 @@
 // (and other parts where we need randomness, perhaps another thing
 // for a general libutil?)
 
-#include <asiolink/qid_gen.h>
+#include <asiodns/qid_gen.h>
 
 #include <sys/time.h>
 
 namespace {
-    asiolink::QidGenerator qid_generator_instance;
+    isc::asiodns::QidGenerator qid_generator_instance;
 }
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 QidGenerator&
 QidGenerator::getInstance() {
@@ -51,4 +52,5 @@ QidGenerator::generateQid() {
     return (vgen_());
 }
 
-} // namespace asiolink
+} // namespace asiodns
+} // namespace isc

+ 4 - 2
src/lib/asiolink/qid_gen.h

@@ -27,7 +27,8 @@
 #include <boost/random/variate_generator.hpp>
 
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 /// This class generates Qids for outgoing queries
 ///
@@ -80,6 +81,7 @@ private:
 };
 
 
-} // namespace asiolink
+} // namespace asiodns
+} // namespace isc
 
 #endif // __QID_GEN_H

+ 6 - 4
src/lib/asiolink/tcp_server.cc

@@ -27,7 +27,7 @@
 #include <asiolink/dummy_io_cb.h>
 #include <asiolink/tcp_endpoint.h>
 #include <asiolink/tcp_socket.h>
-#include <asiolink/tcp_server.h>
+#include <tcp_server.h>
 
 
 using namespace asio;
@@ -36,8 +36,10 @@ using asio::ip::tcp;
 
 using namespace std;
 using namespace isc::dns;
+using namespace isc::asiolink;
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 /// The following functions implement the \c TCPServer class.
 ///
@@ -235,5 +237,5 @@ TCPServer::resume(const bool done) {
     io_.post(*this);
 }
 
-} // namespace asiolink
-
+} // namespace asiodns
+} // namespace isc

+ 12 - 8
src/lib/asiolink/tcp_server.h

@@ -24,9 +24,12 @@
 
 #include <asiolink/asiolink.h>
 #include <coroutine.h>
+#include "dns_server.h"
+#include "dns_lookup.h"
+#include "dns_answer.h"
 
-
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 /// \brief A TCP-specific \c DNSServer object.
 ///
@@ -36,7 +39,7 @@ class TCPServer : public virtual DNSServer, public virtual coroutine {
 public:
     explicit TCPServer(asio::io_service& io_service,
                        const asio::ip::address& addr, const uint16_t port, 
-                       const SimpleCallback* checkin = NULL,
+                       const isc::asiolink::SimpleCallback* checkin = NULL,
                        const DNSLookup* lookup = NULL,
                        const DNSAnswer* answer = NULL);
 
@@ -95,7 +98,7 @@ private:
 
     // \c IOMessage and \c Message objects to be passed to the
     // DNS lookup and answer providers
-    boost::shared_ptr<asiolink::IOMessage> io_message_;
+    boost::shared_ptr<isc::asiolink::IOMessage> io_message_;
     isc::dns::MessagePtr query_message_;
     isc::dns::MessagePtr answer_message_;
 
@@ -108,13 +111,14 @@ private:
     bool done_;
 
     // Callback functions provided by the caller
-    const SimpleCallback* checkin_callback_;
+    const isc::asiolink::SimpleCallback* checkin_callback_;
     const DNSLookup* lookup_callback_;
     const DNSAnswer* answer_callback_;
 
-    boost::shared_ptr<IOEndpoint> peer_;
-    boost::shared_ptr<IOSocket> iosock_;
+    boost::shared_ptr<isc::asiolink::IOEndpoint> peer_;
+    boost::shared_ptr<isc::asiolink::IOSocket> iosock_;
 };
 
-}      // namespace asiolink
+} // namespace asiodns
+} // namespace isc
 #endif // __TCP_SERVER_H

+ 50 - 0
src/lib/asiodns/tests/Makefile.am

@@ -0,0 +1,50 @@
+AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += -I$(top_builddir)/src/lib/dns -I$(top_srcdir)/src/bin
+AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc
+AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\"
+
+AM_CXXFLAGS = $(B10_CXXFLAGS)
+
+if USE_STATIC_LINK
+AM_LDFLAGS = -static
+endif
+
+CLEANFILES = *.gcno *.gcda
+
+TESTS =
+if HAVE_GTEST
+TESTS += run_unittests
+run_unittests_SOURCES  = run_unittests.cc
+run_unittests_SOURCES += $(top_srcdir)/src/lib/dns/tests/unittest_util.h
+run_unittests_SOURCES += $(top_srcdir)/src/lib/dns/tests/unittest_util.cc
+run_unittests_SOURCES += io_service_unittest.cc
+run_unittests_SOURCES += dns_server_unittest.cc
+run_unittests_SOURCES += io_fetch_unittest.cc
+run_unittests_SOURCES += qid_gen_unittest.cc
+
+run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+
+run_unittests_LDADD  = $(GTEST_LDADD)
+run_unittests_LDADD += $(SQLITE_LIBS)
+run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
+run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
+run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
+run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
+run_unittests_LDADD += $(top_builddir)/src/lib/asiodns/libasiodns.la
+
+run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) 
+
+# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
+# B10_CXXFLAGS)
+run_unittests_CXXFLAGS = $(AM_CXXFLAGS)
+if USE_GXX
+run_unittests_CXXFLAGS += -Wno-unused-parameter
+endif
+if USE_CLANGPP
+# Same for clang++, but we need to turn off -Werror completely.
+run_unittests_CXXFLAGS += -Wno-error
+endif
+endif
+
+noinst_PROGRAMS = $(TESTS)

+ 6 - 5
src/lib/asiolink/tests/dns_server_unittest.cc

@@ -18,10 +18,10 @@
 #include <asio.hpp>
 #include <asiolink/io_endpoint.h>
 #include <asiolink/io_error.h>
-#include <asiolink/udp_server.h>
-#include <asiolink/tcp_server.h>
-#include <asiolink/dns_answer.h>
-#include <asiolink/dns_lookup.h>
+#include <asiodns/udp_server.h>
+#include <asiodns/tcp_server.h>
+#include <asiodns/dns_answer.h>
+#include <asiodns/dns_lookup.h>
 #include <string>
 #include <csignal>
 #include <unistd.h> //for alarm
@@ -65,7 +65,8 @@
 /// involved so the message sending between client and server is plain text
 /// And the valid checker, question lookup and answer composition are dummy.
 
-using namespace asiolink;
+using namespace isc::asiolink;
+using namespace isc::asiodns;
 using namespace asio;
 namespace {
 static const std::string server_ip = "127.0.0.1";

+ 6 - 3
src/lib/asiolink/tests/io_fetch_unittest.cc

@@ -37,15 +37,17 @@
 #include <asiolink/asiolink_utilities.h>
 #include <asiolink/io_address.h>
 #include <asiolink/io_endpoint.h>
-#include <asiolink/io_fetch.h>
 #include <asiolink/io_service.h>
+#include <asiodns/io_fetch.h>
 
 using namespace asio;
 using namespace isc::dns;
 using namespace asio::ip;
 using namespace std;
+using namespace isc::asiolink;
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 const asio::ip::address TEST_HOST(asio::ip::address::from_string("127.0.0.1"));
 const uint16_t TEST_PORT(5301);
@@ -720,4 +722,5 @@ TEST_F(IOFetchTest, TcpSendReceive8192ShortSend) {
 }
 
 
-} // namespace asiolink
+} // namespace asiodns
+} // namespace isc

+ 3 - 1
src/lib/asiolink/tests/io_service_unittest.cc

@@ -17,8 +17,10 @@
 
 #include <asio.hpp>
 #include <asiolink/asiolink.h>
+#include <asiodns/asiodns.h>
 
-using namespace asiolink;
+using namespace isc::asiolink;
+using namespace isc::asiodns;
 
 const char* const TEST_SERVER_PORT = "53535";
 const char* const TEST_CLIENT_PORT = "53536";

+ 4 - 4
src/lib/asiolink/tests/qid_gen_unittest.cc

@@ -32,15 +32,15 @@
 
 #include <gtest/gtest.h>
 
-#include <asiolink/qid_gen.h>
+#include <asiodns/qid_gen.h>
 #include <dns/message.h>
 
 // Tests the operation of the Qid generator
 
 // Check that getInstance returns a singleton
 TEST(QidGenerator, singleton) {
-    asiolink::QidGenerator& g1 = asiolink::QidGenerator::getInstance();
-    asiolink::QidGenerator& g2 = asiolink::QidGenerator::getInstance();
+    isc::asiodns::QidGenerator& g1 = isc::asiodns::QidGenerator::getInstance();
+    isc::asiodns::QidGenerator& g2 = isc::asiodns::QidGenerator::getInstance();
 
     EXPECT_TRUE(&g1 == &g2);
 }
@@ -51,7 +51,7 @@ TEST(QidGenerator, generate) {
     // test (http://xkcd.com/221/), and check if three consecutive
     // generates are not all the same.
     isc::dns::qid_t one, two, three;
-    asiolink::QidGenerator& gen = asiolink::QidGenerator::getInstance();
+    isc::asiodns::QidGenerator& gen = isc::asiodns::QidGenerator::getInstance();
     one = gen.generateQid();
     two = gen.generateQid();
     three = gen.generateQid();

+ 28 - 0
src/lib/asiodns/tests/run_unittests.cc

@@ -0,0 +1,28 @@
+// 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.
+
+#include <gtest/gtest.h>
+
+#include <log/root_logger_name.h>
+#include <dns/tests/unittest_util.h>
+
+int
+main(int argc, char* argv[])
+{
+    ::testing::InitGoogleTest(&argc, argv);         // Initialize Google test
+    isc::log::setRootLoggerName("unittest");        // Set a root logger name
+    isc::UnitTestUtil::addDataPath(TEST_DATA_DIR);  // Add location of test data
+
+    return (RUN_ALL_TESTS());
+}

+ 6 - 3
src/lib/asiolink/udp_server.cc

@@ -27,8 +27,8 @@
 #include <asio/error.hpp>
 #include <asiolink/dummy_io_cb.h>
 #include <asiolink/udp_endpoint.h>
-#include <asiolink/udp_server.h>
 #include <asiolink/udp_socket.h>
+#include "udp_server.h"
 
 #include <dns/opcode.h>
 
@@ -38,8 +38,10 @@ using isc::log::dlog;
 
 using namespace std;
 using namespace isc::dns;
+using namespace isc::asiolink;
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 /*
  * Some of the member variables here are shared_ptrs and some are
@@ -318,4 +320,5 @@ UDPServer::hasAnswer() {
     return (data_->done_);
 }
 
-} // namespace asiolink
+} // namespace asiodns
+} // namespace isc

+ 8 - 6
src/lib/asiolink/udp_server.h

@@ -19,14 +19,15 @@
 #error "asio.hpp must be included before including this, see asiolink.h as to why"
 #endif
 
-#include <asiolink/dns_server.h>
 #include <asiolink/simple_callback.h>
-#include <asiolink/dns_lookup.h>
-#include <asiolink/dns_answer.h>
+#include <asiodns/dns_answer.h>
+#include <asiodns/dns_lookup.h>
+#include <asiodns/dns_server.h>
 
 #include <coroutine.h>
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 //
 // Asynchronous UDP server coroutine
@@ -47,7 +48,7 @@ public:
     /// \param answer the callbackprovider for DNS answer events
     explicit UDPServer(asio::io_service& io_service,
                        const asio::ip::address& addr, const uint16_t port,
-                       SimpleCallback* checkin = NULL,
+                       isc::asiolink::SimpleCallback* checkin = NULL,
                        DNSLookup* lookup = NULL,
                        DNSAnswer* answer = NULL);
 
@@ -102,5 +103,6 @@ private:
     boost::shared_ptr<Data> data_;
 };
 
-}      // namespace asiolink
+} // namespace asiodns
+} // namespace isc
 #endif // __UDP_SERVER_H

+ 0 - 11
src/lib/asiolink/Makefile.am

@@ -14,32 +14,21 @@ CLEANFILES = *.gcno *.gcda
 lib_LTLIBRARIES = libasiolink.la
 libasiolink_la_SOURCES  = asiolink.h
 libasiolink_la_SOURCES += asiolink_utilities.h
-libasiolink_la_SOURCES += asiodef.cc asiodef.h
-libasiolink_la_SOURCES += dns_answer.h
-libasiolink_la_SOURCES += dns_lookup.h
-libasiolink_la_SOURCES += dns_server.h
-libasiolink_la_SOURCES += dns_service.cc dns_service.h
 libasiolink_la_SOURCES += dummy_io_cb.h
 libasiolink_la_SOURCES += interval_timer.cc interval_timer.h
 libasiolink_la_SOURCES += io_address.cc io_address.h
 libasiolink_la_SOURCES += io_asio_socket.h
 libasiolink_la_SOURCES += io_endpoint.cc io_endpoint.h
 libasiolink_la_SOURCES += io_error.h
-libasiolink_la_SOURCES += io_fetch.cc io_fetch.h
 libasiolink_la_SOURCES += io_message.h
-libasiolink_la_SOURCES += qid_gen.cc qid_gen.h
 libasiolink_la_SOURCES += io_service.h io_service.cc
 libasiolink_la_SOURCES += io_socket.h io_socket.cc
 libasiolink_la_SOURCES += simple_callback.h
 libasiolink_la_SOURCES += tcp_endpoint.h
-libasiolink_la_SOURCES += tcp_server.cc tcp_server.h
 libasiolink_la_SOURCES += tcp_socket.h
 libasiolink_la_SOURCES += udp_endpoint.h
-libasiolink_la_SOURCES += udp_server.cc udp_server.h
 libasiolink_la_SOURCES += udp_socket.h
 
-EXTRA_DIST = asiodef.msg
-
 # Note: the ordering matters: -Wno-... must follow -Wextra (defined in
 # B10_CXXFLAGS)
 libasiolink_la_CXXFLAGS = $(AM_CXXFLAGS)

+ 0 - 160
src/lib/asiolink/README

@@ -16,167 +16,7 @@ including:
     them in only one place allows us to relax strictness here, while
     leaving it in place elsewhere.
 
-Currently, the asiolink library only supports DNS servers (i.e., b10-auth
-and b10-resolver).  The plan is to make it more generic and allow it to
-support other modules as well.
-
 Some of the classes defined here--for example, IOSocket, IOEndpoint,
 and IOAddress--are to be used by BIND 10 modules as wrappers around
 ASIO-specific classes.
 
-Other classes implement the DNS protocol on behalf of BIND 10 modules.
-
-These DNS server and client routines are written using the "stackless
-coroutine" pattern invented by Chris Kohlhoff and described at
-http://blog.think-async.com/2010/03/potted-guide-to-stackless-coroutines.html.
-This is intended to simplify development a bit, since it allows the
-routines to be written in a straightfowrard step-step-step fashion rather
-than as a complex chain of separate handler functions.
-
-Coroutine objects (i.e., UDPServer, TCPServer and IOFetch) are objects
-with reenterable operator() members.  When an instance of one of these
-classes is called as a function, it resumes at the position where it left
-off.  Thus, a UDPServer can issue an asynchronous I/O call and specify
-itself as the handler object; when the call completes, the UDPServer
-carries on at the same position.  As a result, the code can look as
-if it were using synchronous, not asynchronous, I/O, providing some of
-the benefit of threading but with minimal switching overhead.
-
-So, in simplified form, the behavior of a DNS Server is:
-
-  REENTER:
-    while true:
-      YIELD packet = read_packet
-      FORK
-      if not parent:
-        break
-
-    # This callback informs the caller that a packet has arrived, and
-    # gives it a chance to update configuration, etc
-    SimpleCallback(packet)
-    YIELD answer = DNSLookup(packet, this)
-    response = DNSAnswer(answer)
-    YIELD send(response)
-
-At each "YIELD" point, the coroutine initiates an asynchronous operation,
-then pauses and turns over control to some other task on the ASIO service
-queue.  When the operation completes, the coroutine resumes.
-
-DNSLookup, DNSAnswer and SimpleCallback define callback methods
-used by a DNS Server to communicate with the module that called it.
-They are abstract-only classes whose concrete implementations
-are supplied by the calling module.
-
-The DNSLookup callback always runs asynchronously.  Concrete
-implementations must be sure to call the server's "resume" method when
-it is finished.
-
-In an authoritative server, the DNSLookup implementation would examine
-the query, look up the answer, then call "resume".  (See the diagram
-in doc/auth_process.jpg.)
-
-In a recursive server, the DNSLookup impelemtation would initiate a
-DNSQuery, which in turn would be responsible for calling the server's
-"resume" method.  (See the diagram in doc/recursive_process.jpg.)
-
-A DNSQuery object is intended to handle resolution of a query over
-the network when the local authoritative data sources or cache are not
-sufficient.  The plan is that it will make use of subsidiary DNSFetch
-calls to get data from particular authoritative servers, and when it has
-gotten a complete answer, it calls "resume".
-
-In current form, however, DNSQuery is much simpler; it forwards queries
-to a single upstream resolver and passes the answers back to the client.
-It is constructed with the address of the forward server.  Queries are
-initiated with the question to ask the forward server, a buffer into
-which to write the answer, and a pointer to the coroutine to be resumed
-when the answer has arrived.  In simplified form, the DNSQuery routine is:
-
-  REENTER:
-    render the question into a wire-format query packet
-    YIELD send(query)
-    YIELD response = read_packet
-    server->resume
-
-Currently, DNSQuery is only implemented for UDP queries.  In future work
-it will be necessary to write code to fall back to TCP when circumstances
-require it.
-
-
-Upstream Fetches
-================
-Upstream fetches (queries by the resolver on behalf of a client) are made
-using a slightly-modified version of the pattern described above.
-
-Sockets
--------
-First, it will be useful to understand the class hierarchy used in the
-fetch logic:
-
-        IOSocket
-           |
-      IOAsioSocket
-           |
-     +-----+-----+                
-     |           |
-UDPSocket    TCPSocket
-
-IOSocket is a wrapper class for a socket and is used by the authoritative
-server code.  It is an abstract base class, providing little more that the ability to hold the socket and to return the protocol in use.
-
-Built on this is IOAsioSocket, which adds the open, close, asyncSend and
-asyncReceive methods.  This is a template class, which takes as template
-argument the class of the object that will be used as the callback when the
-asynchronous operation completes. This object can be of any type, but must
-include an operator() method with the signature:
-
-   operator()(asio::error_code ec, size_t length)
-
-... the two arguments being the status of the completed I/O operation and
-the number of bytes transferred. (In the case of the open method, the second
-argument will be zero.)
-
-Finally, the TCPSocket and UDPSocket classes provide the body of the
-asynchronous operations.
-
-Fetch Sequence
---------------
-The fetch is implemented by the IOFetch class, which takes as argument the
-protocol to use.  The sequence is:
-
-  REENTER:
-    render the question into a wire-format query packet
-    open()                           // Open socket and optionally connect
-    if (! synchronous) {
-        YIELD;
-    }
-    YIELD asyncSend(query)           // Send query 
-    do {
-        YIELD asyncReceive(response) // Read response
-    } while (! complete(response))
-    close()                          // Drop connection and close socket
-    server->resume
-
-The open() method opens a socket for use.  On TCP, it also makes a
-connection to the remote end.  So under UDP the operation will complete
-immediately, but under TCP it could take a long time.  One solution would be
-for the open operation to post an event to the I/O queue; then both cases
-could be regarded as being equivalent, with the completion being signalled
-by the posting of the completion event.  However UDP is the most common case
-and that would involve extra overhead.  So the open() returns a status
-indicating whether the operation completed asynchronously.  If it did, the
-code yields back to the coroutine; if not the yield is bypassed.
-
-The asynchronous send is straightforward, invoking the underlying ASIO
-function.  (Note that the address/port is supplied to both the open() and
-asyncSend() methods - it is used by the TCPSocket in open() and by the
-UDPSocket in asyncSend().)
-
-The asyncReceive() method issues an asynchronous read and waits for completion.
-The fetch object keeps track of the amount of data received so far and when
-the receive completes it calls a method on the socket to determine if the
-entire message has been received.  (This will always be the case for UDP.  On
-TCP though, the message is preceded by a count field as several reads may be
-required to read all the data.)  The fetch loops until all the data is read.
-
-Finally, the socket is closed and the server called to resume operation.

+ 0 - 21
src/lib/asiolink/asiodef.h

@@ -1,21 +0,0 @@
-// File created from asiodef.msg on Mon Feb 28 17:15:30 2011
-
-#ifndef __ASIODEF_H
-#define __ASIODEF_H
-
-#include <log/message_types.h>
-
-namespace asiolink {
-
-extern const isc::log::MessageID ASIO_FETCHCOMP;
-extern const isc::log::MessageID ASIO_FETCHSTOP;
-extern const isc::log::MessageID ASIO_OPENSOCK;
-extern const isc::log::MessageID ASIO_RECVSOCK;
-extern const isc::log::MessageID ASIO_RECVTMO;
-extern const isc::log::MessageID ASIO_SENDSOCK;
-extern const isc::log::MessageID ASIO_UNKORIGIN;
-extern const isc::log::MessageID ASIO_UNKRESULT;
-
-} // namespace asiolink
-
-#endif // __ASIODEF_H

+ 0 - 9
src/lib/asiolink/asiolink.h

@@ -20,10 +20,6 @@
 // See the description of the namespace below.
 
 #include <asiolink/io_service.h>
-#include <asiolink/dns_service.h>
-#include <asiolink/dns_server.h>
-#include <asiolink/dns_lookup.h>
-#include <asiolink/dns_answer.h>
 #include <asiolink/simple_callback.h>
 #include <asiolink/interval_timer.h>
 
@@ -62,11 +58,6 @@
 /// this module.  The resulting interfaces are thus straightforward mapping
 /// to the ASIO counterparts.
 ///
-/// Notes to developers:
-/// Currently the wrapper interface is fairly specific to use by a
-/// DNS server, i.e., b10-auth or b10-resolver.  But the plan is to
-/// generalize it and have other modules use it as well.
-///
 /// One obvious drawback of this approach is performance overhead
 /// due to the additional layer.  We should eventually evaluate the cost
 /// of the wrapper abstraction in benchmark tests. Another drawback is

+ 2 - 0
src/lib/asiolink/asiolink_utilities.h

@@ -17,6 +17,7 @@
 
 #include <cstddef>
 
+namespace isc {
 namespace asiolink {
 
 /// \brief Read Unsigned 16-Bit Integer from Buffer
@@ -57,5 +58,6 @@ writeUint16(uint16_t value, void* buffer) {
 }
 
 } // namespace asiolink
+} // namespace isc
 
 #endif // __ASIOLINK_UTILITIES_H

+ 2 - 0
src/lib/asiolink/dummy_io_cb.h

@@ -20,6 +20,7 @@
 #include <asio/error.hpp>
 #include <asio/error_code.hpp>
 
+namespace isc {
 namespace asiolink {
 
 /// \brief Asynchronous I/O Completion Callback
@@ -55,5 +56,6 @@ public:
 };
 
 } // namespace asiolink
+} // namespace isc
 
 #endif // __DUMMY_IO_CB_H

+ 3 - 1
src/lib/asiolink/interval_timer.cc

@@ -26,6 +26,7 @@
 #include <asiolink/interval_timer.h>
 #include <asiolink/io_service.h>
 
+namespace isc {
 namespace asiolink {
 
 class IntervalTimerImpl {
@@ -133,4 +134,5 @@ IntervalTimer::getInterval() const {
     return (impl_->getInterval());
 }
 
-}
+} // namespace asiolink
+} // namespace isc

+ 3 - 1
src/lib/asiolink/interval_timer.h

@@ -19,6 +19,7 @@
 
 #include <asiolink/io_service.h>
 
+namespace isc {
 namespace asiolink {
 
 struct IntervalTimerImpl;
@@ -129,5 +130,6 @@ private:
     IntervalTimerImpl* impl_;
 };
 
-}      // namespace asiolink
+} // namespace asiolink
+} // namespace isc
 #endif // __ASIOLINK_INTERVAL_TIMER_H

+ 3 - 1
src/lib/asiolink/io_address.cc

@@ -31,6 +31,7 @@ using asio::ip::tcp;
 
 using namespace std;
 
+namespace isc {
 namespace asiolink {
 
 // XXX: we cannot simply construct the address in the initialization list,
@@ -62,4 +63,5 @@ IOAddress::getFamily() const {
     }
 }
 
-}
+} // namespace asiolink
+} // namespace isc

+ 3 - 1
src/lib/asiolink/io_address.h

@@ -26,6 +26,7 @@
 
 #include <exceptions/exceptions.h>
 
+namespace isc {
 namespace asiolink {
 
 /// \brief The \c IOAddress class represents an IP addresses (version
@@ -119,5 +120,6 @@ private:
     asio::ip::address asio_address_;
 };
 
-}      // asiolink
+} // namespace asiolink
+} // namespace isc
 #endif // __IO_ADDRESS_H

+ 2 - 1
src/lib/asiolink/io_asio_socket.h

@@ -31,7 +31,7 @@
 #include <asiolink/io_error.h>
 #include <asiolink/io_socket.h>
 
-
+namespace isc {
 namespace asiolink {
 
 /// \brief Socket not open
@@ -395,5 +395,6 @@ private:
 };
 
 } // namespace asiolink
+} // namespace isc
 
 #endif // __IO_ASIO_SOCKET_H

+ 3 - 1
src/lib/asiolink/io_endpoint.cc

@@ -28,6 +28,7 @@
 
 using namespace std;
 
+namespace isc {
 namespace asiolink {
 
 const IOEndpoint*
@@ -57,4 +58,5 @@ IOEndpoint::operator!=(const IOEndpoint& other) const {
     return (!operator==(other));
 }
 
-}
+} // namespace asiolink
+} // namespace isc

+ 3 - 1
src/lib/asiolink/io_endpoint.h

@@ -26,6 +26,7 @@
 #include <exceptions/exceptions.h>
 #include <asiolink/io_address.h>
 
+namespace isc {
 namespace asiolink {
 
 /// \brief The \c IOEndpoint class is an abstract base class to represent
@@ -117,5 +118,6 @@ public:
                                     const unsigned short port);
 };
 
-}      // asiolink
+} // namespace asiolink
+} // namespace isc
 #endif // __IO_ENDPOINT_H

+ 3 - 1
src/lib/asiolink/io_error.h

@@ -18,6 +18,7 @@
 
 #include <exceptions/exceptions.h>
 
+namespace isc {
 namespace asiolink {
 
 /// \brief An exception that is thrown if an error occurs within the IO
@@ -30,6 +31,7 @@ public:
 };
 
 
-}      // asiolink
+} // namespace asiolink
+} // namespace isc
 
 #endif // __IO_ERROR_H

+ 3 - 1
src/lib/asiolink/io_message.h

@@ -28,6 +28,7 @@
 #include <asiolink/io_endpoint.h>
 #include <asiolink/io_socket.h>
 
+namespace isc {
 namespace asiolink {
 
 /// \brief The \c IOMessage class encapsulates an incoming message received
@@ -96,5 +97,6 @@ private:
 };
 
 
-}      // asiolink
+} // namespace asiolink
+} // namespace isc
 #endif // __IO_MESSAGE_H

+ 3 - 1
src/lib/asiolink/io_service.cc

@@ -21,6 +21,7 @@
 #include <asio.hpp>
 #include <asiolink/io_service.h>
 
+namespace isc {
 namespace asiolink {
 
 class IOServiceImpl {
@@ -95,4 +96,5 @@ IOService::get_io_service() {
     return (io_impl_->get_io_service());
 }
 
-} // namepsace asiolink
+} // namespace asiolink
+} // namespace isc

+ 3 - 1
src/lib/asiolink/io_service.h

@@ -19,6 +19,7 @@ namespace asio {
     class io_service;
 }
 
+namespace isc {
 namespace asiolink {
 
 struct IOServiceImpl;
@@ -73,5 +74,6 @@ private:
     IOServiceImpl* io_impl_;
 };
 
-}      // namespace asiolink
+} // namespace asiolink
+} // namespace isc
 #endif // __ASIOLINK_IO_SERVICE_H

+ 3 - 3
src/lib/asiolink/io_socket.cc

@@ -16,8 +16,7 @@
 
 #include <asio.hpp>
 
-using namespace asio;
-
+namespace isc {
 namespace asiolink {
 
 /// \brief The \c DummySocket class is a concrete derived class of
@@ -62,4 +61,5 @@ IOSocket::getDummyTCPSocket() {
     return (socket);
 }
 
-}
+} // namespace asiolink
+} // namespace isc

+ 2 - 0
src/lib/asiolink/io_socket.h

@@ -25,6 +25,7 @@
 
 #include <exceptions/exceptions.h>
 
+namespace isc {
 namespace asiolink {
 
 /// \brief The \c IOSocket class is an abstract base class to represent
@@ -120,5 +121,6 @@ public:
 };
 
 } // namespace asiolink
+} // namespace isc
 
 #endif // __IO_SOCKET_H

+ 3 - 1
src/lib/asiolink/simple_callback.h

@@ -17,6 +17,7 @@
 
 #include <asiolink/io_message.h>
 
+namespace isc {
 namespace asiolink {
 
 /// \brief The \c SimpleCallback class is an abstract base class for a
@@ -67,5 +68,6 @@ private:
     SimpleCallback* self_;
 };
 
-}      // namespace asiolink
+} // namespace asiolink
+} // namespace isc
 #endif // __ASIOLINK_SIMPLE_CALLBACK_H

+ 3 - 1
src/lib/asiolink/tcp_endpoint.h

@@ -21,6 +21,7 @@
 
 #include <asiolink/io_endpoint.h>
 
+namespace isc {
 namespace asiolink {
 
 /// \brief The \c TCPEndpoint class is a concrete derived class of
@@ -109,5 +110,6 @@ private:
     asio::ip::tcp::endpoint& asio_endpoint_;
 };
 
-}      // namespace asiolink
+} // namespace asiolink
+} // namespace isc
 #endif // __TCP_ENDPOINT_H

+ 2 - 0
src/lib/asiolink/tcp_socket.h

@@ -41,6 +41,7 @@
 #include <asiolink/io_service.h>
 #include <asiolink/tcp_endpoint.h>
 
+namespace isc {
 namespace asiolink {
 
 /// \brief Buffer Too Large
@@ -412,5 +413,6 @@ TCPSocket<C>::close() {
 }
 
 } // namespace asiolink
+} // namespace isc
 
 #endif // __TCP_SOCKET_H

+ 0 - 4
src/lib/asiolink/tests/Makefile.am

@@ -21,16 +21,12 @@ run_unittests_SOURCES += $(top_srcdir)/src/lib/dns/tests/unittest_util.cc
 run_unittests_SOURCES += asiolink_utilities_unittest.cc
 run_unittests_SOURCES += io_address_unittest.cc
 run_unittests_SOURCES += io_endpoint_unittest.cc
-run_unittests_SOURCES += io_fetch_unittest.cc
 run_unittests_SOURCES += io_socket_unittest.cc
-run_unittests_SOURCES += io_service_unittest.cc
 run_unittests_SOURCES += interval_timer_unittest.cc
 run_unittests_SOURCES += tcp_endpoint_unittest.cc
 run_unittests_SOURCES += tcp_socket_unittest.cc
 run_unittests_SOURCES += udp_endpoint_unittest.cc
 run_unittests_SOURCES += udp_socket_unittest.cc
-run_unittests_SOURCES += dns_server_unittest.cc
-run_unittests_SOURCES += qid_gen_unittest.cc
 
 run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 

+ 1 - 1
src/lib/asiolink/tests/asiolink_utilities_unittest.cc

@@ -24,7 +24,7 @@
 #include <dns/buffer.h>
 #include <asiolink/asiolink_utilities.h>
 
-using namespace asiolink;
+using namespace isc::asiolink;
 using namespace isc::dns;
 
 TEST(asioutil, readUint16) {

+ 1 - 1
src/lib/asiolink/tests/interval_timer_unittest.cc

@@ -26,7 +26,7 @@ const boost::posix_time::time_duration TIMER_MARGIN_MSEC =
     boost::posix_time::milliseconds(50);
 }
 
-using namespace asiolink;
+using namespace isc::asiolink;
 
 // This fixture is for testing IntervalTimer. Some callback functors are 
 // registered as callback function of the timer to test if they are called

+ 1 - 1
src/lib/asiolink/tests/io_address_unittest.cc

@@ -18,7 +18,7 @@
 #include <asiolink/io_error.h>
 #include <asiolink/io_address.h>
 
-using namespace asiolink;
+using namespace isc::asiolink;
 
 TEST(IOAddressTest, fromText) {
     IOAddress io_address_v4("192.0.2.1");

+ 1 - 1
src/lib/asiolink/tests/io_endpoint_unittest.cc

@@ -18,7 +18,7 @@
 #include <asiolink/io_endpoint.h>
 #include <asiolink/io_error.h>
 
-using namespace asiolink;
+using namespace isc::asiolink;
 
 TEST(IOEndpointTest, createUDPv4) {
     const IOEndpoint* ep;

+ 1 - 1
src/lib/asiolink/tests/io_socket_unittest.cc

@@ -20,7 +20,7 @@
 #include <asio.hpp>
 #include <asiolink/io_socket.h>
 
-using namespace asiolink;
+using namespace isc::asiolink;
 
 TEST(IOSocketTest, dummySockets) {
     EXPECT_EQ(IPPROTO_UDP, IOSocket::getDummyUDPSocket().getProtocol());

+ 1 - 1
src/lib/asiolink/tests/tcp_endpoint_unittest.cc

@@ -22,7 +22,7 @@
 #include <asiolink/io_address.h>
 #include <asiolink/tcp_endpoint.h>
 
-using namespace asiolink;
+using namespace isc::asiolink;
 using namespace std;
 
 // This test checks that the endpoint can manage its own internal

+ 1 - 1
src/lib/asiolink/tests/tcp_socket_unittest.cc

@@ -46,7 +46,7 @@
 
 using namespace asio;
 using namespace asio::ip;
-using namespace asiolink;
+using namespace isc::asiolink;
 using namespace isc::dns;
 using namespace std;
 

+ 1 - 1
src/lib/asiolink/tests/udp_endpoint_unittest.cc

@@ -22,7 +22,7 @@
 #include <asiolink/io_address.h>
 #include <asiolink/udp_endpoint.h>
 
-using namespace asiolink;
+using namespace isc::asiolink;
 using namespace std;
 
 // This test checks that the endpoint can manage its own internal

+ 1 - 1
src/lib/asiolink/tests/udp_socket_unittest.cc

@@ -45,7 +45,7 @@
 #include <asiolink/udp_socket.h>
 
 using namespace asio;
-using namespace asiolink;
+using namespace isc::asiolink;
 using namespace isc::dns;
 using namespace std;
 

+ 3 - 1
src/lib/asiolink/udp_endpoint.h

@@ -21,6 +21,7 @@
 
 #include <asiolink/io_endpoint.h>
 
+namespace isc {
 namespace asiolink {
 
 /// \brief The \c UDPEndpoint class is a concrete derived class of
@@ -109,5 +110,6 @@ private:
     asio::ip::udp::endpoint& asio_endpoint_;
 };
 
-}      // namespace asiolink
+} // namespace asiolink
+} // namespace isc
 #endif // __UDP_ENDPOINT_H

+ 2 - 0
src/lib/asiolink/udp_socket.h

@@ -33,6 +33,7 @@
 #include <asiolink/io_service.h>
 #include <asiolink/udp_endpoint.h>
 
+namespace isc {
 namespace asiolink {
 
 /// \brief The \c UDPSocket class is a concrete derived class of \c IOAsioSocket
@@ -318,5 +319,6 @@ UDPSocket<C>::close() {
 }
 
 } // namespace asiolink
+} // namespace isc
 
 #endif // __UDP_SOCKET_H

+ 1 - 1
src/lib/nsas/glue_hints.cc

@@ -58,7 +58,7 @@ namespace {
         const std::string ns_name = rrset->getName().toText();
         RdataIteratorPtr rdi = rrset->getRdataIterator();
         while (!rdi->isLast()) {
-            AddressEntry entry(asiolink::IOAddress(rdi->getCurrent().toText()));
+            AddressEntry entry(isc::asiolink::IOAddress(rdi->getCurrent().toText()));
             boost::shared_ptr<NameserverEntry> ns_entry(new NameserverEntry(ns_name, rrset->getClass()));
             NameserverAddress ns_address(ns_entry, entry, V4_ONLY);
             addresses.push_back(ns_address);

+ 1 - 1
src/lib/nsas/nameserver_entry.cc

@@ -41,7 +41,7 @@
 #include "nameserver_address.h"
 #include "nameserver_entry.h"
 
-using namespace asiolink;
+using namespace isc::asiolink;
 using namespace isc::nsas;
 using namespace isc::dns;
 using namespace std;

+ 1 - 1
src/lib/nsas/tests/address_entry_unittest.cc

@@ -32,7 +32,7 @@ static std::string V4B_TEXT("5.6.7.8");
 static std::string V6A_TEXT("2001:dead:beef::");
 static std::string V6B_TEXT("1984:1985::1986:1987");
 
-using namespace asiolink;
+using namespace isc::asiolink;
 using namespace std;
 using namespace isc::nsas;
 

+ 2 - 2
src/lib/nsas/tests/nameserver_address_unittest.cc

@@ -58,7 +58,7 @@ public:
     boost::shared_ptr<NameserverEntry>& getNameserverEntry() { return ns_; }
 
     // Return the IOAddress corresponding to the index in rrv4_
-    asiolink::IOAddress getAddressAtIndex(uint32_t index) {
+    isc::asiolink::IOAddress getAddressAtIndex(uint32_t index) {
         return ns_.get()->getAddressAtIndex(index, V4_ONLY);
     }
 
@@ -107,7 +107,7 @@ TEST_F(NameserverAddressTest, Address) {
     boost::shared_ptr<NameserverEntry> empty_ne((NameserverEntry*)NULL);
     // It will throw an NullNameserverEntryPointer exception with the empty NameserverEntry shared pointer
     ASSERT_THROW({NameserverAddress empty_ns_address(empty_ne,
-        asiolink::IOAddress("127.0.0.1"), V4_ONLY);},
+        isc::asiolink::IOAddress("127.0.0.1"), V4_ONLY);},
         NullNameserverEntryPointer);
 }
 

+ 1 - 1
src/lib/nsas/tests/nameserver_entry_unittest.cc

@@ -39,7 +39,7 @@
 #include "nsas_test.h"
 
 using namespace isc::nsas;
-using namespace asiolink;
+using namespace isc::asiolink;
 using namespace std;
 using namespace isc::dns;
 using namespace rdata;

+ 1 - 1
src/lib/nsas/tests/zone_entry_unittest.cc

@@ -33,7 +33,7 @@
 #include "nsas_test.h"
 
 using namespace isc::nsas;
-using namespace asiolink;
+using namespace isc::asiolink;
 using namespace std;
 using namespace isc::dns;
 

+ 7 - 6
src/lib/resolve/recursive_query.cc

@@ -35,15 +35,17 @@
 #include <nsas/nameserver_address.h>
 
 #include <asio.hpp>
-#include <asiolink/dns_service.h>
-#include <asiolink/io_fetch.h>
+#include <asiodns/dns_service.h>
+#include <asiodns/io_fetch.h>
 #include <asiolink/io_service.h>
 #include <resolve/recursive_query.h>
 
 using isc::log::dlog;
 using namespace isc::dns;
+using namespace isc::asiolink;
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 typedef std::vector<std::pair<std::string, uint16_t> > AddressVector;
 
@@ -812,6 +814,5 @@ RecursiveQuery::resolve(const Question& question,
     }
 }
 
-
-
-} // namespace asiolink
+} // namespace asiodns
+} // namespace isc

+ 10 - 9
src/lib/resolve/recursive_query.h

@@ -15,14 +15,14 @@
 #ifndef __RECURSIVE_QUERY_H
 #define __RECURSIVE_QUERY_H 1
 
-#include <asiolink/dns_service.h>
-#include <asiolink/dns_server.h>
+#include <asiodns/dns_service.h>
+#include <asiodns/dns_server.h>
 #include <dns/buffer.h>
 #include <nsas/nameserver_address_store.h>
 #include <cache/resolver_cache.h>
 
-namespace asiolink {
-
+namespace isc {
+namespace asiodns {
 
 /// \brief RTT Recorder
 ///
@@ -87,9 +87,9 @@ public:
                    isc::nsas::NameserverAddressStore& nsas,
                    isc::cache::ResolverCache& cache,
                    const std::vector<std::pair<std::string, uint16_t> >&
-                   upstream, 
+                   upstream,
                    const std::vector<std::pair<std::string, uint16_t> >&
-                   upstream_root, 
+                   upstream_root,
                    int query_timeout = 2000,
                    int client_timeout = 4000,
                    int lookup_timeout = 30000,
@@ -105,7 +105,7 @@ public:
     void setRttRecorder(boost::shared_ptr<RttRecorder>& recorder);
 
     /// \brief Initiate resolving
-    /// 
+    ///
     /// When sendQuery() is called, a (set of) message(s) is sent
     /// asynchronously. If upstream servers are set, one is chosen
     /// and the response (if any) from that server will be returned.
@@ -152,7 +152,7 @@ public:
     /// \param address IP address of the test server.
     /// \param port Port number of the test server
     void setTestServer(const std::string& address, uint16_t port);
-    
+
 private:
     DNSService& dns_service_;
     isc::nsas::NameserverAddressStore& nsas_;
@@ -169,5 +169,6 @@ private:
     boost::shared_ptr<RttRecorder>  rtt_recorder_;  ///< Round-trip time recorder
 };
 
-}      // namespace asiolink
+}      // namespace asiodns
+}      // namespace isc
 #endif // __RECURSIVE_QUERY_H

+ 3 - 3
src/lib/resolve/resolver_callback.h

@@ -15,7 +15,7 @@
 #ifndef _ISC_RESOLVER_CALLBACK_H
 #define _ISC_RESOLVER_CALLBACK_H 1
 
-#include <asiolink/dns_server.h>
+#include <asiodns/dns_server.h>
 #include <dns/message.h>
 
 #include <resolve/resolver_interface.h>
@@ -33,7 +33,7 @@ namespace resolve {
 /// as the server itself should also have a reference.
 class ResolverCallbackServer : public ResolverInterface::Callback {
 public:
-    ResolverCallbackServer(asiolink::DNSServer* server) :
+    ResolverCallbackServer(asiodns::DNSServer* server) :
         server_(server->clone()) {}
     ~ResolverCallbackServer() { delete server_; };
     
@@ -41,7 +41,7 @@ public:
     void failure();
 
 private:
-    asiolink::DNSServer* server_;
+    asiodns::DNSServer* server_;
 };
 
 } //namespace resolve

+ 1 - 0
src/lib/resolve/tests/Makefile.am

@@ -27,6 +27,7 @@ run_unittests_LDADD +=  $(top_builddir)/src/lib/exceptions/libexceptions.la
 run_unittests_LDADD +=  $(top_builddir)/src/lib/nsas/libnsas.la
 run_unittests_LDADD +=  $(top_builddir)/src/lib/cache/libcache.la
 run_unittests_LDADD +=  $(top_builddir)/src/lib/asiolink/libasiolink.la
+run_unittests_LDADD +=  $(top_builddir)/src/lib/asiodns/libasiodns.la
 run_unittests_LDADD +=  $(top_builddir)/src/lib/resolve/libresolve.la
 run_unittests_LDADD +=  $(top_builddir)/src/lib/dns/libdns++.la
 run_unittests_LDADD +=  $(top_builddir)/src/lib/log/liblog.la

+ 4 - 3
src/lib/resolve/tests/recursive_query_unittest.cc

@@ -45,16 +45,17 @@
 // If we need to test something at the level of underlying ASIO and need
 // their definition, that test should go to asiolink/internal/tests.
 #include <resolve/recursive_query.h>
+#include <asiodns/dns_lookup.h>
 #include <asiolink/io_socket.h>
 #include <asiolink/io_service.h>
 #include <asiolink/io_message.h>
 #include <asiolink/io_error.h>
-#include <asiolink/dns_lookup.h>
 #include <asiolink/simple_callback.h>
 
 using isc::UnitTestUtil;
 using namespace std;
-using namespace asiolink;
+using namespace isc::asiodns;
+using namespace isc::asiolink;
 using namespace isc::dns;
 
 namespace {
@@ -316,7 +317,7 @@ protected:
     private:
         // Currently unused; these will be used for testing
         // asynchronous lookup calls via the asyncLookup() method
-        boost::shared_ptr<asiolink::IOMessage> io_message_;
+        boost::shared_ptr<isc::asiolink::IOMessage> io_message_;
         isc::dns::MessagePtr message_;
         isc::dns::MessagePtr answer_message_;
         isc::dns::OutputBufferPtr respbuf_;

+ 7 - 4
src/lib/resolve/tests/recursive_query_unittest_2.cc

@@ -37,16 +37,17 @@
 #include <dns/rdata.h>
 
 #include <asiolink/asiolink_utilities.h>
-#include <asiolink/dns_service.h>
+#include <asiodns/dns_service.h>
+#include <asiodns/io_fetch.h>
 #include <asiolink/io_address.h>
 #include <asiolink/io_endpoint.h>
-#include <asiolink/io_fetch.h>
 #include <asiolink/io_service.h>
 #include <resolve/recursive_query.h>
 #include <resolve/resolver_interface.h>
 
 using namespace asio;
 using namespace asio::ip;
+using namespace isc::asiolink;
 using namespace isc::dns;
 using namespace isc::dns::rdata;
 using namespace isc::resolve;
@@ -72,7 +73,8 @@ using namespace std;
 /// directed to one or other of the "servers" in the RecursiveQueryTest2 class,
 /// regardless of the glue returned in referrals.
 
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 
 const std::string TEST_ADDRESS = "127.0.0.1";   ///< Servers are on this address
 const uint16_t TEST_PORT = 5301;                ///< ... and this port
@@ -689,4 +691,5 @@ TEST_F(RecursiveQueryTest2, Resolve) {
     }
 }
 
-} // namespace asiolink
+} // namespace asiodns
+} // namespace isc

+ 4 - 4
src/lib/resolve/tests/resolver_callback_unittest.cc

@@ -13,7 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <gtest/gtest.h>
-#include <asiolink/dns_server.h>
+#include <asiodns/dns_server.h>
 #include <resolve/resolver_callback.h>
 
 using namespace isc::resolve;
@@ -22,7 +22,7 @@ using namespace isc::resolve;
 // We want to check if resume is called
 // Since the server will get cloned(), we want the clones to share
 // our bools for whether resume got called and with what value
-class DummyServer : public asiolink::DNSServer {
+class DummyServer : public isc::asiodns::DNSServer {
 public:
     DummyServer(DummyServer* orig) {
         resume_called_ = orig->getResumeCalled();
@@ -31,10 +31,10 @@ public:
     DummyServer(bool* resume_called, bool* resume_value) :
         resume_called_(resume_called), resume_value_(resume_value)
     {}
-    
+
     bool* getResumeCalled() { return resume_called_; }
     bool* getResumeValue() { return resume_value_; }
-    
+
     DNSServer* clone() {
         DummyServer* n = new DummyServer(this);
         return n;

+ 4 - 3
src/lib/server_common/portconfig.cc

@@ -15,7 +15,7 @@
 #include <server_common/portconfig.h>
 
 #include <asiolink/io_address.h>
-#include <asiolink/dns_service.h>
+#include <asiodns/dns_service.h>
 #include <log/dummylog.h>
 
 #include <boost/foreach.hpp>
@@ -23,7 +23,8 @@
 
 using namespace std;
 using namespace isc::data;
-using namespace asiolink;
+using namespace isc::asiolink;
+using namespace isc::asiodns;
 using isc::log::dlog;
 
 namespace isc {
@@ -82,7 +83,7 @@ setAddresses(DNSService& service, const AddressList& addresses) {
 void
 installListenAddresses(const AddressList& newAddresses,
                        AddressList& addressStore,
-                       asiolink::DNSService& service)
+                       isc::asiodns::DNSService& service)
 {
     try {
         dlog("Setting listen addresses:");

+ 4 - 2
src/lib/server_common/portconfig.h

@@ -25,9 +25,11 @@
 /*
  * Some forward declarations.
  */
-namespace asiolink {
+namespace isc {
+namespace asiodns {
 class DNSService;
 }
+}
 
 namespace isc {
 namespace server_common {
@@ -112,7 +114,7 @@ parseAddresses(isc::data::ConstElementPtr addresses,
 void
 installListenAddresses(const AddressList& newAddresses,
                        AddressList& addressStore,
-                       asiolink::DNSService& dnsService);
+                       asiodns::DNSService& dnsService);
 
 }
 }

+ 2 - 1
src/lib/server_common/tests/Makefile.am

@@ -12,7 +12,7 @@ endif
 # Some versions of GCC warn about some versions of Boost regarding
 # missing initializer for members in its posix_time.
 # https://svn.boost.org/trac/boost/ticket/3477
-# But older GCC compilers don't have the flag.     
+# But older GCC compilers don't have the flag.
 AM_CXXFLAGS += $(WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG)
 
 if USE_CLANGPP
@@ -35,6 +35,7 @@ run_unittests_LDADD = $(GTEST_LDADD)
 run_unittests_LDADD += $(top_builddir)/src/lib/server_common/libserver_common.la
 run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
 run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
+run_unittests_LDADD += $(top_builddir)/src/lib/asiodns/libasiodns.la
 run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
 run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
 endif

+ 3 - 1
src/lib/server_common/tests/portconfig_unittest.cc

@@ -17,6 +17,7 @@
 #include <cc/data.h>
 #include <exceptions/exceptions.h>
 #include <asiolink/asiolink.h>
+#include <asiodns/asiodns.h>
 
 #include <gtest/gtest.h>
 #include <string>
@@ -25,7 +26,8 @@ using namespace isc::server_common::portconfig;
 using namespace isc::data;
 using namespace isc;
 using namespace std;
-using namespace asiolink;
+using namespace isc::asiolink;
+using namespace isc::asiodns;
 
 namespace {
 

+ 2 - 2
src/lib/testutils/mockups.h

@@ -19,7 +19,7 @@
 
 #include <xfr/xfrout_client.h>
 
-#include <asiolink/asiolink.h>
+#include <asiodns/asiodns.h>
 
 // A minimal mock configuration session.  Most the methods are
 // stubbed out, except for a very basic group_sendmsg() and
@@ -94,7 +94,7 @@ private:
 };
 
 // A nonoperative DNSServer object to be used in calls to processMessage().
-class MockServer : public asiolink::DNSServer {
+class MockServer : public isc::asiodns::DNSServer {
 public:
     MockServer() : done_(false) {}
     void operator()(asio::error_code, size_t) {}

+ 1 - 1
src/lib/testutils/srv_test.cc

@@ -27,7 +27,7 @@
 #include <testutils/srv_test.h>
 
 using namespace isc::dns;
-using namespace asiolink;
+using namespace isc::asiolink;
 
 namespace isc {
 namespace testutils {

+ 0 - 0
tests/tools/badpacket/Makefile.am


Some files were not shown because too many files changed in this diff