Commit f11adb59 authored by Jelte Jansen's avatar Jelte Jansen

add answer message object to answer handler

parent 1efc3bee
......@@ -224,6 +224,7 @@ class MessageAnswer : public DNSAnswer {
public:
virtual void operator()(const IOMessage& io_message,
MessagePtr message,
MessagePtr answer_message,
OutputBufferPtr buffer) const
{
const qid_t qid = message->getQid();
......@@ -233,7 +234,8 @@ public:
const Rcode& rcode = message->getRcode();
vector<QuestionPtr> questions;
questions.assign(message->beginQuestion(), message->endQuestion());
(void)answer_message;
message->clear(Message::RENDER);
message->setQid(qid);
message->setOpcode(opcode);
......
......@@ -467,6 +467,7 @@ public:
/// \param buffer The result is put here
virtual void operator()(const IOMessage& io_message,
isc::dns::MessagePtr message,
isc::dns::MessagePtr answer_message,
isc::dns::OutputBufferPtr buffer) const = 0;
};
......
......@@ -198,6 +198,7 @@ private:
// DNS lookup and answer providers
boost::shared_ptr<asiolink::IOMessage> io_message_;
isc::dns::MessagePtr message_;
isc::dns::MessagePtr answer_message_;
// The buffer into which the query packet is written
boost::shared_array<char>data_;
......
......@@ -211,6 +211,7 @@ private:
// DNS lookup and answer providers
boost::shared_ptr<asiolink::IOMessage> io_message_;
isc::dns::MessagePtr message_;
isc::dns::MessagePtr answer_message_;
// The buffer into which the response is written
isc::dns::OutputBufferPtr respbuf_;
......
......@@ -145,6 +145,7 @@ TCPServer::operator()(error_code ec, size_t length) {
// DNS lookup and the write call.
respbuf_.reset(new OutputBuffer(0));
message_.reset(new Message(Message::PARSE));
answer_message_.reset(new Message(Message::PARSE));
// Schedule a DNS lookup, and yield. When the lookup is
// finished, the coroutine will resume immediately after
......@@ -159,7 +160,7 @@ TCPServer::operator()(error_code ec, size_t length) {
// Call the DNS answer provider to render the answer into
// wire format
(*answer_callback_)(*io_message_, message_, respbuf_);
(*answer_callback_)(*io_message_, message_, answer_message_, respbuf_);
// Set up the response, beginning with two length bytes.
lenbuf.writeUint16(respbuf_->getLength());
......
......@@ -442,6 +442,7 @@ protected:
DNSAnswer* answer = NULL) :
io_(io_service),
message_(new Message(Message::PARSE)),
answer_message_(new Message(Message::RENDER)),
respbuf_(new OutputBuffer(0)),
checkin_(checkin), lookup_(lookup), answer_(answer)
{}
......@@ -473,6 +474,7 @@ protected:
// asynchronous lookup calls via the asyncLookup() method
boost::shared_ptr<asiolink::IOMessage> io_message_;
isc::dns::MessagePtr message_;
isc::dns::MessagePtr answer_message_;
isc::dns::OutputBufferPtr respbuf_;
// Callback functions provided by the caller
......
......@@ -133,6 +133,7 @@ UDPServer::operator()(error_code ec, size_t length) {
// asynchronous DNS lookup and/or by the send call.
respbuf_.reset(new OutputBuffer(0));
message_.reset(new Message(Message::PARSE));
answer_message_.reset(new Message(Message::PARSE));
// Schedule a DNS lookup, and yield. When the lookup is
// finished, the coroutine will resume immediately after
......@@ -149,7 +150,7 @@ UDPServer::operator()(error_code ec, size_t length) {
// Call the DNS answer provider to render the answer into
// wire format
(*answer_callback_)(*io_message_, message_, respbuf_);
(*answer_callback_)(*io_message_, message_, answer_message_, respbuf_);
// Begin an asynchronous send, and then yield. When the
// send completes, we will resume immediately after this point
......
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