Commit f33b0115 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

checkpoint: introduced endpoint wrappers.


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac221@2198 e5f2f494-b856-4b98-b285-d166d9295462
parent 8df32866
......@@ -59,6 +59,34 @@ TEST(IOAddressTest, fromText) {
EXPECT_THROW(IOAddress("2001:db8:::1234"), IOError);
}
TEST(IOEndpointTest, createFromAddress) {
const IOEndpoint* ep;
ep = IOEndpoint::createFromAddress(IPPROTO_UDP, IOAddress("192.0.2.1"),
5300);
EXPECT_EQ("192.0.2.1", ep->getAddress().toText());
delete ep;
ep = IOEndpoint::createFromAddress(IPPROTO_TCP, IOAddress("192.0.2.1"),
5300);
EXPECT_EQ("192.0.2.1", ep->getAddress().toText());
delete ep;
ep = IOEndpoint::createFromAddress(IPPROTO_UDP,
IOAddress("2001:db8::1234"), 5300);
EXPECT_EQ("2001:db8::1234", ep->getAddress().toText());
delete ep;
ep = IOEndpoint::createFromAddress(IPPROTO_TCP,
IOAddress("2001:db8::1234"), 5300);
EXPECT_EQ("2001:db8::1234", ep->getAddress().toText());
delete ep;
EXPECT_THROW(IOEndpoint::createFromAddress(IPPROTO_IP,
IOAddress("192.0.2.1"),
5300)->getAddress().toText(),
IOError);
}
TEST(IOSocketTest, dummySockets) {
EXPECT_EQ(IPPROTO_UDP, IOSocket::getDummyUDPSocket().getProtocol());
EXPECT_EQ(IPPROTO_TCP, IOSocket::getDummyTCPSocket().getProtocol());
......@@ -131,7 +159,8 @@ public:
void callBack(const IOMessage& io_message) {
callback_protocol_ = io_message.getSocket().getProtocol();
callback_native_ = io_message.getSocket().getNative();
callback_address_ = io_message.getRemoteAddress().toText();
callback_address_ =
io_message.getRemoteEndpoint().getAddress().toText();
callback_data_.assign(
static_cast<const uint8_t*>(io_message.getData()),
static_cast<const uint8_t*>(io_message.getData()) +
......
......@@ -50,12 +50,13 @@ protected:
parse_message(Message::PARSE), default_qid(0x1035),
opcode(Opcode(Opcode::QUERY())), qname("www.example.com"),
qclass(RRClass::IN()), qtype(RRType::A()),
io_message(NULL), request_obuffer(0),
io_message(NULL), endpoint(NULL), request_obuffer(0),
request_renderer(request_obuffer),
response_obuffer(0), response_renderer(response_obuffer)
{}
~AuthSrvTest() {
delete io_message;
delete endpoint;
}
AuthSrv server;
Message request_message;
......@@ -65,7 +66,8 @@ protected:
const Name qname;
const RRClass qclass;
const RRType qtype;
IOMessage *io_message;
IOMessage* io_message;
const IOEndpoint* endpoint;
OutputBuffer request_obuffer;
MessageRenderer request_renderer;
OutputBuffer response_obuffer;
......@@ -91,9 +93,13 @@ AuthSrvTest::createDataFromFile(const char* const datafile) {
delete io_message;
data.clear();
delete endpoint;
endpoint = IOEndpoint::createFromAddress(IPPROTO_UDP,
IOAddress("192.0.2.1"),
5300);
UnitTestUtil::readWireData(datafile, data);
io_message = new IOMessage(&data[0], data.size(),
IOSocket::getDummyUDPSocket(), "192.0.2.1");
IOSocket::getDummyUDPSocket(), *endpoint);
}
void
......
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