Commit 435b7a28 authored by Jelte Jansen's avatar Jelte Jansen

add answer_message to processMessage

parent 294251d6
......@@ -105,7 +105,9 @@ public:
}
}
void processNormalQuery(const Question& question, MessagePtr message,
void processNormalQuery(const Question& question,
MessagePtr message,
MessagePtr answer_message,
OutputBufferPtr buffer,
DNSServer* server);
......@@ -214,7 +216,8 @@ public:
DNSServer* server) const
{
(void) answer_message,
server_->processMessage(io_message, message, buffer, server);
server_->processMessage(io_message, message, answer_message,
buffer, server);
}
private:
Resolver* server_;
......@@ -349,8 +352,11 @@ Resolver::getConfigSession() const {
}
void
Resolver::processMessage(const IOMessage& io_message, MessagePtr message,
OutputBufferPtr buffer, DNSServer* server)
Resolver::processMessage(const IOMessage& io_message,
MessagePtr message,
MessagePtr answer_message,
OutputBufferPtr buffer,
DNSServer* server)
{
dlog("Got a DNS message");
InputBuffer request_buffer(io_message.getData(), io_message.getDataSize());
......@@ -418,7 +424,8 @@ Resolver::processMessage(const IOMessage& io_message, MessagePtr message,
// The RecursiveQuery object will post the "resume" event to the
// DNSServer when an answer arrives, so we don't have to do it now.
sendAnswer = false;
impl_->processNormalQuery(*question, message, buffer, server);
impl_->processNormalQuery(*question, message,
answer_message, buffer, server);
}
}
......@@ -428,8 +435,11 @@ Resolver::processMessage(const IOMessage& io_message, MessagePtr message,
}
void
ResolverImpl::processNormalQuery(const Question& question, MessagePtr message,
OutputBufferPtr buffer, DNSServer* server)
ResolverImpl::processNormalQuery(const Question& question,
MessagePtr message,
MessagePtr answer_message,
OutputBufferPtr buffer,
DNSServer* server)
{
dlog("Processing normal query");
ConstEDNSPtr edns(message->getEDNS());
......@@ -445,7 +455,7 @@ ResolverImpl::processNormalQuery(const Question& question, MessagePtr message,
message->setEDNS(edns_response);
}
dlog("[XX] calling sendQuery()");
rec_query_->sendQuery(question, buffer, server);
rec_query_->sendQuery(question, answer_message, buffer, server);
dlog("[XX] done processing normal query");
}
......
......@@ -66,6 +66,7 @@ public:
/// \param server Pointer to the \c DNSServer
void processMessage(const asiolink::IOMessage& io_message,
isc::dns::MessagePtr message,
isc::dns::MessagePtr answer_message,
isc::dns::OutputBufferPtr buffer,
asiolink::DNSServer* server);
......
......@@ -29,7 +29,10 @@ class ResolverTest : public SrvTestBase{
protected:
ResolverTest() : server(){}
virtual void processMessage() {
server.processMessage(*io_message, parse_message, response_obuffer,
server.processMessage(*io_message,
parse_message,
response_message,
response_obuffer,
&dnsserv);
}
Resolver server;
......@@ -82,7 +85,7 @@ TEST_F(ResolverTest, AXFRFail) {
RRType::AXFR());
createRequestPacket(request_message, IPPROTO_TCP);
// AXFR is not implemented and should always send NOTIMP.
server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
server.processMessage(*io_message, parse_message, response_message, response_obuffer, &dnsserv);
EXPECT_TRUE(dnsserv.hasAnswer());
headerCheck(*parse_message, default_qid, Rcode::NOTIMP(), opcode.getCode(),
QR_FLAG, 1, 0, 0, 0);
......@@ -97,7 +100,7 @@ TEST_F(ResolverTest, notifyFail) {
request_message.setQid(default_qid);
request_message.setHeaderFlag(Message::HEADERFLAG_AA);
createRequestPacket(request_message, IPPROTO_UDP);
server.processMessage(*io_message, parse_message, response_obuffer, &dnsserv);
server.processMessage(*io_message, parse_message, response_message, response_obuffer, &dnsserv);
EXPECT_TRUE(dnsserv.hasAnswer());
headerCheck(*parse_message, default_qid, Rcode::NOTAUTH(),
Opcode::NOTIFY().getCode(), QR_FLAG, 0, 0, 0, 0);
......
......@@ -453,7 +453,9 @@ public:
}
void
RecursiveQuery::sendQuery(const Question& question, OutputBufferPtr buffer,
RecursiveQuery::sendQuery(const Question& question,
MessagePtr answer_message,
OutputBufferPtr buffer,
DNSServer* server)
{
// XXX: eventually we will need to be able to determine whether
......@@ -462,6 +464,7 @@ RecursiveQuery::sendQuery(const Question& question, OutputBufferPtr buffer,
// we're only going to handle UDP.
asio::io_service& io = dns_service_.get_io_service();
// It will delete itself when it is done
(void) answer_message;
new RunningQuery(io, question, upstream_, buffer, server,
timeout_, retries_);
}
......
......@@ -561,6 +561,7 @@ public:
/// \param buffer An output buffer into which the response can be copied
/// \param server A pointer to the \c DNSServer object handling the client
void sendQuery(const isc::dns::Question& question,
isc::dns::MessagePtr answer_message,
isc::dns::OutputBufferPtr buffer,
DNSServer* server);
private:
......
......@@ -673,7 +673,8 @@ TEST_F(ASIOLinkTest, recursiveSend) {
Question q(Name("example.com"), RRClass::IN(), RRType::TXT());
OutputBufferPtr buffer(new OutputBuffer(0));
rq.sendQuery(q, buffer, &server);
MessagePtr answer(new Message(Message::RENDER));
rq.sendQuery(q, answer, buffer, &server);
char data[4096];
size_t size = sizeof(data);
......@@ -718,7 +719,8 @@ TEST_F(ASIOLinkTest, recursiveTimeout) {
10, 2);
Question question(Name("example.net"), RRClass::IN(), RRType::A());
OutputBufferPtr buffer(new OutputBuffer(0));
query.sendQuery(question, buffer, &server);
MessagePtr answer(new Message(Message::RENDER));
query.sendQuery(question, answer, buffer, &server);
// Run the test
io_service_->run();
......
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