Commit 3aee00b2 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[master] Merge branch 'trac2587'

parents bdc99366 d3c90ab3
......@@ -1286,12 +1286,12 @@ TEST_F(AuthSrvTest, queryCounterUnexpected) {
createRequestPacket(request_message, IPPROTO_UDP);
// Modify the message.
delete io_message;
endpoint = IOEndpoint::create(IPPROTO_UDP,
IOAddress(DEFAULT_REMOTE_ADDRESS), 53210);
io_message = new IOMessage(request_renderer.getData(),
request_renderer.getLength(),
getDummyUnknownSocket(), *endpoint);
endpoint.reset(IOEndpoint::create(IPPROTO_UDP,
IOAddress(DEFAULT_REMOTE_ADDRESS),
53210));
io_message.reset(new IOMessage(request_renderer.getData(),
request_renderer.getLength(),
getDummyUnknownSocket(), *endpoint));
EXPECT_FALSE(dnsserv.hasAnswer());
}
......@@ -1716,9 +1716,20 @@ void
checkAddrPort(const struct sockaddr& actual_sa,
const string& expected_addr, uint16_t expected_port)
{
// ASIO does not set as_len, which is not a problem on most
// systems, but it will make getnameinfo() fail on NetBSD 4
// So we make a copy and if the field is available, we set it
const socklen_t sa_len = getSALength(actual_sa);
struct sockaddr_storage ss;
memcpy(&ss, &actual_sa, sa_len);
struct sockaddr* sa = convertSockAddr(&ss);
#ifdef HAVE_SA_LEN
sa->sa_len = sa_len;
#endif
char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
const int error = getnameinfo(&actual_sa, getSALength(actual_sa), hbuf,
sizeof(hbuf), sbuf, sizeof(sbuf),
const int error = getnameinfo(sa, sa_len, hbuf, sizeof(hbuf),
sbuf, sizeof(sbuf),
NI_NUMERICHOST | NI_NUMERICSERV);
if (error != 0) {
isc_throw(isc::Unexpected, "getnameinfo failed: " <<
......
......@@ -27,6 +27,8 @@
#include <testutils/dnsmessage_test.h>
#include <testutils/srv_test.h>
#include <boost/scoped_ptr.hpp>
using namespace isc::dns;
using namespace isc::util;
using namespace isc::asiolink;
......@@ -48,27 +50,20 @@ SrvTestBase::SrvTestBase() : request_message(Message::RENDER),
response_obuffer(new OutputBuffer(0))
{}
SrvTestBase::~SrvTestBase() {
delete io_message;
delete endpoint;
}
void
SrvTestBase::createDataFromFile(const char* const datafile,
const int protocol)
{
delete io_message;
data.clear();
delete endpoint;
endpoint = IOEndpoint::create(protocol,
IOAddress(DEFAULT_REMOTE_ADDRESS),
DEFAULT_REMOTE_PORT);
endpoint.reset(IOEndpoint::create(protocol,
IOAddress(DEFAULT_REMOTE_ADDRESS),
DEFAULT_REMOTE_PORT));
UnitTestUtil::readWireData(datafile, data);
io_sock = (protocol == IPPROTO_UDP) ? &IOSocket::getDummyUDPSocket() :
&IOSocket::getDummyTCPSocket();
io_message = new IOMessage(&data[0], data.size(), *io_sock, *endpoint);
io_message.reset(new IOMessage(&data[0], data.size(), *io_sock,
*endpoint));
}
void
......@@ -83,16 +78,14 @@ SrvTestBase::createRequestPacket(Message& message,
message.toWire(request_renderer, *context);
}
delete io_message;
endpoint = IOEndpoint::create(protocol, IOAddress(remote_address),
remote_port);
endpoint.reset(IOEndpoint::create(protocol, IOAddress(remote_address),
remote_port));
io_sock = (protocol == IPPROTO_UDP) ? &IOSocket::getDummyUDPSocket() :
&IOSocket::getDummyTCPSocket();
io_message = new IOMessage(request_renderer.getData(),
request_renderer.getLength(),
*io_sock, *endpoint);
io_message.reset(new IOMessage(request_renderer.getData(),
request_renderer.getLength(),
*io_sock, *endpoint));
}
// Unsupported requests. Should result in NOTIMP.
......@@ -151,7 +144,7 @@ SrvTestBase::shortMessage() {
// or malformed or could otherwise cause a protocol error.
void
SrvTestBase::response() {
// A valid (although unusual) response
// A valid (although unusual) response
createDataFromFile("simpleresponse_fromWire.wire");
processMessage();
EXPECT_FALSE(dnsserv.hasAnswer());
......@@ -242,6 +235,6 @@ SrvTestBase::axfrOverUDP() {
} // end of namespace isc
// Local Variables:
// Local Variables:
// mode: c++
// End:
// End:
......@@ -25,6 +25,7 @@
#include <dns/rrtype.h>
#include "mockups.h"
#include <boost/scoped_ptr.hpp>
namespace asiolink {
class IOSocket;
......@@ -52,7 +53,6 @@ extern const unsigned int CD_FLAG;
class SrvTestBase : public ::testing::Test {
protected:
SrvTestBase();
virtual ~SrvTestBase();
/// Let the server process a DNS message.
///
......@@ -104,8 +104,8 @@ protected:
const isc::dns::RRClass qclass;
const isc::dns::RRType qtype;
asiolink::IOSocket* io_sock;
asiolink::IOMessage* io_message;
const asiolink::IOEndpoint* endpoint;
boost::scoped_ptr<asiolink::IOMessage> io_message;
boost::scoped_ptr<const asiolink::IOEndpoint> endpoint;
isc::dns::MessageRenderer request_renderer;
isc::util::OutputBufferPtr response_obuffer;
std::vector<uint8_t> data;
......@@ -114,6 +114,6 @@ protected:
} // end of namespace isc
#endif // ISC_TESTUTILS_SRVTEST_H
// Local Variables:
// Local Variables:
// mode: c++
// End:
// End:
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