Commit 04959743 authored by JINMEI Tatuya's avatar JINMEI Tatuya

added a mock implementation IOAddress, a wrapper for asio::ip::address.

added test cases for the class, which currently fail.


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac221@2170 e5f2f494-b856-4b98-b285-d166d9295462
parent e97fa799
......@@ -91,6 +91,20 @@ dispatch_axfr_query(const int tcp_sock, char const axfr_query[],
}
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 @@ public:
// 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(
......
......@@ -17,11 +17,56 @@
#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:
IOService(AuthSrv* auth_server, const char* port, bool use_ipv4,
......
......@@ -14,6 +14,7 @@ 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 += ../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/dns/.libs/libdns++.a
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)
......
// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
// $Id$
#include <gtest/gtest.h>
#include <auth/asio_link.h>
using namespace asio_link;
namespace {
TEST(IOAddressTest, fromText) {
IOAddress io_address_v4("192.0.2.1");
EXPECT_EQ("192.0.2.1", io_address_v4.toText());
IOAddress io_address_v6("2001:db8::1234");
EXPECT_EQ("2001:db8::1234", io_address_v6.toText());
// bogus IPv4 address-like input
EXPECT_THROW(IOAddress("192.0.2.2.1"), IOError);
// bogus IPv6 address-like input
EXPECT_THROW(IOAddress("2001:db8:::1234"), IOError);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment