[svn] commit: r1349 - in /trunk/src/bin/auth: auth_srv.cc tests/auth_srv_unittest.cc tests/testdata/multiquestion_fromWire tests/testdata/multiquestion_fromWire.spec
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Mar 12 04:33:42 UTC 2010
Author: jinmei
Date: Fri Mar 12 04:33:42 2010
New Revision: 1349
Log:
preserved the question section when returning an error to a query
Modified:
trunk/src/bin/auth/auth_srv.cc
trunk/src/bin/auth/tests/auth_srv_unittest.cc
trunk/src/bin/auth/tests/testdata/multiquestion_fromWire
trunk/src/bin/auth/tests/testdata/multiquestion_fromWire.spec
Modified: trunk/src/bin/auth/auth_srv.cc
==============================================================================
--- trunk/src/bin/auth/auth_srv.cc (original)
+++ trunk/src/bin/auth/auth_srv.cc Fri Mar 12 04:33:42 2010
@@ -21,8 +21,10 @@
#include <netdb.h>
#include <stdlib.h>
+#include <algorithm>
#include <cassert>
#include <iostream>
+#include <vector>
#include <exceptions/exceptions.h>
@@ -94,6 +96,15 @@
}
namespace {
+class QuestionInserter {
+public:
+ QuestionInserter(Message* message) : message_(message) {}
+ void operator()(const QuestionPtr question) {
+ message_->addQuestion(question);
+ }
+ Message* message_;
+};
+
void
makeErrorMessage(Message& message, MessageRenderer& renderer,
const Rcode& rcode)
@@ -105,6 +116,12 @@
const bool rd = message.getHeaderFlag(MessageFlag::RD());
const bool cd = message.getHeaderFlag(MessageFlag::CD());
const Opcode& opcode = message.getOpcode();
+ vector<QuestionPtr> questions;
+
+ // If this is an error to a query, we should also copy the question section.
+ if (opcode == Opcode::QUERY()) {
+ questions.assign(message.beginQuestion(), message.endQuestion());
+ }
message.clear(Message::RENDER);
message.setQid(qid);
@@ -116,6 +133,7 @@
if (cd) {
message.setHeaderFlag(MessageFlag::CD());
}
+ for_each(questions.begin(), questions.end(), QuestionInserter(&message));
message.setRcode(rcode);
message.toWire(renderer);
}
Modified: trunk/src/bin/auth/tests/auth_srv_unittest.cc
==============================================================================
--- trunk/src/bin/auth/tests/auth_srv_unittest.cc (original)
+++ trunk/src/bin/auth/tests/auth_srv_unittest.cc Fri Mar 12 04:33:42 2010
@@ -115,14 +115,24 @@
}
// Multiple questions. Should result in FORMERR.
-
TEST_F(AuthSrvTest, multiQuestion) {
createDataFromFile("testdata/multiquestion_fromWire", data);
InputBuffer buffer(&data[0], data.size());
EXPECT_EQ(0, server.processMessage(buffer, parse_message,
response_renderer, true, false));
headerCheck(parse_message, default_qid, Rcode::FORMERR(), opcode.getCode(),
- QR_FLAG, 0, 0, 0, 0);
+ QR_FLAG, 2, 0, 0, 0);
+
+ QuestionIterator qit = parse_message.beginQuestion();
+ EXPECT_EQ(Name("example.com"), (*qit)->getName());
+ EXPECT_EQ(RRClass::IN(), (*qit)->getClass());
+ EXPECT_EQ(RRType::A(), (*qit)->getType());
+ ++qit;
+ EXPECT_EQ(Name("example.com"), (*qit)->getName());
+ EXPECT_EQ(RRClass::IN(), (*qit)->getClass());
+ EXPECT_EQ(RRType::AAAA(), (*qit)->getType());
+ ++qit;
+ EXPECT_TRUE(qit == parse_message.endQuestion());
}
}
Modified: trunk/src/bin/auth/tests/testdata/multiquestion_fromWire
==============================================================================
--- trunk/src/bin/auth/tests/testdata/multiquestion_fromWire (original)
+++ trunk/src/bin/auth/tests/testdata/multiquestion_fromWire Fri Mar 12 04:33:42 2010
@@ -13,5 +13,5 @@
076578616d706c6503636f6d00 0001 0001
# Question Section
-# QNAME=q2.example.com QTYPE=A(1) QCLASS=IN(1)
-027132076578616d706c6503636f6d00 0001 0001
+# QNAME=example.com. QTYPE=AAAA(28) QCLASS=IN(1)
+076578616d706c6503636f6d00 001c 0001
Modified: trunk/src/bin/auth/tests/testdata/multiquestion_fromWire.spec
==============================================================================
--- trunk/src/bin/auth/tests/testdata/multiquestion_fromWire.spec (original)
+++ trunk/src/bin/auth/tests/testdata/multiquestion_fromWire.spec Fri Mar 12 04:33:42 2010
@@ -9,4 +9,4 @@
[question/0]
# use default
[question/1]
-name: q2.example.com
+rrtype: AAAA
More information about the bind10-changes
mailing list