[svn] commit: r2170 - in /branches/trac221/src/bin/auth: asio_link.cc asio_link.h tests/Makefile.am tests/asio_link_unittest.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Sat Jun 19 04:03:42 UTC 2010


Author: jinmei
Date: Sat Jun 19 04:03:41 2010
New Revision: 2170

Log:
added a mock implementation IOAddress, a wrapper for asio::ip::address.
added test cases for the class, which currently fail.

Added:
    branches/trac221/src/bin/auth/tests/asio_link_unittest.cc   (with props)
Modified:
    branches/trac221/src/bin/auth/asio_link.cc
    branches/trac221/src/bin/auth/asio_link.h
    branches/trac221/src/bin/auth/tests/Makefile.am

Modified: branches/trac221/src/bin/auth/asio_link.cc
==============================================================================
--- branches/trac221/src/bin/auth/asio_link.cc (original)
+++ branches/trac221/src/bin/auth/asio_link.cc Sat Jun 19 04:03:41 2010
@@ -91,6 +91,20 @@
 }
 
 namespace asio_link {
+IOAddress::IOAddress(const string& address_str) :
+    asio_address_placeholder_(NULL),
+    asio_address_(*asio_address_placeholder_) // XXX
+{}
+
+IOAddress::~IOAddress() {
+    delete asio_address_placeholder_;
+}
+
+string
+IOAddress::toText() const {
+    return ("dummy");
+}
+
 //
 // Helper classes for asynchronous I/O using asio
 //
@@ -146,7 +160,15 @@
                 // start to get new query ?
                 start();
             } else {
-#endif          
+#endif
+#ifdef notyet
+                IOMessage io_message(data_, bytes_transferred,
+                                     remote_endpoint, socket);
+                if (auth_server_->processMessage(IOMessage(message), ..)) {
+                    //...
+                    message.getIOService().
+                }
+#endif
                 if (auth_server_->processMessage(dnsbuffer, dns_message_,
                                                 response_renderer_, false)) {
                     responselen_buffer_.writeUint16(

Modified: branches/trac221/src/bin/auth/asio_link.h
==============================================================================
--- branches/trac221/src/bin/auth/asio_link.h (original)
+++ branches/trac221/src/bin/auth/asio_link.h Sat Jun 19 04:03:41 2010
@@ -17,10 +17,55 @@
 #ifndef __ASIO_LINK_H
 #define __ASIO_LINK_H 1
 
+#include <string>
+
+#include <exceptions/exceptions.h>
+
+namespace asio {
+class io_service;
+
+namespace ip {
+class address;
+}
+}
+
 class AuthSrv;
 
 namespace asio_link {
 struct IOServiceImpl;
+
+/// \brief An exception that is thrown if an error occurs with in the IO
+/// module.  This is mainly intended to be a wrapper exception class for
+/// ASIO specific exceptions.
+class IOError : public isc::Exception {
+public:
+    IOError(const char* file, size_t line, const char* what) :
+        isc::Exception(file, line, what) {}
+};
+
+class IOAddress {
+public:
+    IOAddress(const std::string& adress_str);
+    IOAddress(const asio::ip::address& asio_adress);
+    std::string toText() const;
+    ~IOAddress();
+private:
+    asio::ip::address* asio_address_placeholder_;
+    asio::ip::address& asio_address_;
+};
+
+class IOMessage {
+public:
+    IOMessage();
+    ~IOMessage();
+    const void* getData() const;
+    size_t getDataSize() const;
+    int getNative() const;
+    const IOAddress& getRemoteAddress() const;
+private:
+    class IOMessageImpl;
+    IOMessageImpl* impl_;
+};
 
 class IOService {
 public:

Modified: branches/trac221/src/bin/auth/tests/Makefile.am
==============================================================================
--- branches/trac221/src/bin/auth/tests/Makefile.am (original)
+++ branches/trac221/src/bin/auth/tests/Makefile.am Sat Jun 19 04:03:41 2010
@@ -14,6 +14,7 @@
 run_unittests_SOURCES += $(top_srcdir)/src/lib/dns/tests/unittest_util.cc
 run_unittests_SOURCES += ../auth_srv.h ../auth_srv.cc
 run_unittests_SOURCES += auth_srv_unittest.cc
+run_unittests_SOURCES += asio_link_unittest.cc
 run_unittests_SOURCES += run_unittests.cc
 run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
@@ -24,6 +25,11 @@
 run_unittests_LDADD += $(top_builddir)/src/lib/config/.libs/libcfgclient.a
 run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.a
 run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/.libs/libexceptions.a
+run_unittests_LDADD += $(top_builddir)/src/bin/auth/libasio_link.a
+if HAVE_BOOST_PYTHON
+# Note: after this refactoring this should become unnecessary.
+run_unittests_LDADD += $(top_builddir)/src/lib/xfr/.libs/libxfr.a
+endif
 endif
 
 noinst_PROGRAMS = $(TESTS)




More information about the bind10-changes mailing list