[svn] commit: r3481 - in /branches/trac299: ./ src/bin/auth/ src/bin/auth/benchmarks/ src/bin/auth/tests/ src/bin/bind10/ src/bin/bindctl/ src/bin/cfgmgr/ src/bin/cmdctl/ src/bin/host/ src/bin/loadzone/ src/bin/loadzone/tests/error/ src/bin/msgq/ src/bin/msgq/tests/ src/bin/stats/ src/bin/stats/tests/isc/ src/bin/stats/tests/isc/config/ src/bin/stats/tests/isc/util/ src/bin/tests/ src/bin/usermgr/ src/bin/xfrin/ src/bin/xfrin/tests/ src/bin/xfrout/ src/bin/xfrout/tests/ src/bin/zonemgr/ src/bin/zonemgr/tests/ src/lib/bench/ src/lib/bench/example/ src/lib/bench/tests/ src/lib/cc/ src/lib/cc/tests/ src/lib/config/ src/lib/config/tests/ src/lib/datasrc/ src/lib/datasrc/tests/ src/lib/dns/ src/lib/dns/python/ src/lib/dns/python/tests/ src/lib/dns/rdata/generic/ src/lib/dns/tests/ src/lib/python/isc/ src/lib/python/isc/Util/ src/lib/python/isc/cc/ src/lib/python/isc/cc/tests/ src/lib/python/isc/config/ src/lib/python/isc/config/tests/ src/lib/python/isc/datasrc/ src/lib/python/isc/notify/ src/lib/python/isc/util/ src/lib/python/isc/utils/ src/lib/xfr/
BIND 10 source code commits
bind10-changes at lists.isc.org
Sun Nov 7 11:01:07 UTC 2010
Author: chenzhengzhang
Date: Sun Nov 7 11:01:06 2010
New Revision: 3481
Log:
merge trunk into branch299
Added:
branches/trac299/src/bin/stats/tests/isc/util/
- copied from r3480, trunk/src/bin/stats/tests/isc/util/
branches/trac299/src/lib/python/isc/util/
- copied from r3480, trunk/src/lib/python/isc/util/
Removed:
branches/trac299/src/lib/python/isc/Util/
Modified:
branches/trac299/ (props changed)
branches/trac299/ChangeLog
branches/trac299/configure.ac
branches/trac299/src/bin/auth/Makefile.am
branches/trac299/src/bin/auth/asio_link.h
branches/trac299/src/bin/auth/auth_srv.cc
branches/trac299/src/bin/auth/benchmarks/Makefile.am
branches/trac299/src/bin/auth/tests/Makefile.am
branches/trac299/src/bin/auth/tests/auth_srv_unittest.cc
branches/trac299/src/bin/bind10/bind10.py.in (contents, props changed)
branches/trac299/src/bin/bindctl/bindctl-source.py.in
branches/trac299/src/bin/cfgmgr/b10-cfgmgr.py.in
branches/trac299/src/bin/cmdctl/cmdctl.py.in (contents, props changed)
branches/trac299/src/bin/host/Makefile.am
branches/trac299/src/bin/host/host.cc
branches/trac299/src/bin/loadzone/b10-loadzone.py.in
branches/trac299/src/bin/loadzone/tests/error/error.known
branches/trac299/src/bin/msgq/msgq.py.in
branches/trac299/src/bin/msgq/tests/Makefile.am
branches/trac299/src/bin/msgq/tests/msgq_test.py
branches/trac299/src/bin/stats/stats.py.in
branches/trac299/src/bin/stats/stats_stub.py.in
branches/trac299/src/bin/stats/tests/isc/Makefile.am
branches/trac299/src/bin/stats/tests/isc/config/ccsession.py
branches/trac299/src/bin/tests/process_rename_test.py.in
branches/trac299/src/bin/usermgr/b10-cmdctl-usermgr.py.in
branches/trac299/src/bin/xfrin/tests/xfrin_test.py
branches/trac299/src/bin/xfrin/xfrin.py.in
branches/trac299/src/bin/xfrout/tests/xfrout_test.py
branches/trac299/src/bin/xfrout/xfrout.py.in
branches/trac299/src/bin/zonemgr/tests/zonemgr_test.py
branches/trac299/src/bin/zonemgr/zonemgr.py.in
branches/trac299/src/lib/bench/Makefile.am
branches/trac299/src/lib/bench/example/search_bench.cc
branches/trac299/src/lib/bench/tests/Makefile.am
branches/trac299/src/lib/bench/tests/loadquery_unittest.cc
branches/trac299/src/lib/cc/Makefile.am
branches/trac299/src/lib/cc/tests/Makefile.am
branches/trac299/src/lib/cc/tests/data_unittests.cc
branches/trac299/src/lib/config/Makefile.am
branches/trac299/src/lib/config/tests/Makefile.am
branches/trac299/src/lib/config/tests/ccsession_unittests.cc
branches/trac299/src/lib/datasrc/Makefile.am
branches/trac299/src/lib/datasrc/data_source.cc
branches/trac299/src/lib/datasrc/query.cc
branches/trac299/src/lib/datasrc/query.h
branches/trac299/src/lib/datasrc/tests/Makefile.am
branches/trac299/src/lib/datasrc/tests/datasrc_unittest.cc
branches/trac299/src/lib/datasrc/tests/query_unittest.cc
branches/trac299/src/lib/dns/Makefile.am
branches/trac299/src/lib/dns/message.cc
branches/trac299/src/lib/dns/message.h
branches/trac299/src/lib/dns/python/Makefile.am
branches/trac299/src/lib/dns/python/message_python.cc
branches/trac299/src/lib/dns/python/tests/message_python_test.py
branches/trac299/src/lib/dns/python/tests/messagerenderer_python_test.py
branches/trac299/src/lib/dns/rdata/generic/opt_41.cc
branches/trac299/src/lib/dns/tests/Makefile.am
branches/trac299/src/lib/dns/tests/edns_unittest.cc
branches/trac299/src/lib/dns/tests/message_unittest.cc
branches/trac299/src/lib/dns/tests/name_unittest.cc
branches/trac299/src/lib/dns/tests/rdata_ns_unittest.cc
branches/trac299/src/lib/dns/tests/rdata_ptr_unittest.cc
branches/trac299/src/lib/dns/tests/rdata_unittest.cc
branches/trac299/src/lib/python/isc/Makefile.am
branches/trac299/src/lib/python/isc/cc/data.py
branches/trac299/src/lib/python/isc/cc/session.py
branches/trac299/src/lib/python/isc/cc/tests/session_test.py
branches/trac299/src/lib/python/isc/config/ccsession.py
branches/trac299/src/lib/python/isc/config/tests/ccsession_test.py
branches/trac299/src/lib/python/isc/datasrc/master.py
branches/trac299/src/lib/python/isc/notify/notify_out.py
branches/trac299/src/lib/python/isc/utils/ (props changed)
branches/trac299/src/lib/xfr/Makefile.am
Modified: branches/trac299/ChangeLog
==============================================================================
--- branches/trac299/ChangeLog (original)
+++ branches/trac299/ChangeLog Sun Nov 7 11:01:06 2010
@@ -1,3 +1,27 @@
+ 115. [func]* jinmei
+ src/lib/dns: Changed DNS message flags and section names from
+ separate classes to simpler enums, considering the balance between
+ type safety and usability. API has been changed accordingly.
+ More documentation and tests were provided with these changes.
+ (Trac #358, r3439)
+
+ 114. [build] jinmei
+ Supported clang++. Note: Boost >= 1.44 is required.
+ (Trac #365, svn r3383)
+
+ 113. [func]* zhanglikun
+ Folder name 'utils'(the folder in /src/lib/python/isc/) has been
+ renamed to 'util'. Programs that used 'import isc.utils.process'
+ now need to use 'import isc.util.process'. The folder
+ /src/lib/python/isc/Util is removed since it isn't used by any
+ program. (Trac #364, r3382)
+
+ 112. [func] zhang likun
+ Add one mixin class to override the naive serve_forever() provided
+ in python library socketserver. Instead of polling for shutdwon
+ every poll_interval seconds, one socketpair is used to wake up
+ the waiting server.(Trac #352, svn r3366)
+
111. [bug]* zhanglikun, Michal Vaner
Make sure process xfrin/xfrout/zonemgr/cmdctl can be stoped
properly when user enter "ctrl+c" or 'Boss shutdown' command
@@ -20,10 +44,10 @@
Added the document of the stats module, which is about how stats
module collects the data (Trac #170, [wiki:StatsModule])
- 108. [func] jerry
+ 108. [func] jerry
src/bin/zonemgr: Provide customizable configurations for
lowerbound_refresh, lowerbound_retry, max_transfer_timeout and
- jitter_scope. (Trac #340, r3205)
+ jitter_scope. (Trac #340, r3205)
107. [func] zhang likun
Remove the parameter 'db_file' for command 'retransfer' of
@@ -38,7 +62,7 @@
105. [bug] Michal Vaner
Python processes: they no longer take 100% CPU while idle
due to a busy loop in reading command session in a nonblocking way.
- (Trac #349, svn r3153)
+ (Trac #349, svn r3153), (Trac #382, svn r3294)
104. [bug] jerry
bin/zonemgr: zonemgr should be attempting to refresh expired zones.
Modified: branches/trac299/configure.ac
==============================================================================
--- branches/trac299/configure.ac (original)
+++ branches/trac299/configure.ac Sun Nov 7 11:01:06 2010
@@ -17,6 +17,8 @@
# Identify the compiler: this check must be after AC_PROG_CXX and AC_LANG.
AM_CONDITIONAL(USE_GXX, test "X${GXX}" = "Xyes")
AC_CHECK_DECL([__SUNPRO_CC], [SUNCXX="yes"], [SUNCXX="no"])
+AC_CHECK_DECL([__clang__], [CLANGPP="yes"], [CLANGPP="no"])
+AM_CONDITIONAL(USE_CLANGPP, test "X${CLANGPP}" = "Xyes")
# Linker options
@@ -313,12 +315,14 @@
fi
done
fi
+CPPFLAGS_SAVES="$CPPFLAGS"
if test "${boost_include_path}" ; then
BOOST_INCLUDES="-I${boost_include_path}"
CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES"
fi
AC_CHECK_HEADERS([boost/shared_ptr.hpp boost/foreach.hpp],,
AC_MSG_ERROR([Missing required header files.]))
+CPPFLAGS="$CPPFLAGS_SAVES"
AC_SUBST(BOOST_INCLUDES)
#
@@ -476,7 +480,7 @@
src/bin/stats/tests/isc/Makefile
src/bin/stats/tests/isc/cc/Makefile
src/bin/stats/tests/isc/config/Makefile
- src/bin/stats/tests/isc/utils/Makefile
+ src/bin/stats/tests/isc/util/Makefile
src/bin/stats/tests/testdata/Makefile
src/bin/usermgr/Makefile
src/bin/tests/Makefile
@@ -488,8 +492,8 @@
src/lib/cc/tests/Makefile
src/lib/python/Makefile
src/lib/python/isc/Makefile
- src/lib/python/isc/utils/Makefile
- src/lib/python/isc/utils/tests/Makefile
+ src/lib/python/isc/util/Makefile
+ src/lib/python/isc/util/tests/Makefile
src/lib/python/isc/datasrc/Makefile
src/lib/python/isc/cc/Makefile
src/lib/python/isc/cc/tests/Makefile
@@ -604,6 +608,8 @@
Name: $PACKAGE_NAME
Version: $PACKAGE_VERSION
+C++ Compiler: $CXX
+
Flags:
DEFS: $DEFS
CPPFLAGS: $CPPFLAGS
@@ -613,6 +619,7 @@
Python: ${PYTHON_INCLUDES}
${PYTHON_LDFLAGS}
${PYTHON_LIB}
+ Boost: ${BOOST_INCLUDES}
SQLite: $SQLITE_CFLAGS
$SQLITE_LIBS
@@ -632,4 +639,3 @@
Now you can type "make" to build BIND 10
EOF
-
Modified: branches/trac299/src/bin/auth/Makefile.am
==============================================================================
--- branches/trac299/src/bin/auth/Makefile.am (original)
+++ branches/trac299/src/bin/auth/Makefile.am Sun Nov 7 11:01:06 2010
@@ -5,6 +5,7 @@
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc
AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS)
@@ -46,6 +47,10 @@
if USE_GXX
libasio_link_a_CXXFLAGS += -Wno-unused-parameter
endif
+if USE_CLANGPP
+# Same for clang++, but we need to turn off -Werror completely.
+libasio_link_a_CXXFLAGS += -Wno-error
+endif
libasio_link_a_CPPFLAGS = $(AM_CPPFLAGS)
BUILT_SOURCES = spec_config.h
Modified: branches/trac299/src/bin/auth/asio_link.h
==============================================================================
--- branches/trac299/src/bin/auth/asio_link.h (original)
+++ branches/trac299/src/bin/auth/asio_link.h Sun Nov 7 11:01:06 2010
@@ -88,7 +88,7 @@
/// http://think-async.com/Asio/asio-1.3.1/doc/asio/reference/asio_handler_allocate.html
namespace asio_link {
-struct IOServiceImpl;
+class IOServiceImpl;
/// \brief An exception that is thrown if an error occurs within the IO
/// module. This is mainly intended to be a wrapper exception class for
Modified: branches/trac299/src/bin/auth/auth_srv.cc
==============================================================================
--- branches/trac299/src/bin/auth/auth_srv.cc (original)
+++ branches/trac299/src/bin/auth/auth_srv.cc Sun Nov 7 11:01:06 2010
@@ -152,8 +152,8 @@
// XXX: with the current implementation, it's not easy to set EDNS0
// depending on whether the query had it. So we'll simply omit it.
const qid_t qid = message.getQid();
- const bool rd = message.getHeaderFlag(MessageFlag::RD());
- const bool cd = message.getHeaderFlag(MessageFlag::CD());
+ const bool rd = message.getHeaderFlag(Message::HEADERFLAG_RD);
+ const bool cd = message.getHeaderFlag(Message::HEADERFLAG_CD);
const Opcode& opcode = message.getOpcode();
vector<QuestionPtr> questions;
@@ -166,12 +166,12 @@
message.clear(Message::RENDER);
message.setQid(qid);
message.setOpcode(opcode);
- message.setHeaderFlag(MessageFlag::QR());
+ message.setHeaderFlag(Message::HEADERFLAG_QR);
if (rd) {
- message.setHeaderFlag(MessageFlag::RD());
+ message.setHeaderFlag(Message::HEADERFLAG_RD);
}
if (cd) {
- message.setHeaderFlag(MessageFlag::CD());
+ message.setHeaderFlag(Message::HEADERFLAG_CD);
}
for_each(questions.begin(), questions.end(), QuestionInserter(&message));
message.setRcode(rcode);
@@ -231,7 +231,7 @@
message.parseHeader(request_buffer);
// Ignore all responses.
- if (message.getHeaderFlag(MessageFlag::QR())) {
+ if (message.getHeaderFlag(Message::HEADERFLAG_QR)) {
if (impl_->verbose_mode_) {
cerr << "[b10-auth] received unexpected response, ignoring"
<< endl;
@@ -279,7 +279,7 @@
return (true);
}
- if (message.getRRCount(Section::QUESTION()) != 1) {
+ if (message.getRRCount(Message::SECTION_QUESTION) != 1) {
makeErrorMessage(message, response_renderer, Rcode::FORMERR(),
impl_->verbose_mode_);
return (true);
@@ -310,7 +310,7 @@
Message::DEFAULT_MAX_UDPSIZE;
message.makeResponse();
- message.setHeaderFlag(MessageFlag::AA());
+ message.setHeaderFlag(Message::HEADERFLAG_AA);
message.setRcode(Rcode::NOERROR());
if (remote_edns) {
@@ -396,10 +396,10 @@
{
// The incoming notify must contain exactly one question for SOA of the
// zone name.
- if (message.getRRCount(Section::QUESTION()) != 1) {
+ if (message.getRRCount(Message::SECTION_QUESTION) != 1) {
if (verbose_mode_) {
cerr << "[b10-auth] invalid number of questions in notify: "
- << message.getRRCount(Section::QUESTION()) << endl;
+ << message.getRRCount(Message::SECTION_QUESTION) << endl;
}
makeErrorMessage(message, response_renderer, Rcode::FORMERR(),
verbose_mode_);
@@ -471,7 +471,7 @@
}
message.makeResponse();
- message.setHeaderFlag(MessageFlag::AA());
+ message.setHeaderFlag(Message::HEADERFLAG_AA);
message.setRcode(Rcode::NOERROR());
message.toWire(response_renderer);
return (true);
Modified: branches/trac299/src/bin/auth/benchmarks/Makefile.am
==============================================================================
--- branches/trac299/src/bin/auth/benchmarks/Makefile.am (original)
+++ branches/trac299/src/bin/auth/benchmarks/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,5 +1,6 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS)
Modified: branches/trac299/src/bin/auth/tests/Makefile.am
==============================================================================
--- branches/trac299/src/bin/auth/tests/Makefile.am (original)
+++ branches/trac299/src/bin/auth/tests/Makefile.am Sun Nov 7 11:01:06 2010
@@ -3,6 +3,7 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_builddir)/src/lib/dns -I$(top_srcdir)/src/bin
AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\"
AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/bin/auth/tests/testdata\"
Modified: branches/trac299/src/bin/auth/tests/auth_srv_unittest.cc
==============================================================================
--- branches/trac299/src/bin/auth/tests/auth_srv_unittest.cc (original)
+++ branches/trac299/src/bin/auth/tests/auth_srv_unittest.cc Sun Nov 7 11:01:06 2010
@@ -321,18 +321,25 @@
EXPECT_EQ(qid, message.getQid());
EXPECT_EQ(rcode, message.getRcode());
EXPECT_EQ(opcodeval, message.getOpcode().getCode());
- EXPECT_EQ((flags & QR_FLAG) != 0, message.getHeaderFlag(MessageFlag::QR()));
- EXPECT_EQ((flags & AA_FLAG) != 0, message.getHeaderFlag(MessageFlag::AA()));
- EXPECT_EQ((flags & TC_FLAG) != 0, message.getHeaderFlag(MessageFlag::TC()));
- EXPECT_EQ((flags & RA_FLAG) != 0, message.getHeaderFlag(MessageFlag::RA()));
- EXPECT_EQ((flags & RD_FLAG) != 0, message.getHeaderFlag(MessageFlag::RD()));
- EXPECT_EQ((flags & AD_FLAG) != 0, message.getHeaderFlag(MessageFlag::AD()));
- EXPECT_EQ((flags & CD_FLAG) != 0, message.getHeaderFlag(MessageFlag::CD()));
-
- EXPECT_EQ(qdcount, message.getRRCount(Section::QUESTION()));
- EXPECT_EQ(ancount, message.getRRCount(Section::ANSWER()));
- EXPECT_EQ(nscount, message.getRRCount(Section::AUTHORITY()));
- EXPECT_EQ(arcount, message.getRRCount(Section::ADDITIONAL()));
+ EXPECT_EQ((flags & QR_FLAG) != 0,
+ message.getHeaderFlag(Message::HEADERFLAG_QR));
+ EXPECT_EQ((flags & AA_FLAG) != 0,
+ message.getHeaderFlag(Message::HEADERFLAG_AA));
+ EXPECT_EQ((flags & TC_FLAG) != 0,
+ message.getHeaderFlag(Message::HEADERFLAG_TC));
+ EXPECT_EQ((flags & RA_FLAG) != 0,
+ message.getHeaderFlag(Message::HEADERFLAG_RA));
+ EXPECT_EQ((flags & RD_FLAG) != 0,
+ message.getHeaderFlag(Message::HEADERFLAG_RD));
+ EXPECT_EQ((flags & AD_FLAG) != 0,
+ message.getHeaderFlag(Message::HEADERFLAG_AD));
+ EXPECT_EQ((flags & CD_FLAG) != 0,
+ message.getHeaderFlag(Message::HEADERFLAG_CD));
+
+ EXPECT_EQ(qdcount, message.getRRCount(Message::SECTION_QUESTION));
+ EXPECT_EQ(ancount, message.getRRCount(Message::SECTION_ANSWER));
+ EXPECT_EQ(nscount, message.getRRCount(Message::SECTION_AUTHORITY));
+ EXPECT_EQ(arcount, message.getRRCount(Message::SECTION_ADDITIONAL));
}
// Unsupported requests. Should result in NOTIMP.
@@ -348,8 +355,8 @@
data[2] = ((i << 3) & 0xff);
parse_message.clear(Message::PARSE);
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
headerCheck(parse_message, default_qid, Rcode::NOTIMP(), i, QR_FLAG,
0, 0, 0, 0);
}
@@ -367,8 +374,8 @@
// Multiple questions. Should result in FORMERR.
TEST_F(AuthSrvTest, multiQuestion) {
createDataFromFile("multiquestion_fromWire.wire");
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
headerCheck(parse_message, default_qid, Rcode::FORMERR(), opcode.getCode(),
QR_FLAG, 2, 0, 0, 0);
@@ -388,8 +395,8 @@
// dropped.
TEST_F(AuthSrvTest, shortMessage) {
createDataFromFile("shortmessage_fromWire");
- EXPECT_EQ(false, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_FALSE(server.processMessage(*io_message, parse_message,
+ response_renderer));
}
// Response messages. Must be silently dropped, whether it's a valid response
@@ -397,26 +404,26 @@
TEST_F(AuthSrvTest, response) {
// A valid (although unusual) response
createDataFromFile("simpleresponse_fromWire.wire");
- EXPECT_EQ(false, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_FALSE(server.processMessage(*io_message, parse_message,
+ response_renderer));
// A response with a broken question section. must be dropped rather than
// returning FORMERR.
createDataFromFile("shortresponse_fromWire");
- EXPECT_EQ(false, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_FALSE(server.processMessage(*io_message, parse_message,
+ response_renderer));
// A response to iquery. must be dropped rather than returning NOTIMP.
createDataFromFile("iqueryresponse_fromWire.wire");
- EXPECT_EQ(false, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_FALSE(server.processMessage(*io_message, parse_message,
+ response_renderer));
}
// Query with a broken question
TEST_F(AuthSrvTest, shortQuestion) {
createDataFromFile("shortquestion_fromWire");
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
// Since the query's question is broken, the question section of the
// response should be empty.
headerCheck(parse_message, default_qid, Rcode::FORMERR(), opcode.getCode(),
@@ -426,8 +433,8 @@
// Query with a broken answer section
TEST_F(AuthSrvTest, shortAnswer) {
createDataFromFile("shortanswer_fromWire.wire");
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
// This is a bogus query, but question section is valid. So the response
// should copy the question section.
@@ -445,8 +452,8 @@
// Query with unsupported version of EDNS.
TEST_F(AuthSrvTest, ednsBadVers) {
createDataFromFile("queryBadEDNS_fromWire.wire");
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
// The response must have an EDNS OPT RR in the additional section, but
// it will be added automatically at the render time.
@@ -468,8 +475,8 @@
// AXFR over UDP is invalid and should result in FORMERR.
createRequestPacket(opcode, Name("example.com"), RRClass::IN(),
RRType::AXFR(), IPPROTO_UDP);
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
headerCheck(parse_message, default_qid, Rcode::FORMERR(), opcode.getCode(),
QR_FLAG, 1, 0, 0, 0);
}
@@ -480,8 +487,8 @@
RRType::AXFR(), IPPROTO_TCP);
// On success, the AXFR query has been passed to a separate process,
// so we shouldn't have to respond.
- EXPECT_EQ(false, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_FALSE(server.processMessage(*io_message, parse_message,
+ response_renderer));
EXPECT_TRUE(xfrout.isConnected());
}
@@ -538,10 +545,10 @@
TEST_F(AuthSrvTest, notify) {
createRequestMessage(Opcode::NOTIFY(), Name("example.com"), RRClass::IN(),
RRType::SOA());
- request_message.setHeaderFlag(MessageFlag::AA());
- createRequestPacket(IPPROTO_UDP);
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ request_message.setHeaderFlag(Message::HEADERFLAG_AA);
+ createRequestPacket(IPPROTO_UDP);
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
// An internal command message should have been created and sent to an
// external module. Check them.
@@ -570,10 +577,10 @@
// Same as the previous test, but for the CH RRClass.
createRequestMessage(Opcode::NOTIFY(), Name("example.com"), RRClass::CH(),
RRType::SOA());
- request_message.setHeaderFlag(MessageFlag::AA());
- createRequestPacket(IPPROTO_UDP);
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ request_message.setHeaderFlag(Message::HEADERFLAG_AA);
+ createRequestPacket(IPPROTO_UDP);
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
// Other conditions should be the same, so simply confirm the RR class is
// set correctly.
@@ -586,12 +593,12 @@
request_message.clear(Message::RENDER);
request_message.setOpcode(Opcode::NOTIFY());
request_message.setRcode(Rcode::NOERROR());
- request_message.setHeaderFlag(MessageFlag::AA());
+ request_message.setHeaderFlag(Message::HEADERFLAG_AA);
request_message.setQid(default_qid);
request_message.toWire(request_renderer);
createRequestPacket(IPPROTO_UDP);
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
headerCheck(parse_message, default_qid, Rcode::FORMERR(),
Opcode::NOTIFY().getCode(), QR_FLAG, 0, 0, 0, 0);
}
@@ -602,10 +609,10 @@
// add one more SOA question
request_message.addQuestion(Question(Name("example.com"), RRClass::IN(),
RRType::SOA()));
- request_message.setHeaderFlag(MessageFlag::AA());
- createRequestPacket(IPPROTO_UDP);
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ request_message.setHeaderFlag(Message::HEADERFLAG_AA);
+ createRequestPacket(IPPROTO_UDP);
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
headerCheck(parse_message, default_qid, Rcode::FORMERR(),
Opcode::NOTIFY().getCode(), QR_FLAG, 2, 0, 0, 0);
}
@@ -613,10 +620,10 @@
TEST_F(AuthSrvTest, notifyNonSOAQuestion) {
createRequestMessage(Opcode::NOTIFY(), Name("example.com"), RRClass::IN(),
RRType::NS());
- request_message.setHeaderFlag(MessageFlag::AA());
- createRequestPacket(IPPROTO_UDP);
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ request_message.setHeaderFlag(Message::HEADERFLAG_AA);
+ createRequestPacket(IPPROTO_UDP);
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
headerCheck(parse_message, default_qid, Rcode::FORMERR(),
Opcode::NOTIFY().getCode(), QR_FLAG, 1, 0, 0, 0);
}
@@ -625,8 +632,8 @@
// implicitly leave the AA bit off. our implementation will accept it.
createRequestPacket(Opcode::NOTIFY(), Name("example.com"), RRClass::IN(),
RRType::SOA());
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
headerCheck(parse_message, default_qid, Rcode::NOERROR(),
Opcode::NOTIFY().getCode(), QR_FLAG | AA_FLAG, 1, 0, 0, 0);
}
@@ -634,11 +641,11 @@
TEST_F(AuthSrvTest, notifyWithErrorRcode) {
createRequestMessage(Opcode::NOTIFY(), Name("example.com"), RRClass::IN(),
RRType::SOA());
- request_message.setHeaderFlag(MessageFlag::AA());
+ request_message.setHeaderFlag(Message::HEADERFLAG_AA);
request_message.setRcode(Rcode::SERVFAIL());
createRequestPacket(IPPROTO_UDP);
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
headerCheck(parse_message, default_qid, Rcode::NOERROR(),
Opcode::NOTIFY().getCode(), QR_FLAG | AA_FLAG, 1, 0, 0, 0);
}
@@ -648,7 +655,7 @@
createRequestMessage(Opcode::NOTIFY(), Name("example.com"), RRClass::IN(),
RRType::SOA());
- request_message.setHeaderFlag(MessageFlag::AA());
+ request_message.setHeaderFlag(Message::HEADERFLAG_AA);
createRequestPacket(IPPROTO_UDP);
// we simply ignore the notify and let it be resent if an internal error
@@ -662,7 +669,7 @@
createRequestMessage(Opcode::NOTIFY(), Name("example.com"), RRClass::IN(),
RRType::SOA());
- request_message.setHeaderFlag(MessageFlag::AA());
+ request_message.setHeaderFlag(Message::HEADERFLAG_AA);
createRequestPacket(IPPROTO_UDP);
EXPECT_FALSE(server.processMessage(*io_message, parse_message,
@@ -674,7 +681,7 @@
createRequestMessage(Opcode::NOTIFY(), Name("example.com"), RRClass::IN(),
RRType::SOA());
- request_message.setHeaderFlag(MessageFlag::AA());
+ request_message.setHeaderFlag(Message::HEADERFLAG_AA);
createRequestPacket(IPPROTO_UDP);
EXPECT_FALSE(server.processMessage(*io_message, parse_message,
response_renderer));
@@ -685,7 +692,7 @@
createRequestMessage(Opcode::NOTIFY(), Name("example.com"), RRClass::IN(),
RRType::SOA());
- request_message.setHeaderFlag(MessageFlag::AA());
+ request_message.setHeaderFlag(Message::HEADERFLAG_AA);
createRequestPacket(IPPROTO_UDP);
EXPECT_FALSE(server.processMessage(*io_message, parse_message,
response_renderer));
@@ -697,7 +704,7 @@
createRequestMessage(Opcode::NOTIFY(), Name("example.com"), RRClass::IN(),
RRType::SOA());
- request_message.setHeaderFlag(MessageFlag::AA());
+ request_message.setHeaderFlag(Message::HEADERFLAG_AA);
createRequestPacket(IPPROTO_UDP);
EXPECT_FALSE(server.processMessage(*io_message, parse_message,
response_renderer));
@@ -725,8 +732,8 @@
// response should have the AA flag on, and have an RR in each answer
// and authority section.
createDataFromFile("examplequery_fromWire.wire");
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
headerCheck(parse_message, default_qid, Rcode::NOERROR(), opcode.getCode(),
QR_FLAG | AA_FLAG, 1, 1, 1, 0);
}
@@ -739,8 +746,8 @@
// in a SERVFAIL response, and the answer and authority sections should
// be empty.
createDataFromFile("badExampleQuery_fromWire.wire");
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
headerCheck(parse_message, default_qid, Rcode::SERVFAIL(),
opcode.getCode(), QR_FLAG, 1, 0, 0, 0);
}
@@ -754,8 +761,8 @@
// The original data source should still exist.
createDataFromFile("examplequery_fromWire.wire");
- EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
- response_renderer));
+ EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+ response_renderer));
headerCheck(parse_message, default_qid, Rcode::NOERROR(), opcode.getCode(),
QR_FLAG | AA_FLAG, 1, 1, 1, 0);
}
Modified: branches/trac299/src/bin/bind10/bind10.py.in
==============================================================================
--- branches/trac299/src/bin/bind10/bind10.py.in (original)
+++ branches/trac299/src/bin/bind10/bind10.py.in Sun Nov 7 11:01:06 2010
@@ -63,11 +63,11 @@
import posix
import isc.cc
+import isc.util.process
import isc.net.parse
-import isc.utils.process
# Assign this process some longer name
-isc.utils.process.rename(sys.argv[0])
+isc.util.process.rename(sys.argv[0])
# This is the version that gets displayed to the user.
# The VERSION string consists of the module name, the module version
@@ -141,9 +141,14 @@
self.username = username
self._spawn()
- def _setuid(self):
+ def _preexec_work(self):
"""Function used before running a program that needs to run as a
different user."""
+ # First, put us into a separate process group so we don't get
+ # SIGINT signals on Ctrl-C (the boss will shut everthing down by
+ # other means).
+ os.setpgrp()
+ # Second, set the user ID if one has been specified
if self.uid is not None:
try:
posix.setuid(self.uid)
@@ -177,7 +182,7 @@
stderr=spawn_stderr,
close_fds=True,
env=spawn_env,
- preexec_fn=self._setuid)
+ preexec_fn=self._preexec_work)
self.pid = self.process.pid
self.restart_schedule.set_run_start_time()
@@ -629,7 +634,7 @@
def process_rename(option, opt_str, value, parser):
"""Function that renames the process if it is requested by a option."""
- isc.utils.process.rename(value)
+ isc.util.process.rename(value)
def main():
global options
Modified: branches/trac299/src/bin/bindctl/bindctl-source.py.in
==============================================================================
--- branches/trac299/src/bin/bindctl/bindctl-source.py.in (original)
+++ branches/trac299/src/bin/bindctl/bindctl-source.py.in Sun Nov 7 11:01:06 2010
@@ -24,9 +24,9 @@
from bindctl.bindcmd import *
import pprint
from optparse import OptionParser, OptionValueError
-import isc.utils.process
+import isc.util.process
-isc.utils.process.rename()
+isc.util.process.rename()
__version__ = 'Bindctl'
Modified: branches/trac299/src/bin/cfgmgr/b10-cfgmgr.py.in
==============================================================================
--- branches/trac299/src/bin/cfgmgr/b10-cfgmgr.py.in (original)
+++ branches/trac299/src/bin/cfgmgr/b10-cfgmgr.py.in Sun Nov 7 11:01:06 2010
@@ -21,11 +21,11 @@
from isc.config.cfgmgr import ConfigManager, ConfigManagerDataReadError
from isc.cc import SessionError
-import isc.utils.process
+import isc.util.process
import signal
import os
-isc.utils.process.rename()
+isc.util.process.rename()
# If B10_FROM_SOURCE is set in the environment, we use data files
# from a directory relative to that, otherwise we use the ones
Modified: branches/trac299/src/bin/cmdctl/cmdctl.py.in
==============================================================================
--- branches/trac299/src/bin/cmdctl/cmdctl.py.in (original)
+++ branches/trac299/src/bin/cmdctl/cmdctl.py.in Sun Nov 7 11:01:06 2010
@@ -43,16 +43,18 @@
import time
import signal
from isc.config import ccsession
+import isc.util.process
import isc.net.parse
-import isc.utils.process
from optparse import OptionParser, OptionValueError
from hashlib import sha1
+from isc.util import socketserver_mixin
+
try:
import threading
except ImportError:
import dummy_threading as threading
-isc.utils.process.rename()
+isc.util.process.rename()
__version__ = 'BIND10'
URL_PATTERN = re.compile('/([\w]+)(?:/([\w]+))?/?')
@@ -441,7 +443,9 @@
return (keyfile, certfile, accountsfile)
-class SecureHTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
+class SecureHTTPServer(socketserver_mixin.NoPollMixIn,
+ socketserver.ThreadingMixIn,
+ http.server.HTTPServer):
'''Make the server address can be reused.'''
allow_reuse_address = True
@@ -449,6 +453,7 @@
CommandControlClass,
idle_timeout = 1200, verbose = False):
'''idle_timeout: the max idle time for login'''
+ socketserver_mixin.NoPollMixIn.__init__(self)
try:
http.server.HTTPServer.__init__(self, server_address, RequestHandlerClass)
except socket.error as err:
Modified: branches/trac299/src/bin/host/Makefile.am
==============================================================================
--- branches/trac299/src/bin/host/Makefile.am (original)
+++ branches/trac299/src/bin/host/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,5 +1,6 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS)
Modified: branches/trac299/src/bin/host/host.cc
==============================================================================
--- branches/trac299/src/bin/host/host.cc (original)
+++ branches/trac299/src/bin/host/host.cc Sun Nov 7 11:01:06 2010
@@ -58,7 +58,7 @@
msg.setOpcode(Opcode::QUERY());
msg.setRcode(Rcode::NOERROR());
if (recursive_bit) {
- msg.setHeaderFlag(MessageFlag::RD()); // set recursive bit
+ msg.setHeaderFlag(Message::HEADERFLAG_RD); // set recursive bit
}
msg.addQuestion(Question(Name(name),
@@ -122,9 +122,10 @@
rmsg.fromWire(ibuffer);
if (!verbose) {
- for (RRsetIterator it = rmsg.beginSection(Section::ANSWER());
- it != rmsg.endSection(Section::ANSWER());
- ++it) {
+ for (RRsetIterator it =
+ rmsg.beginSection(Message::SECTION_ANSWER);
+ it != rmsg.endSection(Message::SECTION_ANSWER);
+ ++it) {
if ((*it)->getType() != RRType::A()) {
continue;
}
Modified: branches/trac299/src/bin/loadzone/b10-loadzone.py.in
==============================================================================
--- branches/trac299/src/bin/loadzone/b10-loadzone.py.in (original)
+++ branches/trac299/src/bin/loadzone/b10-loadzone.py.in Sun Nov 7 11:01:06 2010
@@ -18,12 +18,12 @@
import sys; sys.path.append ('@@PYTHONPATH@@')
import re, getopt
import isc.datasrc
-import isc.utils.process
+import isc.util.process
from isc.datasrc.master import MasterFile
import time
import os
-isc.utils.process.rename()
+isc.util.process.rename()
#########################################################################
# usage: print usage note and exit
Modified: branches/trac299/src/bin/loadzone/tests/error/error.known
==============================================================================
--- branches/trac299/src/bin/loadzone/tests/error/error.known (original)
+++ branches/trac299/src/bin/loadzone/tests/error/error.known Sun Nov 7 11:01:06 2010
@@ -1,5 +1,5 @@
Error reading zone file: Cannot parse RR, No $ORIGIN: @ IN SOA ns hostmaster 1 3600 1800 1814400 3600
-Error reading zone file: $ORIGIN is not absolute in record:$ORIGIN com
+Error reading zone file: $ORIGIN is not absolute in record: $ORIGIN com
Error reading zone file: Cannot parse RR: $TL 300
Error reading zone file: Cannot parse RR: $OIGIN com.
Error loading database: Error while loading com.: Cannot parse RR: $INLUDE file.txt
Modified: branches/trac299/src/bin/msgq/msgq.py.in
==============================================================================
--- branches/trac299/src/bin/msgq/msgq.py.in (original)
+++ branches/trac299/src/bin/msgq/msgq.py.in Sun Nov 7 11:01:06 2010
@@ -31,11 +31,11 @@
import pprint
import random
from optparse import OptionParser, OptionValueError
-import isc.utils.process
+import isc.util.process
import isc.cc
-isc.utils.process.rename()
+isc.util.process.rename()
# This is the version that gets displayed to the user.
__version__ = "v20091030 (Paving the DNS Parking Lot)"
Modified: branches/trac299/src/bin/msgq/tests/Makefile.am
==============================================================================
--- branches/trac299/src/bin/msgq/tests/Makefile.am (original)
+++ branches/trac299/src/bin/msgq/tests/Makefile.am Sun Nov 7 11:01:06 2010
@@ -8,6 +8,7 @@
for pytest in $(PYTESTS) ; do \
echo Running test: $$pytest ; \
env PYTHONPATH=$(abs_top_builddir)/src/bin/msgq:$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python \
+ BIND10_TEST_SOCKET_FILE=$(builddir)/test_msgq_socket.sock \
$(PYCOVERAGE) $(abs_srcdir)/$$pytest || exit ; \
done
Modified: branches/trac299/src/bin/msgq/tests/msgq_test.py
==============================================================================
--- branches/trac299/src/bin/msgq/tests/msgq_test.py (original)
+++ branches/trac299/src/bin/msgq/tests/msgq_test.py Sun Nov 7 11:01:06 2010
@@ -79,9 +79,14 @@
def test_open_socket_default(self):
env_var = None
+ orig_socket_file = None
if "BIND10_MSGQ_SOCKET_FILE" in os.environ:
env_var = os.environ["BIND10_MSGQ_SOCKET_FILE"]
del os.environ["BIND10_MSGQ_SOCKET_FILE"]
+ # temporarily replace the class "default" not to be disrupted by
+ # any running BIND 10 instance.
+ if "BIND10_TEST_SOCKET_FILE" in os.environ:
+ MsgQ.SOCKET_FILE = os.environ["BIND10_TEST_SOCKET_FILE"]
socket_file = MsgQ.SOCKET_FILE
self.assertFalse(os.path.exists(socket_file))
msgq = MsgQ();
@@ -96,6 +101,8 @@
pass
if env_var is not None:
os.environ["BIND10_MSGQ_SOCKET_FILE"] = env_var
+ if orig_socket_file is not None:
+ MsgQ.SOCKET_FILE = orig_socket_file
def test_open_socket_bad(self):
msgq = MsgQ("/does/not/exist")
Modified: branches/trac299/src/bin/stats/stats.py.in
==============================================================================
--- branches/trac299/src/bin/stats/stats.py.in (original)
+++ branches/trac299/src/bin/stats/stats.py.in Sun Nov 7 11:01:06 2010
@@ -35,8 +35,8 @@
pass #@@REMOVED@@
# for setproctitle
-import isc.utils.process
-isc.utils.process.rename()
+import isc.util.process
+isc.util.process.rename()
# If B10_FROM_BUILD is set in the environment, we use data files
# from a directory relative to that, otherwise we use the ones
@@ -233,7 +233,7 @@
"""
check the cc chanel
"""
- return self.cc_session.check_command()
+ return self.cc_session.check_command(False)
def config_handler(self, new_config):
"""
Modified: branches/trac299/src/bin/stats/stats_stub.py.in
==============================================================================
--- branches/trac299/src/bin/stats/stats_stub.py.in (original)
+++ branches/trac299/src/bin/stats/stats_stub.py.in Sun Nov 7 11:01:06 2010
@@ -27,8 +27,8 @@
from stats import get_datetime
# for setproctitle
-import isc.utils.process
-isc.utils.process.rename()
+import isc.util.process
+isc.util.process.rename()
# If B10_FROM_BUILD is set in the environment, we use data files
# from a directory relative to that, otherwise we use the ones
Modified: branches/trac299/src/bin/stats/tests/isc/Makefile.am
==============================================================================
--- branches/trac299/src/bin/stats/tests/isc/Makefile.am (original)
+++ branches/trac299/src/bin/stats/tests/isc/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,3 +1,3 @@
-SUBDIRS = cc config utils
+SUBDIRS = cc config util
EXTRA_DIST = __init__.py
CLEANFILES = __init__.pyc
Modified: branches/trac299/src/bin/stats/tests/isc/config/ccsession.py
==============================================================================
--- branches/trac299/src/bin/stats/tests/isc/config/ccsession.py (original)
+++ branches/trac299/src/bin/stats/tests/isc/config/ccsession.py Sun Nov 7 11:01:06 2010
@@ -90,8 +90,8 @@
def close(self):
self._session.close()
- def check_command(self):
- msg, env = self._session.group_recvmsg(False)
+ def check_command(self, nonblock=True):
+ msg, env = self._session.group_recvmsg(nonblock)
if not msg or 'result' in msg:
return
cmd, arg = parse_command(msg)
Modified: branches/trac299/src/bin/tests/process_rename_test.py.in
==============================================================================
--- branches/trac299/src/bin/tests/process_rename_test.py.in (original)
+++ branches/trac299/src/bin/tests/process_rename_test.py.in Sun Nov 7 11:01:06 2010
@@ -17,7 +17,7 @@
import unittest
import os
import os.path
-import isc.utils.process
+import isc.util.process
import re
class TestRename(unittest.TestCase):
@@ -28,7 +28,7 @@
data = ''.join(open(filename).readlines())
prettyname = 'src' + filename[filename.rfind('../') + 2:]
self.assertTrue(fun.search(data),
- "Didn't find a call to isc.utils.process.rename in " + prettyname)
+ "Didn't find a call to isc.util.process.rename in " + prettyname)
def test_calls(self):
"""
@@ -45,7 +45,7 @@
# Script name regular expression
scripts = re.compile(r'((\w|[-.0-9])+)')
# Line with the call
- fun = re.compile(r'^\s*isc\.utils\.process\.rename\s*\(.*\)\s*(|#.*)$',
+ fun = re.compile(r'^\s*isc\.util\.process\.rename\s*\(.*\)\s*(|#.*)$',
re.MULTILINE)
# Find all Makefile and extract names of scripts
Modified: branches/trac299/src/bin/usermgr/b10-cmdctl-usermgr.py.in
==============================================================================
--- branches/trac299/src/bin/usermgr/b10-cmdctl-usermgr.py.in (original)
+++ branches/trac299/src/bin/usermgr/b10-cmdctl-usermgr.py.in Sun Nov 7 11:01:06 2010
@@ -25,9 +25,9 @@
import getpass
import getopt
import sys
-import isc.utils.process
+import isc.util.process
-isc.utils.process.rename()
+isc.util.process.rename()
VERSION_NUMBER = 'bind10'
DEFAULT_FILE = 'cmdctl-accounts.csv'
Modified: branches/trac299/src/bin/xfrin/tests/xfrin_test.py
==============================================================================
--- branches/trac299/src/bin/xfrin/tests/xfrin_test.py (original)
+++ branches/trac299/src/bin/xfrin/tests/xfrin_test.py Sun Nov 7 11:01:06 2010
@@ -135,9 +135,9 @@
resp.set_opcode(Opcode.QUERY())
resp.set_rcode(rcode)
if response:
- resp.set_header_flag(MessageFlag.QR())
+ resp.set_header_flag(Message.HEADERFLAG_QR)
[resp.add_question(q) for q in questions]
- [resp.add_rrset(Section.ANSWER(), a) for a in answers]
+ [resp.add_rrset(Message.SECTION_ANSWER, a) for a in answers]
renderer = MessageRenderer()
resp.to_wire(renderer)
Modified: branches/trac299/src/bin/xfrin/xfrin.py.in
==============================================================================
--- branches/trac299/src/bin/xfrin/xfrin.py.in (original)
+++ branches/trac299/src/bin/xfrin/xfrin.py.in Sun Nov 7 11:01:06 2010
@@ -30,8 +30,8 @@
from optparse import OptionParser, OptionValueError
from isc.config.ccsession import *
from isc.notify import notify_out
+import isc.util.process
import isc.net.parse
-import isc.utils.process
try:
from pydnspp import *
except ImportError as e:
@@ -39,7 +39,7 @@
# must keep running, so we warn about it and move forward.
sys.stderr.write('[b10-xfrin] failed to import DNS module: %s\n' % str(e))
-isc.utils.process.rename()
+isc.util.process.rename()
# If B10_FROM_BUILD is set in the environment, we use data files
# from a directory relative to that, otherwise we use the ones
@@ -240,7 +240,7 @@
if msg_rcode != Rcode.NOERROR():
raise XfrinException('error response: %s' % msg_rcode.to_text())
- if not msg.get_header_flag(MessageFlag.QR()):
+ if not msg.get_header_flag(Message.HEADERFLAG_QR):
raise XfrinException('response is not a response ')
if msg.get_qid() != self._query_id:
@@ -251,10 +251,10 @@
self._check_response_header(msg)
- if msg.get_rr_count(Section.ANSWER()) == 0:
+ if msg.get_rr_count(Message.SECTION_ANSWER) == 0:
raise XfrinException('answer section is empty')
- if msg.get_rr_count(Section.QUESTION()) > 1:
+ if msg.get_rr_count(Message.SECTION_QUESTION) > 1:
raise XfrinException('query section count greater than 1')
def _handle_answer_section(self, answer_section):
@@ -294,7 +294,7 @@
msg.from_wire(recvdata)
self._check_response_status(msg)
- answer_section = msg.get_section(Section.ANSWER())
+ answer_section = msg.get_section(Message.SECTION_ANSWER)
for rr in self._handle_answer_section(answer_section):
yield rr
Modified: branches/trac299/src/bin/xfrout/tests/xfrout_test.py
==============================================================================
--- branches/trac299/src/bin/xfrout/tests/xfrout_test.py (original)
+++ branches/trac299/src/bin/xfrout/tests/xfrout_test.py Sun Nov 7 11:01:06 2010
@@ -131,7 +131,7 @@
self.assertEqual(msg.get_qid(), qid)
self.assertEqual(msg.get_opcode(), opcode)
self.assertEqual(msg.get_rcode(), rcode)
- self.assertTrue(msg.get_header_flag(MessageFlag.AA()))
+ self.assertTrue(msg.get_header_flag(Message.HEADERFLAG_AA))
def test_reply_query_with_format_error(self):
@@ -156,12 +156,12 @@
self.xfrsess._send_message_with_last_soa(msg, self.sock, rrset_soa, 0)
get_msg = self.sock.read_msg()
- self.assertEqual(get_msg.get_rr_count(Section.QUESTION()), 1)
- self.assertEqual(get_msg.get_rr_count(Section.ANSWER()), 1)
- self.assertEqual(get_msg.get_rr_count(Section.AUTHORITY()), 0)
+ self.assertEqual(get_msg.get_rr_count(Message.SECTION_QUESTION), 1)
+ self.assertEqual(get_msg.get_rr_count(Message.SECTION_ANSWER), 1)
+ self.assertEqual(get_msg.get_rr_count(Message.SECTION_AUTHORITY), 0)
#answer_rrset_iter = section_iter(get_msg, section.ANSWER())
- answer = get_msg.get_section(Section.ANSWER())[0]#answer_rrset_iter.get_rrset()
+ answer = get_msg.get_section(Message.SECTION_ANSWER)[0]#answer_rrset_iter.get_rrset()
self.assertEqual(answer.get_name().to_text(), "example.com.")
self.assertEqual(answer.get_class(), RRClass("IN"))
self.assertEqual(answer.get_type().to_text(), "SOA")
@@ -176,7 +176,7 @@
msg = self.getmsg()
msg.make_response()
- msg.add_rrset(Section.ANSWER(), rrset_a)
+ msg.add_rrset(Message.SECTION_ANSWER, rrset_a)
# give the function a value that is larger than MAX-len(rrset)
self.xfrsess._send_message_with_last_soa(msg, self.sock, rrset_soa, 65520)
@@ -184,11 +184,11 @@
# (1 with the rrset we added manually, and 1 that triggered
# the sending in _with_last_soa)
get_msg = self.sock.read_msg()
- self.assertEqual(get_msg.get_rr_count(Section.QUESTION()), 1)
- self.assertEqual(get_msg.get_rr_count(Section.ANSWER()), 1)
- self.assertEqual(get_msg.get_rr_count(Section.AUTHORITY()), 0)
-
- answer = get_msg.get_section(Section.ANSWER())[0]
+ self.assertEqual(get_msg.get_rr_count(Message.SECTION_QUESTION), 1)
+ self.assertEqual(get_msg.get_rr_count(Message.SECTION_ANSWER), 1)
+ self.assertEqual(get_msg.get_rr_count(Message.SECTION_AUTHORITY), 0)
+
+ answer = get_msg.get_section(Message.SECTION_ANSWER)[0]
self.assertEqual(answer.get_name().to_text(), "example.com.")
self.assertEqual(answer.get_class(), RRClass("IN"))
self.assertEqual(answer.get_type().to_text(), "A")
@@ -196,12 +196,12 @@
self.assertEqual(rdata[0].to_text(), "192.0.2.1")
get_msg = self.sock.read_msg()
- self.assertEqual(get_msg.get_rr_count(Section.QUESTION()), 0)
- self.assertEqual(get_msg.get_rr_count(Section.ANSWER()), 1)
- self.assertEqual(get_msg.get_rr_count(Section.AUTHORITY()), 0)
-
- #answer_rrset_iter = section_iter(get_msg, section.ANSWER())
- answer = get_msg.get_section(Section.ANSWER())[0]
+ self.assertEqual(get_msg.get_rr_count(Message.SECTION_QUESTION), 0)
+ self.assertEqual(get_msg.get_rr_count(Message.SECTION_ANSWER), 1)
+ self.assertEqual(get_msg.get_rr_count(Message.SECTION_AUTHORITY), 0)
+
+ #answer_rrset_iter = section_iter(get_msg, Message.SECTION_ANSWER)
+ answer = get_msg.get_section(Message.SECTION_ANSWER)[0]
self.assertEqual(answer.get_name().to_text(), "example.com.")
self.assertEqual(answer.get_class(), RRClass("IN"))
self.assertEqual(answer.get_type().to_text(), "SOA")
@@ -297,7 +297,7 @@
sqlite3_ds.get_zone_datas = get_zone_datas
self.xfrsess._reply_xfrout_query(self.getmsg(), self.sock, "example.com.")
reply_msg = self.sock.read_msg()
- self.assertEqual(reply_msg.get_rr_count(Section.ANSWER()), 2)
+ self.assertEqual(reply_msg.get_rr_count(Message.SECTION_ANSWER), 2)
class MyCCSession():
def __init__(self):
Modified: branches/trac299/src/bin/xfrout/xfrout.py.in
==============================================================================
--- branches/trac299/src/bin/xfrout/xfrout.py.in (original)
+++ branches/trac299/src/bin/xfrout/xfrout.py.in Sun Nov 7 11:01:06 2010
@@ -30,11 +30,13 @@
from isc.log.log import *
from isc.cc import SessionError, SessionTimeout
from isc.notify import notify_out
-import isc.utils.process
+import isc.util.process
import socket
import select
import errno
from optparse import OptionParser, OptionValueError
+from isc.util import socketserver_mixin
+
try:
from libxfr_python import *
from pydnspp import *
@@ -43,7 +45,7 @@
# must keep running, so we warn about it and move forward.
sys.stderr.write('[b10-xfrout] failed to import DNS or XFR module: %s\n' % str(e))
-isc.utils.process.rename()
+isc.util.process.rename()
if "B10_FROM_BUILD" in os.environ:
SPECFILE_PATH = os.environ["B10_FROM_BUILD"] + "/src/bin/xfrout"
@@ -257,8 +259,8 @@
msg.set_qid(qid)
msg.set_opcode(opcode)
msg.set_rcode(rcode)
- msg.set_header_flag(MessageFlag.AA())
- msg.set_header_flag(MessageFlag.QR())
+ msg.set_header_flag(Message.HEADERFLAG_AA)
+ msg.set_header_flag(Message.HEADERFLAG_QR)
return msg
def _create_rrset_from_db_record(self, record):
@@ -278,11 +280,11 @@
rrset_len = get_rrset_len(rrset_soa)
if message_upper_len + rrset_len < XFROUT_MAX_MESSAGE_SIZE:
- msg.add_rrset(Section.ANSWER(), rrset_soa)
+ msg.add_rrset(Message.SECTION_ANSWER, rrset_soa)
else:
self._send_message(sock_fd, msg)
msg = self._clear_message(msg)
- msg.add_rrset(Section.ANSWER(), rrset_soa)
+ msg.add_rrset(Message.SECTION_ANSWER, rrset_soa)
self._send_message(sock_fd, msg)
@@ -290,10 +292,10 @@
def _reply_xfrout_query(self, msg, sock_fd, zone_name):
#TODO, there should be a better way to insert rrset.
msg.make_response()
- msg.set_header_flag(MessageFlag.AA())
+ msg.set_header_flag(Message.HEADERFLAG_AA)
soa_record = sqlite3_ds.get_zone_soa(zone_name, self.server.get_db_file())
rrset_soa = self._create_rrset_from_db_record(soa_record)
- msg.add_rrset(Section.ANSWER(), rrset_soa)
+ msg.add_rrset(Message.SECTION_ANSWER, rrset_soa)
message_upper_len = get_rrset_len(rrset_soa)
@@ -313,23 +315,24 @@
# may have reached the limit
rrset_len = get_rrset_len(rrset_)
if message_upper_len + rrset_len < XFROUT_MAX_MESSAGE_SIZE:
- msg.add_rrset(Section.ANSWER(), rrset_)
+ msg.add_rrset(Message.SECTION_ANSWER, rrset_)
message_upper_len += rrset_len
continue
self._send_message(sock_fd, msg)
msg = self._clear_message(msg)
- msg.add_rrset(Section.ANSWER(), rrset_) # Add the rrset to the new message
+ msg.add_rrset(Message.SECTION_ANSWER, rrset_) # Add the rrset to the new message
message_upper_len = rrset_len
self._send_message_with_last_soa(msg, sock_fd, rrset_soa, message_upper_len)
-class UnixSockServer(ThreadingUnixStreamServer):
+class UnixSockServer(socketserver_mixin.NoPollMixIn, ThreadingUnixStreamServer):
'''The unix domain socket server which accept xfr query sent from auth server.'''
def __init__(self, sock_file, handle_class, shutdown_event, config_data, cc, log):
self._remove_unused_sock_file(sock_file)
self._sock_file = sock_file
+ socketserver_mixin.NoPollMixIn.__init__(self)
ThreadingUnixStreamServer.__init__(self, sock_file, handle_class)
self._lock = threading.Lock()
self._transfers_counter = 0
@@ -376,7 +379,7 @@
def shutdown(self):
self._write_sock.send(b"shutdown") #terminate the xfrout session thread
- ThreadingUnixStreamServer.shutdown(self)
+ super().shutdown() # call the shutdown() of class socketserver_mixin.NoPollMixIn
try:
os.unlink(self._sock_file)
except Exception as e:
@@ -417,26 +420,6 @@
self._lock.acquire()
self._transfers_counter -= 1
self._lock.release()
-
-def listen_on_xfr_query(unix_socket_server):
- '''Listen xfr query in one single thread. Polls for shutdown
- every 0.1 seconds, is there a better time?
- '''
-
- while True:
- try:
- unix_socket_server.serve_forever(poll_interval = 0.1)
- except select.error as err:
- # serve_forever() calls select.select(), which can be
- # interrupted.
- # If it is interrupted, it raises select.error with the
- # errno set to EINTR. We ignore this case, and let the
- # normal program flow continue by trying serve_forever()
- # again.
- if err.args[0] != errno.EINTR: raise
- else:
- # serve_forever() loop has been stoped normally.
- break
class XfroutServer:
def __init__(self):
@@ -459,7 +442,7 @@
self._unix_socket_server = UnixSockServer(self._listen_sock_file, XfroutSession,
self._shutdown_event, self._config_data,
self._cc, self._log);
- listener = threading.Thread(target = listen_on_xfr_query, args = (self._unix_socket_server,))
+ listener = threading.Thread(target=self._unix_socket_server.serve_forever)
listener.start()
def _start_notifier(self):
Modified: branches/trac299/src/bin/zonemgr/tests/zonemgr_test.py
==============================================================================
--- branches/trac299/src/bin/zonemgr/tests/zonemgr_test.py (original)
+++ branches/trac299/src/bin/zonemgr/tests/zonemgr_test.py Sun Nov 7 11:01:06 2010
@@ -506,6 +506,15 @@
params1 = {"zone_class" : "CH"}
self.assertRaises(ZonemgrException, self.zonemgr._parse_cmd_params, params2, ZONE_NOTIFY_COMMAND)
+ def test_config_data_check(self):
+ # jitter should not be bigger than half of the original value
+ config_data2 = {"jitter_scope" : 0.2}
+ config_data3 = {"jitter_scope" : 0.6}
+ self.zonemgr._config_data_check(config_data2)
+ self.assertEqual(0.2, config_data2.get("jitter_scope"))
+ self.zonemgr._config_data_check(config_data3)
+ self.assertEqual(0.5, config_data3.get("jitter_scope"))
+
def tearDown(self):
pass
Modified: branches/trac299/src/bin/zonemgr/zonemgr.py.in
==============================================================================
--- branches/trac299/src/bin/zonemgr/zonemgr.py.in (original)
+++ branches/trac299/src/bin/zonemgr/zonemgr.py.in Sun Nov 7 11:01:06 2010
@@ -37,9 +37,9 @@
from isc.datasrc import sqlite3_ds
from optparse import OptionParser, OptionValueError
from isc.config.ccsession import *
-import isc.utils.process
-
-isc.utils.process.rename()
+import isc.util.process
+
+isc.util.process.rename()
# If B10_FROM_BUILD is set in the environment, we use data files
# from a directory relative to that, otherwise we use the ones
@@ -435,10 +435,7 @@
self.command_handler)
self._module_cc.add_remote_config(AUTH_SPECFILE_LOCATION)
self._config_data = self._module_cc.get_full_config()
- # jitter should not be bigger than half of the original value
- if self._config_data.get('jitter_scope') > 0.5:
- self._config_data['jitter_scope'] = 0.5
- log_msg("[b10-zonemgr] jitter_scope should not be bigger than 0.5.")
+ self._config_data_check(self._config_data)
self._module_cc.start()
def get_db_file(self):
@@ -468,17 +465,22 @@
if key not in self._config_data:
answer = create_answer(1, "Unknown config data: " + str(key))
continue
- # jitter should not be bigger than half of the original value
- if key == 'jitter_scope':
- if new_config.get(key) > 0.5:
- new_config[key] = 0.5
- log_msg("[b10-zonemgr] jitter_scope should not be bigger than 0.5.")
self._config_data[key] = new_config[key]
+ self._config_data_check(self._config_data)
if (self._zone_refresh):
self._zone_refresh.update_config_data(self._config_data)
return answer
+
+ def _config_data_check(self, config_data):
+ """Check whether the new config data is valid or
+ not. """
+ # jitter should not be bigger than half of the original value
+ if config_data.get('jitter_scope') > 0.5:
+ config_data['jitter_scope'] = 0.5
+ log_msg("[b10-zonemgr] jitter_scope is too big, its value will "
+ "be set to 0.5")
def _parse_cmd_params(self, args, command):
zone_name = args.get("zone_name")
Modified: branches/trac299/src/lib/bench/Makefile.am
==============================================================================
--- branches/trac299/src/lib/bench/Makefile.am (original)
+++ branches/trac299/src/lib/bench/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,6 +1,7 @@
SUBDIRS = . tests example
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS)
CLEANFILES = *.gcno *.gcda
Modified: branches/trac299/src/lib/bench/example/search_bench.cc
==============================================================================
--- branches/trac299/src/lib/bench/example/search_bench.cc (original)
+++ branches/trac299/src/lib/bench/example/search_bench.cc Sun Nov 7 11:01:06 2010
@@ -16,6 +16,7 @@
#include <unistd.h> // for getpid
+#include <cassert>
#include <cstdlib> // for rand
#include <algorithm>
#include <iostream>
@@ -42,9 +43,11 @@
vector<int>::const_iterator end_key = keys_.end();
for (iter = keys_.begin(); iter != end_key; ++iter) {
if (Sorted) {
- binary_search(data_.begin(), data_.end(), *iter);
+ // perform simple sanity check with assert() to ensure
+ // compiler optimization won't skip the search.
+ assert(binary_search(data_.begin(), data_.end(), *iter));
} else {
- find(data_.begin(), data_.end(), *iter);
+ assert(find(data_.begin(), data_.end(), *iter) != data_.end());
}
}
return (keys_.size());
@@ -63,7 +66,7 @@
vector<int>::const_iterator iter;
vector<int>::const_iterator end_key = keys_.end();
for (iter = keys_.begin(); iter != end_key; ++iter) {
- data_.find(*iter);
+ assert(data_.find(*iter) != data_.end());
}
return (keys_.size());
}
Modified: branches/trac299/src/lib/bench/tests/Makefile.am
==============================================================================
--- branches/trac299/src/lib/bench/tests/Makefile.am (original)
+++ branches/trac299/src/lib/bench/tests/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,4 +1,5 @@
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\"
AM_CXXFLAGS = $(B10_CXXFLAGS)
Modified: branches/trac299/src/lib/bench/tests/loadquery_unittest.cc
==============================================================================
--- branches/trac299/src/lib/bench/tests/loadquery_unittest.cc (original)
+++ branches/trac299/src/lib/bench/tests/loadquery_unittest.cc Sun Nov 7 11:01:06 2010
@@ -82,12 +82,12 @@
EXPECT_EQ(0, message.getQid());
EXPECT_EQ(Opcode::QUERY(), message.getOpcode());
EXPECT_EQ(Rcode::NOERROR(), message.getRcode());
- EXPECT_FALSE(message.getHeaderFlag(MessageFlag::QR()));
- EXPECT_FALSE(message.getHeaderFlag(MessageFlag::AA()));
- EXPECT_EQ(1, message.getRRCount(Section::QUESTION()));
- EXPECT_EQ(0, message.getRRCount(Section::ANSWER()));
- EXPECT_EQ(0, message.getRRCount(Section::AUTHORITY()));
- EXPECT_EQ(0, message.getRRCount(Section::ADDITIONAL()));
+ EXPECT_FALSE(message.getHeaderFlag(Message::HEADERFLAG_QR));
+ EXPECT_FALSE(message.getHeaderFlag(Message::HEADERFLAG_AA));
+ EXPECT_EQ(1, message.getRRCount(Message::SECTION_QUESTION));
+ EXPECT_EQ(0, message.getRRCount(Message::SECTION_ANSWER));
+ EXPECT_EQ(0, message.getRRCount(Message::SECTION_AUTHORITY));
+ EXPECT_EQ(0, message.getRRCount(Message::SECTION_ADDITIONAL));
// Check if the question matches our original data, if the expected
// data is given.
Modified: branches/trac299/src/lib/cc/Makefile.am
==============================================================================
--- branches/trac299/src/lib/cc/Makefile.am (original)
+++ branches/trac299/src/lib/cc/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,15 +1,22 @@
SUBDIRS = . tests
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
AM_CXXFLAGS = $(B10_CXXFLAGS)
-# ASIO header files used in session.cc will trigger "unused-parameter"
-# error. Unfortunately there doesn't seem to be an easy way to selectively
+if USE_GXX
+# ASIO header files used in session.cc will trigger the "unused-parameter"
+# warning. Unfortunately there doesn't seem to be an easy way to selectively
# avoid the error. As a short term workaround we suppress this warning
# for the entire this module. See also src/bin/auth/Makefile.am.
-if USE_GXX
AM_CXXFLAGS += -Wno-unused-parameter
+endif
+if USE_CLANGPP
+# Likewise, ASIO header files will trigger various warnings with clang++.
+# Worse, there doesn't seem to be any option to disable one of the warnings
+# in any way, so we need to turn off -Werror.
+AM_CXXFLAGS += -Wno-error
endif
lib_LTLIBRARIES = libcc.la
Modified: branches/trac299/src/lib/cc/tests/Makefile.am
==============================================================================
--- branches/trac299/src/lib/cc/tests/Makefile.am (original)
+++ branches/trac299/src/lib/cc/tests/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,9 +1,13 @@
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
AM_CXXFLAGS = $(B10_CXXFLAGS)
if USE_GXX #XXX: see ../Makefile.am
AM_CXXFLAGS += -Wno-unused-parameter
+endif
+if USE_CLANGPP
+AM_CXXFLAGS += -Wno-error
endif
if USE_STATIC_LINK
Modified: branches/trac299/src/lib/cc/tests/data_unittests.cc
==============================================================================
--- branches/trac299/src/lib/cc/tests/data_unittests.cc (original)
+++ branches/trac299/src/lib/cc/tests/data_unittests.cc Sun Nov 7 11:01:06 2010
@@ -247,7 +247,7 @@
EXPECT_EQ(b, true);
b = false;
EXPECT_TRUE(el->setValue(b));
- EXPECT_EQ(false, el->boolValue());
+ EXPECT_FALSE(el->boolValue());
el = Element::create("foo");
EXPECT_THROW(el->intValue(), TypeError);
Modified: branches/trac299/src/lib/config/Makefile.am
==============================================================================
--- branches/trac299/src/lib/config/Makefile.am (original)
+++ branches/trac299/src/lib/config/Makefile.am Sun Nov 7 11:01:06 2010
@@ -2,6 +2,7 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS) -Wno-strict-aliasing
lib_LTLIBRARIES = libcfgclient.la
Modified: branches/trac299/src/lib/config/tests/Makefile.am
==============================================================================
--- branches/trac299/src/lib/config/tests/Makefile.am (original)
+++ branches/trac299/src/lib/config/tests/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,6 +1,7 @@
SUBDIRS = testdata .
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS)
# see src/lib/cc/Makefile.am for -Wno-unused-parameter
@@ -25,8 +26,8 @@
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
run_unittests_LDADD = $(GTEST_LDADD)
+run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
-run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
run_unittests_LDADD += libfake_session.la
run_unittests_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
Modified: branches/trac299/src/lib/config/tests/ccsession_unittests.cc
==============================================================================
--- branches/trac299/src/lib/config/tests/ccsession_unittests.cc (original)
+++ branches/trac299/src/lib/config/tests/ccsession_unittests.cc Sun Nov 7 11:01:06 2010
@@ -150,9 +150,9 @@
}
TEST_F(CCSessionTest, session1) {
- EXPECT_EQ(false, session.haveSubscription("Spec1", "*"));
+ EXPECT_FALSE(session.haveSubscription("Spec1", "*"));
ModuleCCSession mccs(ccspecfile("spec1.spec"), session, NULL, NULL);
- EXPECT_EQ(true, session.haveSubscription("Spec1", "*"));
+ EXPECT_TRUE(session.haveSubscription("Spec1", "*"));
EXPECT_EQ(1, session.getMsgQueue()->size());
ConstElementPtr msg;
@@ -165,9 +165,9 @@
}
TEST_F(CCSessionTest, session2) {
- EXPECT_EQ(false, session.haveSubscription("Spec2", "*"));
+ EXPECT_FALSE(session.haveSubscription("Spec2", "*"));
ModuleCCSession mccs(ccspecfile("spec2.spec"), session, NULL, NULL);
- EXPECT_EQ(true, session.haveSubscription("Spec2", "*"));
+ EXPECT_TRUE(session.haveSubscription("Spec2", "*"));
EXPECT_EQ(1, session.getMsgQueue()->size());
ConstElementPtr msg;
@@ -211,10 +211,10 @@
// client will ask for config
session.getMessages()->add(createAnswer(0, el("{}")));
- EXPECT_EQ(false, session.haveSubscription("Spec2", "*"));
+ EXPECT_FALSE(session.haveSubscription("Spec2", "*"));
ModuleCCSession mccs(ccspecfile("spec2.spec"), session, my_config_handler,
my_command_handler);
- EXPECT_EQ(true, session.haveSubscription("Spec2", "*"));
+ EXPECT_TRUE(session.haveSubscription("Spec2", "*"));
EXPECT_EQ(2, session.getMsgQueue()->size());
ConstElementPtr msg;
@@ -235,10 +235,10 @@
// client will ask for config
session.getMessages()->add(createAnswer(0, el("{}")));
- EXPECT_EQ(false, session.haveSubscription("Spec2", "*"));
+ EXPECT_FALSE(session.haveSubscription("Spec2", "*"));
ModuleCCSession mccs(ccspecfile("spec2.spec"), session, my_config_handler,
my_command_handler);
- EXPECT_EQ(true, session.haveSubscription("Spec2", "*"));
+ EXPECT_TRUE(session.haveSubscription("Spec2", "*"));
EXPECT_EQ(2, session.getMsgQueue()->size());
ConstElementPtr msg;
@@ -340,23 +340,23 @@
int item1;
ModuleCCSession mccs(ccspecfile("spec1.spec"), session, NULL, NULL);
- EXPECT_EQ(true, session.haveSubscription("Spec1", "*"));
+ EXPECT_TRUE(session.haveSubscription("Spec1", "*"));
// first simply connect, with no config values, and see we get
// the default
session.getMessages()->add(createAnswer(0, el("{}")));
- EXPECT_EQ(false, session.haveSubscription("Spec2", "*"));
+ EXPECT_FALSE(session.haveSubscription("Spec2", "*"));
module_name = mccs.addRemoteConfig(ccspecfile("spec2.spec"));
EXPECT_EQ("Spec2", module_name);
- EXPECT_EQ(true, session.haveSubscription("Spec2", "*"));
+ EXPECT_TRUE(session.haveSubscription("Spec2", "*"));
item1 = mccs.getRemoteConfigValue(module_name, "item1")->intValue();
EXPECT_EQ(1, item1);
// Remove it and see we get an error asking for a config value
mccs.removeRemoteConfig(module_name);
- EXPECT_EQ(false, session.haveSubscription("Spec2", "*"));
+ EXPECT_FALSE(session.haveSubscription("Spec2", "*"));
EXPECT_THROW(mccs.getRemoteConfigValue(module_name, "item1"), CCSessionError);
// Now re-add it, with a specific config value, and see we get that
@@ -387,9 +387,9 @@
// client will ask for config
session.getMessages()->add(createAnswer(0, el("{ }")));
- EXPECT_EQ(false, session.haveSubscription("Spec2", "*"));
+ EXPECT_FALSE(session.haveSubscription("Spec2", "*"));
ModuleCCSession mccs(ccspecfile("spec2.spec"), session, my_config_handler, my_command_handler);
- EXPECT_EQ(true, session.haveSubscription("Spec2", "*"));
+ EXPECT_TRUE(session.haveSubscription("Spec2", "*"));
EXPECT_EQ(2, session.getMsgQueue()->size());
ConstElementPtr msg;
Modified: branches/trac299/src/lib/datasrc/Makefile.am
==============================================================================
--- branches/trac299/src/lib/datasrc/Makefile.am (original)
+++ branches/trac299/src/lib/datasrc/Makefile.am Sun Nov 7 11:01:06 2010
@@ -2,6 +2,7 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CPPFLAGS += $(SQLITE_CFLAGS)
AM_CXXFLAGS = $(B10_CXXFLAGS)
Modified: branches/trac299/src/lib/datasrc/data_source.cc
==============================================================================
--- branches/trac299/src/lib/datasrc/data_source.cc (original)
+++ branches/trac299/src/lib/datasrc/data_source.cc Sun Nov 7 11:01:06 2010
@@ -101,14 +101,14 @@
const generic::NS& ns = dynamic_cast<const generic::NS&>(rd);
q.tasks().push(QueryTaskPtr(
new QueryTask(q, ns.getNSName(),
- Section::ADDITIONAL(),
+ Message::SECTION_ADDITIONAL,
QueryTask::GLUE_QUERY,
QueryTask::GETADDITIONAL)));
} else if (rrset->getType() == RRType::MX()) {
const generic::MX& mx = dynamic_cast<const generic::MX&>(rd);
q.tasks().push(QueryTaskPtr(
new QueryTask(q, mx.getMXName(),
- Section::ADDITIONAL(),
+ Message::SECTION_ADDITIONAL,
QueryTask::NOGLUE_QUERY,
QueryTask::GETADDITIONAL)));
}
@@ -165,7 +165,7 @@
q.tasks().push(QueryTaskPtr(
new QueryTask(q, dynamic_cast<const generic::CNAME&>
(it->getCurrent()).getCname(),
- task->qtype, Section::ANSWER(),
+ task->qtype, Message::SECTION_ANSWER,
QueryTask::FOLLOWCNAME)));
}
@@ -473,16 +473,19 @@
// checking first to ensure that there isn't already an RRset with
// the same name and type.
inline void
-addToMessage(Query& q, const Section& sect, RRsetPtr rrset,
+addToMessage(Query& q, const Message::Section sect, RRsetPtr rrset,
bool no_dnssec = false)
{
Message& m = q.message();
if (no_dnssec) {
- if (rrset->getType() == RRType::RRSIG() || !m.hasRRset(sect, rrset)) {
+ if (rrset->getType() == RRType::RRSIG() ||
+ !m.hasRRset(sect, rrset->getName(), rrset->getClass(),
+ rrset->getType())) {
m.addRRset(sect, rrset, false);
}
} else {
- if (!m.hasRRset(sect, rrset)) {
+ if (!m.hasRRset(sect, rrset->getName(), rrset->getClass(),
+ rrset->getType())) {
m.addRRset(sect, rrset, q.wantDnssec());
}
}
@@ -498,7 +501,7 @@
if (rrset->getType() == RRType::DS() && !q.wantDnssec()) {
continue;
}
- addToMessage(q, Section::AUTHORITY(), rrset);
+ addToMessage(q, Message::SECTION_AUTHORITY, rrset);
getAdditional(q, rrset);
}
}
@@ -560,11 +563,11 @@
RRsetPtr r = ref.findRRset(RRType::DNAME(), q.qclass());
if (r != NULL) {
RRsetList syn;
- addToMessage(q, Section::ANSWER(), r);
- q.message().setHeaderFlag(MessageFlag::AA());
+ addToMessage(q, Message::SECTION_ANSWER, r);
+ q.message().setHeaderFlag(Message::HEADERFLAG_AA);
synthesizeCname(task, r, syn);
if (syn.size() == 1) {
- addToMessage(q, Section::ANSWER(),
+ addToMessage(q, Message::SECTION_ANSWER,
syn.findRRset(RRType::CNAME(), q.qclass()));
chaseCname(q, task, syn.findRRset(RRType::CNAME(),
q.qclass()));
@@ -582,7 +585,7 @@
// at the actual qname node.)
if (task->op == QueryTask::AUTH_QUERY &&
task->state == QueryTask::GETANSWER) {
- q.message().setHeaderFlag(MessageFlag::AA());
+ q.message().setHeaderFlag(Message::HEADERFLAG_AA);
}
return (false);
@@ -599,7 +602,7 @@
return (DataSrc::ERROR);
}
- addToMessage(q, Section::AUTHORITY(),
+ addToMessage(q, Message::SECTION_AUTHORITY,
soa.findRRset(RRType::SOA(), q.qclass()));
return (DataSrc::SUCCESS);
}
@@ -611,7 +614,7 @@
QueryTask newtask(q, name, RRType::NSEC(), QueryTask::SIMPLE_QUERY);
RETERR(doQueryTask(newtask, zoneinfo, nsec));
if (newtask.flags == 0) {
- addToMessage(q, Section::AUTHORITY(),
+ addToMessage(q, Message::SECTION_AUTHORITY,
nsec.findRRset(RRType::NSEC(), q.qclass()));
}
@@ -680,7 +683,7 @@
RRsetPtr rrset;
string hash1(nsec3->getHash(task->qname));
RETERR(getNsec3(q, zoneinfo, hash1, rrset));
- addToMessage(q, Section::AUTHORITY(), rrset);
+ addToMessage(q, Message::SECTION_AUTHORITY, rrset);
// If this is an NXRRSET or NOERROR/NODATA, we're done
if ((task->flags & DataSrc::TYPE_NOT_FOUND) != 0) {
@@ -705,7 +708,7 @@
// we don't want to use one until we find an exact match
RETERR(getNsec3(q, zoneinfo, hash2, rrset));
if (hash2 == nodehash) {
- addToMessage(q, Section::AUTHORITY(), rrset);
+ addToMessage(q, Message::SECTION_AUTHORITY, rrset);
break;
}
}
@@ -720,7 +723,7 @@
string hash3(nsec3->getHash(Name("*").concatenate(enclosure)));
RETERR(getNsec3(q, zoneinfo, hash3, rrset));
if (hash3 != hash1 && hash3 != hash2) {
- addToMessage(q, Section::AUTHORITY(), rrset);
+ addToMessage(q, Message::SECTION_AUTHORITY, rrset);
}
} else {
Name nsecname(task->qname);
@@ -778,7 +781,7 @@
for (int i = 1; i <= diff; ++i) {
const Name& wname(star.concatenate(task->qname.split(i)));
- QueryTask newtask(q, wname, task->qtype, Section::ANSWER(),
+ QueryTask newtask(q, wname, task->qtype, Message::SECTION_ANSWER,
QueryTask::AUTH_QUERY);
result = doQueryTask(newtask, zoneinfo, wild);
if (result == DataSrc::SUCCESS) {
@@ -820,13 +823,13 @@
RRsetPtr rrset = wild.findRRset(RRType::CNAME(), q.qclass());
if (rrset != NULL) {
rrset->setName(task->qname);
- addToMessage(q, Section::ANSWER(), rrset);
+ addToMessage(q, Message::SECTION_ANSWER, rrset);
chaseCname(q, task, rrset);
}
} else {
BOOST_FOREACH (RRsetPtr rrset, wild) {
rrset->setName(task->qname);
- addToMessage(q, Section::ANSWER(), rrset);
+ addToMessage(q, Message::SECTION_ANSWER, rrset);
}
RRsetList auth;
@@ -855,7 +858,7 @@
// Process the query task queue. (The queue is initialized
// and the first task placed on it by the Query constructor.)
- m.clearHeaderFlag(MessageFlag::AA());
+ m.setHeaderFlag(Message::HEADERFLAG_AA, false);
while (!q.tasks().empty()) {
QueryTaskPtr task = q.tasks().front();
q.tasks().pop();
@@ -982,19 +985,19 @@
// The qname node contains an out-of-zone referral.
if (task->state == QueryTask::GETANSWER) {
RRsetList auth;
- m.clearHeaderFlag(MessageFlag::AA());
+ m.setHeaderFlag(Message::HEADERFLAG_AA, false);
if (!refQuery(q, task->qname, zoneinfo, auth)) {
m.setRcode(Rcode::SERVFAIL());
return;
}
BOOST_FOREACH (RRsetPtr rrset, auth) {
if (rrset->getType() == RRType::NS()) {
- addToMessage(q, Section::AUTHORITY(), rrset);
+ addToMessage(q, Message::SECTION_AUTHORITY, rrset);
} else if (rrset->getType() == task->qtype) {
- addToMessage(q, Section::ANSWER(), rrset);
+ addToMessage(q, Message::SECTION_ANSWER, rrset);
} else if (rrset->getType() == RRType::DS() &&
q.wantDnssec()) {
- addToMessage(q, Section::AUTHORITY(), rrset);
+ addToMessage(q, Message::SECTION_AUTHORITY, rrset);
}
getAdditional(q, rrset);
}
@@ -1063,13 +1066,14 @@
// space, signatures in additional section are
// optional.)
BOOST_FOREACH(RRsetPtr rrset, additional) {
- addToMessage(q, Section::ADDITIONAL(), rrset, true);
+ addToMessage(q, Message::SECTION_ADDITIONAL, rrset, true);
}
if (q.wantDnssec()) {
BOOST_FOREACH(RRsetPtr rrset, additional) {
if (rrset->getRRsig()) {
- addToMessage(q, Section::ADDITIONAL(), rrset->getRRsig(), true);
+ addToMessage(q, Message::SECTION_ADDITIONAL, rrset->getRRsig(),
+ true);
}
}
}
Modified: branches/trac299/src/lib/datasrc/query.cc
==============================================================================
--- branches/trac299/src/lib/datasrc/query.cc (original)
+++ branches/trac299/src/lib/datasrc/query.cc Sun Nov 7 11:01:06 2010
@@ -29,27 +29,31 @@
namespace datasrc {
QueryTask::QueryTask(const Query& qry, const isc::dns::Name& n,
- const isc::dns::RRType& t, const isc::dns::Section& sect) :
+ const isc::dns::RRType& t,
+ const isc::dns::Message::Section sect) :
q(qry), qname(n), qclass(qry.qclass()), qtype(t), section(sect),
op(AUTH_QUERY), state(GETANSWER), flags(0)
{}
QueryTask::QueryTask(const Query& qry, const isc::dns::Name& n,
- const isc::dns::RRType& t, const isc::dns::Section& sect,
+ const isc::dns::RRType& t,
+ const isc::dns::Message::Section sect,
const Op o) :
q(qry), qname(n), qclass(qry.qclass()), qtype(t), section(sect), op(o),
state(GETANSWER), flags(0)
{}
QueryTask::QueryTask(const Query& qry, const isc::dns::Name& n,
- const isc::dns::RRType& t, const isc::dns::Section& sect,
+ const isc::dns::RRType& t,
+ const isc::dns::Message::Section sect,
const State st) :
q(qry), qname(n), qclass(qry.qclass()), qtype(t), section(sect),
op(AUTH_QUERY), state(st), flags(0)
{}
QueryTask::QueryTask(const Query& qry, const isc::dns::Name& n,
- const isc::dns::RRType& t, const isc::dns::Section& sect,
+ const isc::dns::RRType& t,
+ const isc::dns::Message::Section sect,
const Op o, const State st) :
q(qry), qname(n), qclass(qry.qclass()), qtype(t), section(sect), op(o),
state(st), flags(0)
@@ -58,7 +62,7 @@
QueryTask::QueryTask(const Query& qry, const isc::dns::Name& n,
const isc::dns::RRType& t, const Op o) :
q(qry), qname(n), qclass(qry.qclass()), qtype(t),
- section(Section::ANSWER()), op(o), state(GETANSWER), flags(0)
+ section(Message::SECTION_ANSWER), op(o), state(GETANSWER), flags(0)
{
if (op != SIMPLE_QUERY) {
isc_throw(Unexpected, "invalid constructor for this task operation");
@@ -68,7 +72,7 @@
// A referral query doesn't need to specify section, state, or type.
QueryTask::QueryTask(const Query& qry, const isc::dns::Name& n, const Op o) :
q(qry), qname(n), qclass(qry.qclass()), qtype(RRType::ANY()),
- section(Section::ANSWER()), op(o), state(GETANSWER), flags(0)
+ section(Message::SECTION_ANSWER), op(o), state(GETANSWER), flags(0)
{
if (op != REF_QUERY) {
isc_throw(Unexpected, "invalid constructor for this task operation");
@@ -76,7 +80,7 @@
}
QueryTask::QueryTask(const Query& qry, const isc::dns::Name& n,
- const isc::dns::Section& sect, const Op o,
+ const isc::dns::Message::Section sect, const Op o,
const State st) :
q(qry), qname(n), qclass(qry.qclass()), qtype(RRType::ANY()),
section(sect), op(o), state(st), flags(0)
@@ -93,7 +97,7 @@
cache_(&c), message_(&m), want_additional_(true), want_dnssec_(dnssec)
{
// Check message formatting
- if (message_->getRRCount(Section::QUESTION()) != 1) {
+ if (message_->getRRCount(Message::SECTION_QUESTION) != 1) {
isc_throw(Unexpected, "malformed message: too many questions");
}
@@ -105,7 +109,7 @@
restarts_ = 0;
querytasks_.push(QueryTaskPtr(new QueryTask(*this, *qname_, *qtype_,
- Section::ANSWER())));
+ Message::SECTION_ANSWER)));
}
Query::~Query() {}
Modified: branches/trac299/src/lib/datasrc/query.h
==============================================================================
--- branches/trac299/src/lib/datasrc/query.h (original)
+++ branches/trac299/src/lib/datasrc/query.h Sun Nov 7 11:01:06 2010
@@ -57,7 +57,7 @@
// The section of the reply into which the data should be
// written after it has been fetched from the data source.
- const isc::dns::Section section;
+ const isc::dns::Message::Section section;
// The op field indicates the operation to be carried out by
// this query task:
@@ -127,14 +127,18 @@
// Constructors
QueryTask(const Query& q, const isc::dns::Name& n,
- const isc::dns::RRType& t, const isc::dns::Section& sect);
- QueryTask(const Query& q, const isc::dns::Name& n,
- const isc::dns::RRType& t, const isc::dns::Section& sect, Op o);
- QueryTask(const Query& q, const isc::dns::Name& n,
- const isc::dns::RRType& t, const isc::dns::Section& sect,
+ const isc::dns::RRType& t,
+ const isc::dns::Message::Section sect);
+ QueryTask(const Query& q, const isc::dns::Name& n,
+ const isc::dns::RRType& t,
+ const isc::dns::Message::Section sect, Op o);
+ QueryTask(const Query& q, const isc::dns::Name& n,
+ const isc::dns::RRType& t,
+ const isc::dns::Message::Section sect,
const State st);
QueryTask(const Query& q, const isc::dns::Name& n,
- const isc::dns::RRType& t, const isc::dns::Section& sect,
+ const isc::dns::RRType& t,
+ const isc::dns::Message::Section sect,
Op o, State st);
// These are special constructors for particular query task types,
@@ -147,7 +151,7 @@
QueryTask(const Query& q, const isc::dns::Name& n, Op o);
// A glue (or noglue) query doesn't need to specify type.
QueryTask(const Query& q, const isc::dns::Name& n,
- const isc::dns::Section& sect, Op o, State st);
+ const isc::dns::Message::Section sect, Op o, State st);
~QueryTask();
};
Modified: branches/trac299/src/lib/datasrc/tests/Makefile.am
==============================================================================
--- branches/trac299/src/lib/datasrc/tests/Makefile.am (original)
+++ branches/trac299/src/lib/datasrc/tests/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,5 +1,7 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_builddir)/src/lib/dns -I$(top_srcdir)/src/lib/dns
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += $(SQLITE_CFLAGS)
AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\"
AM_CXXFLAGS = $(B10_CXXFLAGS)
Modified: branches/trac299/src/lib/datasrc/tests/datasrc_unittest.cc
==============================================================================
--- branches/trac299/src/lib/datasrc/tests/datasrc_unittest.cc (original)
+++ branches/trac299/src/lib/datasrc/tests/datasrc_unittest.cc Sun Nov 7 11:01:06 2010
@@ -79,7 +79,7 @@
void
performQuery(DataSrc& data_source, HotCache& cache, Message& message) {
- message.setHeaderFlag(MessageFlag::AA());
+ message.setHeaderFlag(Message::HEADERFLAG_AA);
message.setRcode(Rcode::NOERROR());
Query q(message, cache, true);
data_source.doQuery(q);
@@ -92,7 +92,7 @@
msg.makeResponse();
msg.setOpcode(Opcode::QUERY());
msg.addQuestion(Question(qname, qclass, qtype));
- msg.setHeaderFlag(MessageFlag::RD());
+ msg.setHeaderFlag(Message::HEADERFLAG_RD);
performQuery(meta_source, cache, msg);
}
@@ -102,13 +102,13 @@
const unsigned int nscount, const unsigned int arcount)
{
EXPECT_EQ(rcode, message.getRcode());
- EXPECT_EQ(qrflag, message.getHeaderFlag(MessageFlag::QR()));
- EXPECT_EQ(aaflag, message.getHeaderFlag(MessageFlag::AA()));
- EXPECT_EQ(rdflag, message.getHeaderFlag(MessageFlag::RD()));
-
- EXPECT_EQ(ancount, message.getRRCount(Section::ANSWER()));
- EXPECT_EQ(nscount, message.getRRCount(Section::AUTHORITY()));
- EXPECT_EQ(arcount, message.getRRCount(Section::ADDITIONAL()));
+ EXPECT_EQ(qrflag, message.getHeaderFlag(Message::HEADERFLAG_QR));
+ EXPECT_EQ(aaflag, message.getHeaderFlag(Message::HEADERFLAG_AA));
+ EXPECT_EQ(rdflag, message.getHeaderFlag(Message::HEADERFLAG_RD));
+
+ EXPECT_EQ(ancount, message.getRRCount(Message::SECTION_ANSWER));
+ EXPECT_EQ(nscount, message.getRRCount(Message::SECTION_AUTHORITY));
+ EXPECT_EQ(arcount, message.getRRCount(Message::SECTION_ADDITIONAL));
}
void
@@ -117,7 +117,7 @@
headerCheck(msg, Rcode::NOERROR(), true, true, true, 2, 4, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("www.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
@@ -131,7 +131,7 @@
// XXX: also check ANSWER RRSIG
- rit = msg.beginSection(Section::AUTHORITY());
+ rit = msg.beginSection(Message::SECTION_AUTHORITY);
rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -147,7 +147,7 @@
it->next();
EXPECT_TRUE(it->isLast());
- rit = msg.beginSection(Section::ADDITIONAL());
+ rit = msg.beginSection(Message::SECTION_ADDITIONAL);
rrset = *rit;
EXPECT_EQ(Name("dns01.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
@@ -171,9 +171,9 @@
headerCheck(msg, Rcode::REFUSED(), true, false, true, 0, 0, 0);
EXPECT_EQ(Rcode::REFUSED(), msg.getRcode());
- EXPECT_TRUE(msg.getHeaderFlag(MessageFlag::QR()));
- EXPECT_FALSE(msg.getHeaderFlag(MessageFlag::AA()));
- EXPECT_TRUE(msg.getHeaderFlag(MessageFlag::RD()));
+ EXPECT_TRUE(msg.getHeaderFlag(Message::HEADERFLAG_QR));
+ EXPECT_FALSE(msg.getHeaderFlag(Message::HEADERFLAG_AA));
+ EXPECT_TRUE(msg.getHeaderFlag(Message::HEADERFLAG_RD));
}
// Query class of any should match the first data source.
@@ -186,7 +186,7 @@
RRType::NS());
headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 0, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -209,7 +209,7 @@
RRType::NS());
headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 0, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -230,7 +230,7 @@
RRType::NS());
headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 0, 6);
- rit = msg.beginSection(Section::ANSWER());
+ rit = msg.beginSection(Message::SECTION_ANSWER);
rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -252,7 +252,7 @@
RRType::DNSKEY());
headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 4, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::DNSKEY(), rrset->getType());
@@ -267,7 +267,7 @@
RRType::DNSKEY());
headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 4, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::DNSKEY(), rrset->getType());
@@ -276,7 +276,7 @@
msg.clear(Message::PARSE);
createAndProcessQuery(Name("example.com"), RRClass::IN(),
RRType::DNSKEY());
- rit = msg.beginSection(Section::ANSWER());
+ rit = msg.beginSection(Message::SECTION_ANSWER);
rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::DNSKEY(), rrset->getType());
@@ -289,7 +289,7 @@
headerCheck(msg, Rcode::NOERROR(), true, true, true, 0, 4, 0);
- RRsetIterator rit = msg.beginSection(Section::AUTHORITY());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_AUTHORITY);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::SOA(), rrset->getType());
@@ -301,7 +301,7 @@
headerCheck(msg, Rcode::NXDOMAIN(), true, true, true, 0, 6, 0);
- RRsetIterator rit = msg.beginSection(Section::AUTHORITY());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_AUTHORITY);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::SOA(), rrset->getType());
@@ -316,9 +316,9 @@
headerCheck(msg, Rcode::REFUSED(), true, false, true, 0, 0, 0);
EXPECT_EQ(Rcode::REFUSED(), msg.getRcode());
- EXPECT_TRUE(msg.getHeaderFlag(MessageFlag::QR()));
- EXPECT_FALSE(msg.getHeaderFlag(MessageFlag::AA()));
- EXPECT_TRUE(msg.getHeaderFlag(MessageFlag::RD()));
+ EXPECT_TRUE(msg.getHeaderFlag(Message::HEADERFLAG_QR));
+ EXPECT_FALSE(msg.getHeaderFlag(Message::HEADERFLAG_AA));
+ EXPECT_TRUE(msg.getHeaderFlag(Message::HEADERFLAG_RD));
}
TEST_F(DataSrcTest, Wildcard) {
@@ -327,7 +327,7 @@
headerCheck(msg, Rcode::NOERROR(), true, true, true, 2, 6, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("www.wild.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
@@ -339,7 +339,7 @@
it->next();
EXPECT_TRUE(it->isLast());
- rit = msg.beginSection(Section::AUTHORITY());
+ rit = msg.beginSection(Message::SECTION_AUTHORITY);
rrset = *rit;
EXPECT_EQ(Name("*.wild.example.com"), rrset->getName());
EXPECT_EQ(RRType::NSEC(), rrset->getType());
@@ -362,7 +362,7 @@
it->next();
EXPECT_TRUE(it->isLast());
- rit = msg.beginSection(Section::ADDITIONAL());
+ rit = msg.beginSection(Message::SECTION_ADDITIONAL);
rrset = *rit;
EXPECT_EQ(Name("dns01.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
@@ -399,7 +399,7 @@
headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 6, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("www.wild2.example.com"), rrset->getName());
EXPECT_EQ(RRType::CNAME(), rrset->getType());
@@ -424,7 +424,7 @@
it->next();
EXPECT_TRUE(it->isLast());
- rit = msg.beginSection(Section::AUTHORITY());
+ rit = msg.beginSection(Message::SECTION_AUTHORITY);
rrset = *rit;
EXPECT_EQ(Name("*.wild2.example.com"), rrset->getName());
EXPECT_EQ(RRType::NSEC(), rrset->getType());
@@ -447,7 +447,7 @@
it->next();
EXPECT_TRUE(it->isLast());
- rit = msg.beginSection(Section::ADDITIONAL());
+ rit = msg.beginSection(Message::SECTION_ADDITIONAL);
rrset = *rit;
EXPECT_EQ(Name("dns01.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
@@ -467,7 +467,7 @@
RRType::AAAA());
headerCheck(msg, Rcode::NOERROR(), true, true, true, 2, 4, 0);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("www.wild2.example.com"), rrset->getName());
EXPECT_EQ(RRType::CNAME(), rrset->getType());
@@ -479,7 +479,7 @@
it->next();
EXPECT_TRUE(it->isLast());
- rit = msg.beginSection(Section::AUTHORITY());
+ rit = msg.beginSection(Message::SECTION_AUTHORITY);
rrset = *rit;
EXPECT_EQ(Name("*.wild2.example.com"), rrset->getName());
EXPECT_EQ(RRType::NSEC(), rrset->getType());
@@ -499,7 +499,7 @@
RRType::A());
headerCheck(msg, Rcode::NOERROR(), true, true, true, 2, 6, 0);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("www.wild3.example.com"), rrset->getName());
EXPECT_EQ(RRType::CNAME(), rrset->getType());
@@ -511,7 +511,7 @@
it->next();
EXPECT_TRUE(it->isLast());
- rit = msg.beginSection(Section::AUTHORITY());
+ rit = msg.beginSection(Message::SECTION_AUTHORITY);
rrset = *rit;
EXPECT_EQ(Name("*.wild3.example.com"), rrset->getName());
EXPECT_EQ(RRType::NSEC(), rrset->getType());
@@ -537,7 +537,7 @@
headerCheck(msg, Rcode::NOERROR(), true, true, true, 2, 4, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("www.sql1.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
@@ -549,7 +549,7 @@
it->next();
EXPECT_TRUE(it->isLast());
- rit = msg.beginSection(Section::AUTHORITY());
+ rit = msg.beginSection(Message::SECTION_AUTHORITY);
rrset = *rit;
EXPECT_EQ(Name("sql1.example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -565,7 +565,7 @@
it->next();
EXPECT_TRUE(it->isLast());
- rit = msg.beginSection(Section::ADDITIONAL());
+ rit = msg.beginSection(Message::SECTION_ADDITIONAL);
rrset = *rit;
EXPECT_EQ(Name("dns01.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
@@ -584,7 +584,7 @@
headerCheck(msg, Rcode::NOERROR(), true, true, true, 5, 4, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("dname.example.com"), rrset->getName());
EXPECT_EQ(RRType::DNAME(), rrset->getType());
@@ -598,7 +598,7 @@
// XXX: check CNAME and A record too
- rit = msg.beginSection(Section::AUTHORITY());
+ rit = msg.beginSection(Message::SECTION_AUTHORITY);
rrset = *rit;
EXPECT_EQ(Name("sql1.example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -614,7 +614,7 @@
it->next();
EXPECT_TRUE(it->isLast());
- rit = msg.beginSection(Section::ADDITIONAL());
+ rit = msg.beginSection(Message::SECTION_ADDITIONAL);
rrset = *rit;
EXPECT_EQ(Name("dns01.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
@@ -642,7 +642,7 @@
headerCheck(msg, Rcode::NOERROR(), true, true, true, 2, 0, 0);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("foo.example.com"), rrset->getName());
EXPECT_EQ(RRType::CNAME(), rrset->getType());
@@ -661,7 +661,7 @@
headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 4, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("cname-int.example.com"), rrset->getName());
EXPECT_EQ(RRType::CNAME(), rrset->getType());
@@ -675,7 +675,7 @@
// XXX: check a record as well
- rit = msg.beginSection(Section::AUTHORITY());
+ rit = msg.beginSection(Message::SECTION_AUTHORITY);
rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -688,7 +688,7 @@
headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 4, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("cname-ext.example.com"), rrset->getName());
EXPECT_EQ(RRType::CNAME(), rrset->getType());
@@ -700,7 +700,7 @@
it->next();
EXPECT_TRUE(it->isLast());
- rit = msg.beginSection(Section::AUTHORITY());
+ rit = msg.beginSection(Message::SECTION_AUTHORITY);
rrset = *rit;
EXPECT_EQ(Name("sql1.example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -713,7 +713,7 @@
headerCheck(msg, Rcode::NOERROR(), true, false, true, 0, 5, 2);
- RRsetIterator rit = msg.beginSection(Section::AUTHORITY());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_AUTHORITY);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("subzone.example.com."), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -725,7 +725,7 @@
it->next();
EXPECT_FALSE(it->isLast());
- rit = msg.beginSection(Section::ADDITIONAL());
+ rit = msg.beginSection(Message::SECTION_ADDITIONAL);
rrset = *rit;
EXPECT_EQ(Name("ns1.subzone.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
@@ -744,7 +744,7 @@
headerCheck(msg, Rcode::NOERROR(), true, false, true, 0, 5, 2);
- RRsetIterator rit = msg.beginSection(Section::AUTHORITY());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_AUTHORITY);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("subzone.example.com."), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -756,7 +756,7 @@
it->next();
EXPECT_FALSE(it->isLast());
- rit = msg.beginSection(Section::ADDITIONAL());
+ rit = msg.beginSection(Message::SECTION_ADDITIONAL);
rrset = *rit;
EXPECT_EQ(Name("ns1.subzone.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
@@ -782,13 +782,13 @@
headerCheck(msg, Rcode::NOERROR(), true, true, true, 2, 4, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("subzone.example.com."), rrset->getName());
EXPECT_EQ(RRType::NSEC(), rrset->getType());
EXPECT_EQ(RRClass::IN(), rrset->getClass());
- rit = msg.beginSection(Section::AUTHORITY());
+ rit = msg.beginSection(Message::SECTION_AUTHORITY);
rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -810,7 +810,7 @@
RRType::DNAME());
headerCheck(msg, Rcode::NOERROR(), true, false, true, 0, 5, 2);
- RRsetIterator rit = msg.beginSection(Section::AUTHORITY());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_AUTHORITY);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("subzone.example.com."), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -822,7 +822,7 @@
it->next();
EXPECT_FALSE(it->isLast());
- rit = msg.beginSection(Section::ADDITIONAL());
+ rit = msg.beginSection(Message::SECTION_ADDITIONAL);
rrset = *rit;
EXPECT_EQ(Name("ns1.subzone.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
@@ -841,13 +841,13 @@
headerCheck(msg, Rcode::NOERROR(), true, true, true, 3, 4, 6);
- RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_ANSWER);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("subzone.example.com."), rrset->getName());
EXPECT_EQ(RRType::DS(), rrset->getType());
EXPECT_EQ(RRClass::IN(), rrset->getClass());
- rit = msg.beginSection(Section::AUTHORITY());
+ rit = msg.beginSection(Message::SECTION_AUTHORITY);
rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -872,7 +872,7 @@
// one.loop.example points to two.loop.example, which points back
// to one.loop.example, so there should be exactly two CNAME records
// in the answer.
- EXPECT_EQ(2, msg.getRRCount(Section::ANSWER()));
+ EXPECT_EQ(2, msg.getRRCount(Message::SECTION_ANSWER));
}
// NSEC query for the name of a zone cut for non-secure delegation.
@@ -883,7 +883,7 @@
headerCheck(msg, Rcode::NOERROR(), true, false, true, 0, 1, 1);
- RRsetIterator rit = msg.beginSection(Section::AUTHORITY());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_AUTHORITY);
ConstRRsetPtr rrset = *rit;
EXPECT_EQ(Name("sub.example.org."), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
@@ -897,7 +897,7 @@
it->next();
EXPECT_TRUE(it->isLast());
- rit = msg.beginSection(Section::ADDITIONAL());
+ rit = msg.beginSection(Message::SECTION_ADDITIONAL);
rrset = *rit;
EXPECT_EQ(Name("ns.sub.example.org."), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
@@ -942,7 +942,7 @@
createAndProcessQuery(Name("www.version.bind"), RRClass::CH(),
RRType::TXT());
headerCheck(msg, Rcode::NXDOMAIN(), true, true, true, 0, 1, 0);
- RRsetIterator rit = msg.beginSection(Section::AUTHORITY());
+ RRsetIterator rit = msg.beginSection(Message::SECTION_AUTHORITY);
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("version.bind"), rrset->getName());
EXPECT_EQ(RRType::SOA(), rrset->getType());
Modified: branches/trac299/src/lib/datasrc/tests/query_unittest.cc
==============================================================================
--- branches/trac299/src/lib/datasrc/tests/query_unittest.cc (original)
+++ branches/trac299/src/lib/datasrc/tests/query_unittest.cc Sun Nov 7 11:01:06 2010
@@ -38,7 +38,7 @@
const RRType& qtype)
{
m.setOpcode(Opcode::QUERY());
- m.setHeaderFlag(MessageFlag::RD());
+ m.setHeaderFlag(Message::HEADERFLAG_RD);
m.addQuestion(Question(qname, qclass, qtype));
}
Modified: branches/trac299/src/lib/dns/Makefile.am
==============================================================================
--- branches/trac299/src/lib/dns/Makefile.am (original)
+++ branches/trac299/src/lib/dns/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,6 +1,7 @@
SUBDIRS = . tests python
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS)
CLEANFILES = *.gcno *.gcda
Modified: branches/trac299/src/lib/dns/message.cc
==============================================================================
--- branches/trac299/src/lib/dns/message.cc (original)
+++ branches/trac299/src/lib/dns/message.cc Sun Nov 7 11:01:06 2010
@@ -44,32 +44,42 @@
using namespace std;
using namespace boost;
-using namespace isc::dns;
using namespace isc::dns::rdata;
namespace isc {
namespace dns {
namespace {
-typedef uint16_t flags_t;
-
// protocol constants
const size_t HEADERLEN = 12;
-
-const flags_t FLAG_QR = 0x8000;
-const flags_t FLAG_AA = 0x0400;
-const flags_t FLAG_TC = 0x0200;
-const flags_t FLAG_RD = 0x0100;
-const flags_t FLAG_RA = 0x0080;
-const flags_t FLAG_AD = 0x0020;
-const flags_t FLAG_CD = 0x0010;
const unsigned int OPCODE_MASK = 0x7800;
const unsigned int OPCODE_SHIFT = 11;
const unsigned int RCODE_MASK = 0x000f;
-const unsigned int FLAG_MASK = 0x8ff0;
-
-const unsigned int MESSAGE_REPLYPRESERVE = (FLAG_RD | FLAG_CD);
+
+// This diagram shows the wire-format representation of the 2nd 16 bits of
+// the DNS header section, which contain all defined flag bits.
+//
+// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+// |QR| Opcode |AA|TC|RD|RA| |AD|CD| RCODE |
+// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+// 1 0 0 0| 0 1 1 1| 1 0 1 1| 0 0 0 0|
+// 0x8 0x7 0xb 0x0
+//
+// This mask covers all the flag bits, and those bits only.
+// Note: we reject a "flag" the is not covered by this mask in some of the
+// public methods. This means our current definition is not fully extendable;
+// applications cannot introduce a new flag bit temporarily without modifying
+// the source code.
+const unsigned int HEADERFLAG_MASK = 0x87b0;
+
+// This is a set of flag bits that should be preserved when building a reply
+// from a request.
+// Note: we assume the specific definition of HEADERFLAG_xx. We may change
+// the definition in future, in which case we need to adjust this definition,
+// too (see also the description about the Message::HeaderFlag type).
+const uint16_t MESSAGE_REPLYPRESERVE = (Message::HEADERFLAG_RD |
+ Message::HEADERFLAG_CD);
const char *sectiontext[] = {
"QUESTION",
@@ -77,15 +87,6 @@
"AUTHORITY",
"ADDITIONAL"
};
-}
-
-namespace {
-inline unsigned int
-sectionCodeToId(const Section& section) {
- unsigned int code = section.getCode();
- assert(code > 0);
- return (section.getCode() - 1);
-}
}
class MessageImpl {
@@ -105,13 +106,13 @@
const Opcode* opcode_;
Opcode opcode_placeholder_;
- flags_t flags_;
+ uint16_t flags_; // wire-format representation of header flags.
bool header_parsed_;
- static const unsigned int SECTION_MAX = 4; // TODO: revisit this design
- int counts_[SECTION_MAX]; // TODO: revisit this definition
+ static const unsigned int NUM_SECTIONS = 4; // TODO: revisit this design
+ int counts_[NUM_SECTIONS]; // TODO: revisit this definition
vector<QuestionPtr> questions_;
- vector<RRsetPtr> rrsets_[SECTION_MAX];
+ vector<RRsetPtr> rrsets_[NUM_SECTIONS];
ConstEDNSPtr edns_;
#ifdef notyet
@@ -123,7 +124,7 @@
void setOpcode(const Opcode& opcode);
void setRcode(const Rcode& rcode);
int parseQuestion(InputBuffer& buffer);
- int parseSection(const Section& section, InputBuffer& buffer);
+ int parseSection(const Message::Section section, InputBuffer& buffer);
};
MessageImpl::MessageImpl(Message::Mode mode) :
@@ -142,15 +143,15 @@
opcode_ = NULL;
edns_ = EDNSPtr();
- for (int i = 0; i < SECTION_MAX; ++i) {
+ for (int i = 0; i < NUM_SECTIONS; ++i) {
counts_[i] = 0;
}
header_parsed_ = false;
questions_.clear();
- rrsets_[sectionCodeToId(Section::ANSWER())].clear();
- rrsets_[sectionCodeToId(Section::AUTHORITY())].clear();
- rrsets_[sectionCodeToId(Section::ADDITIONAL())].clear();
+ rrsets_[Message::SECTION_ANSWER].clear();
+ rrsets_[Message::SECTION_AUTHORITY].clear();
+ rrsets_[Message::SECTION_ADDITIONAL].clear();
}
void
@@ -174,26 +175,31 @@
}
bool
-Message::getHeaderFlag(const MessageFlag& flag) const {
- return ((impl_->flags_ & flag.getBit()) != 0);
-}
-
-void
-Message::setHeaderFlag(const MessageFlag& flag) {
+Message::getHeaderFlag(const HeaderFlag flag) const {
+ if (flag == 0 || (flag & ~HEADERFLAG_MASK) != 0) {
+ isc_throw(InvalidParameter,
+ "Message::getHeaderFlag:: Invalid flag is specified: " <<
+ flag);
+ }
+ return ((impl_->flags_ & flag) != 0);
+}
+
+void
+Message::setHeaderFlag(const HeaderFlag flag, const bool on) {
if (impl_->mode_ != Message::RENDER) {
isc_throw(InvalidMessageOperation,
"setHeaderFlag performed in non-render mode");
}
- impl_->flags_ |= flag.getBit();
-}
-
-void
-Message::clearHeaderFlag(const MessageFlag& flag) {
- if (impl_->mode_ != Message::RENDER) {
- isc_throw(InvalidMessageOperation,
- "clearHeaderFlag performed in non-render mode");
- }
- impl_->flags_ &= ~flag.getBit();
+ if (flag == 0 || (flag & ~HEADERFLAG_MASK) != 0) {
+ isc_throw(InvalidParameter,
+ "Message::getHeaderFlag:: Invalid flag is specified: " <<
+ flag);
+ }
+ if (on) {
+ impl_->flags_ |= flag;
+ } else {
+ impl_->flags_ &= ~flag;
+ }
}
qid_t
@@ -259,35 +265,46 @@
}
unsigned int
-Message::getRRCount(const Section& section) const {
- return (impl_->counts_[section.getCode()]);
-}
-
-void
-Message::addRRset(const Section& section, RRsetPtr rrset, const bool sign) {
+Message::getRRCount(const Section section) const {
+ if (section >= MessageImpl::NUM_SECTIONS) {
+ isc_throw(OutOfRange, "Invalid message section: " << section);
+ }
+ return (impl_->counts_[section]);
+}
+
+void
+Message::addRRset(const Section section, RRsetPtr rrset, const bool sign) {
if (impl_->mode_ != Message::RENDER) {
isc_throw(InvalidMessageOperation,
"addRRset performed in non-render mode");
}
-
- impl_->rrsets_[sectionCodeToId(section)].push_back(rrset);
- impl_->counts_[section.getCode()] += rrset->getRdataCount();
+ if (section >= MessageImpl::NUM_SECTIONS) {
+ isc_throw(OutOfRange, "Invalid message section: " << section);
+ }
+
+ impl_->rrsets_[section].push_back(rrset);
+ impl_->counts_[section] += rrset->getRdataCount();
RRsetPtr sp = rrset->getRRsig();
if (sign && sp != NULL) {
- impl_->rrsets_[sectionCodeToId(section)].push_back(sp);
- impl_->counts_[section.getCode()] += sp->getRdataCount();
+ impl_->rrsets_[section].push_back(sp);
+ impl_->counts_[section] += sp->getRdataCount();
}
}
bool
-Message::hasRRset(const Section& section, RRsetPtr rrset) {
- BOOST_FOREACH(RRsetPtr r, impl_->rrsets_[sectionCodeToId(section)]) {
- if (r->getType() == rrset->getType() &&
- r->getName() == rrset->getName())
- {
+Message::hasRRset(const Section section, const Name& name,
+ const RRClass& rrclass, const RRType& rrtype)
+{
+ if (section >= MessageImpl::NUM_SECTIONS) {
+ isc_throw(OutOfRange, "Invalid message section: " << section);
+ }
+
+ BOOST_FOREACH(ConstRRsetPtr r, impl_->rrsets_[section]) {
+ if (r->getClass() == rrclass &&
+ r->getType() == rrtype &&
+ r->getName() == name) {
return (true);
-
}
}
@@ -302,7 +319,7 @@
}
impl_->questions_.push_back(question);
- ++impl_->counts_[Section::QUESTION().getCode()];
+ ++impl_->counts_[SECTION_QUESTION];
}
void
@@ -366,24 +383,24 @@
uint16_t ancount = 0;
if (!renderer.isTruncated()) {
ancount =
- for_each(impl_->rrsets_[sectionCodeToId(Section::ANSWER())].begin(),
- impl_->rrsets_[sectionCodeToId(Section::ANSWER())].end(),
+ for_each(impl_->rrsets_[SECTION_ANSWER].begin(),
+ impl_->rrsets_[SECTION_ANSWER].end(),
RenderSection<RRsetPtr>(renderer, true)).getTotalCount();
}
uint16_t nscount = 0;
if (!renderer.isTruncated()) {
nscount =
- for_each(impl_->rrsets_[sectionCodeToId(Section::AUTHORITY())].begin(),
- impl_->rrsets_[sectionCodeToId(Section::AUTHORITY())].end(),
+ for_each(impl_->rrsets_[SECTION_AUTHORITY].begin(),
+ impl_->rrsets_[SECTION_AUTHORITY].end(),
RenderSection<RRsetPtr>(renderer, true)).getTotalCount();
}
uint16_t arcount = 0;
if (renderer.isTruncated()) {
- setHeaderFlag(MessageFlag::TC());
+ setHeaderFlag(HEADERFLAG_TC, true);
} else {
arcount =
- for_each(impl_->rrsets_[sectionCodeToId(Section::ADDITIONAL())].begin(),
- impl_->rrsets_[sectionCodeToId(Section::ADDITIONAL())].end(),
+ for_each(impl_->rrsets_[SECTION_ADDITIONAL].begin(),
+ impl_->rrsets_[SECTION_ADDITIONAL].end(),
RenderSection<RRsetPtr>(renderer, false)).getTotalCount();
}
@@ -406,10 +423,10 @@
// in rrsets_[] or questions_ if truncation occurred or an EDNS OPT RR
// was inserted. This is not good, and we should revisit the entire
// design.
- impl_->counts_[Section::QUESTION().getCode()] = qdcount;
- impl_->counts_[Section::ANSWER().getCode()] = ancount;
- impl_->counts_[Section::AUTHORITY().getCode()] = nscount;
- impl_->counts_[Section::ADDITIONAL().getCode()] = arcount;
+ impl_->counts_[SECTION_QUESTION] = qdcount;
+ impl_->counts_[SECTION_ANSWER] = ancount;
+ impl_->counts_[SECTION_AUTHORITY] = nscount;
+ impl_->counts_[SECTION_ADDITIONAL] = arcount;
// TBD: TSIG, SIG(0) etc.
@@ -421,7 +438,7 @@
uint16_t codes_and_flags =
(impl_->opcode_->getCode() << OPCODE_SHIFT) & OPCODE_MASK;
codes_and_flags |= (impl_->rcode_->getCode() & RCODE_MASK);
- codes_and_flags |= (impl_->flags_ & FLAG_MASK);
+ codes_and_flags |= (impl_->flags_ & HEADERFLAG_MASK);
renderer.writeUint16At(codes_and_flags, header_pos);
header_pos += sizeof(uint16_t);
// XXX: should avoid repeated pattern (TODO)
@@ -451,11 +468,11 @@
const uint16_t codes_and_flags = buffer.readUint16();
impl_->setOpcode(Opcode((codes_and_flags & OPCODE_MASK) >> OPCODE_SHIFT));
impl_->setRcode(Rcode(codes_and_flags & RCODE_MASK));
- impl_->flags_ = (codes_and_flags & FLAG_MASK);
- impl_->counts_[Section::QUESTION().getCode()] = buffer.readUint16();
- impl_->counts_[Section::ANSWER().getCode()] = buffer.readUint16();
- impl_->counts_[Section::AUTHORITY().getCode()] = buffer.readUint16();
- impl_->counts_[Section::ADDITIONAL().getCode()] = buffer.readUint16();
+ impl_->flags_ = (codes_and_flags & HEADERFLAG_MASK);
+ impl_->counts_[SECTION_QUESTION] = buffer.readUint16();
+ impl_->counts_[SECTION_ANSWER] = buffer.readUint16();
+ impl_->counts_[SECTION_AUTHORITY] = buffer.readUint16();
+ impl_->counts_[SECTION_ADDITIONAL] = buffer.readUint16();
impl_->header_parsed_ = true;
}
@@ -471,14 +488,13 @@
parseHeader(buffer);
}
- impl_->counts_[Section::QUESTION().getCode()] =
- impl_->parseQuestion(buffer);
- impl_->counts_[Section::ANSWER().getCode()] =
- impl_->parseSection(Section::ANSWER(), buffer);
- impl_->counts_[Section::AUTHORITY().getCode()] =
- impl_->parseSection(Section::AUTHORITY(), buffer);
- impl_->counts_[Section::ADDITIONAL().getCode()] =
- impl_->parseSection(Section::ADDITIONAL(), buffer);
+ impl_->counts_[SECTION_QUESTION] = impl_->parseQuestion(buffer);
+ impl_->counts_[SECTION_ANSWER] =
+ impl_->parseSection(SECTION_ANSWER, buffer);
+ impl_->counts_[SECTION_AUTHORITY] =
+ impl_->parseSection(SECTION_AUTHORITY, buffer);
+ impl_->counts_[SECTION_ADDITIONAL] =
+ impl_->parseSection(SECTION_ADDITIONAL, buffer);
}
int
@@ -486,7 +502,7 @@
unsigned int added = 0;
for (unsigned int count = 0;
- count < counts_[Section::QUESTION().getCode()];
+ count < counts_[Message::SECTION_QUESTION];
++count) {
const Name name(buffer);
@@ -498,9 +514,9 @@
const RRType rrtype(buffer.readUint16());
const RRClass rrclass(buffer.readUint16());
- // XXX: need a duplicate check. We might also want to have an optimized
- // algorithm that requires the question section contain exactly one
- // RR.
+ // XXX: need a duplicate check. We might also want to have an
+ // optimized algorithm that requires the question section contain
+ // exactly one RR.
questions_.push_back(QuestionPtr(new Question(name, rrclass, rrtype)));
++added;
@@ -553,16 +569,20 @@
// logic to that class; processing logic dependent on parse context
// is hardcoded here.
int
-MessageImpl::parseSection(const Section& section, InputBuffer& buffer) {
+MessageImpl::parseSection(const Message::Section section,
+ InputBuffer& buffer)
+{
+ assert(section < MessageImpl::NUM_SECTIONS);
+
unsigned int added = 0;
- for (unsigned int count = 0; count < counts_[section.getCode()]; ++count) {
+ for (unsigned int count = 0; count < counts_[section]; ++count) {
const Name name(buffer);
// buffer must store at least RR TYPE, RR CLASS, TTL, and RDLEN.
if ((buffer.getLength() - buffer.getPosition()) <
3 * sizeof(uint16_t) + sizeof(uint32_t)) {
- isc_throw(DNSMessageFORMERR, sectiontext[section.getCode()] <<
+ isc_throw(DNSMessageFORMERR, sectiontext[section] <<
" section too short: " <<
(buffer.getLength() - buffer.getPosition()) << " bytes");
}
@@ -574,7 +594,7 @@
ConstRdataPtr rdata = createRdata(rrtype, rrclass, buffer, rdlen);
if (rrtype == RRType::OPT()) {
- if (section != Section::ADDITIONAL()) {
+ if (section != Message::SECTION_ADDITIONAL) {
isc_throw(DNSMessageFORMERR,
"EDNS OPT RR found in an invalid section");
}
@@ -589,17 +609,16 @@
continue;
} else {
vector<RRsetPtr>::iterator it =
- find_if(rrsets_[sectionCodeToId(section)].begin(),
- rrsets_[sectionCodeToId(section)].end(),
+ find_if(rrsets_[section].begin(), rrsets_[section].end(),
MatchRR(name, rrtype, rrclass));
- if (it != rrsets_[sectionCodeToId(section)].end()) {
+ if (it != rrsets_[section].end()) {
(*it)->setTTL(min((*it)->getTTL(), ttl));
(*it)->addRdata(rdata);
} else {
RRsetPtr rrset =
RRsetPtr(new RRset(name, rrclass, rrtype, ttl));
rrset->addRdata(rdata);
- rrsets_[sectionCodeToId(section)].push_back(rrset);
+ rrsets_[section].push_back(rrset);
}
++added;
}
@@ -611,15 +630,15 @@
namespace {
template <typename T>
struct SectionFormatter {
- SectionFormatter(const Section& section, string& output) :
+ SectionFormatter(const Message::Section section, string& output) :
section_(section), output_(output) {}
void operator()(const T& entry) {
- if (section_ == Section::QUESTION()) {
+ if (section_ == Message::SECTION_QUESTION) {
output_ += ";";
}
output_ += entry->toText();
}
- const Section& section_;
+ const Message::Section section_;
string& output_;
};
}
@@ -642,30 +661,37 @@
s += ", status: " + impl_->rcode_->toText();
s += ", id: " + boost::lexical_cast<string>(impl_->qid_);
s += "\n;; flags: ";
- if (getHeaderFlag(MessageFlag::QR()))
+ if (getHeaderFlag(HEADERFLAG_QR)) {
s += "qr ";
- if (getHeaderFlag(MessageFlag::AA()))
+ }
+ if (getHeaderFlag(HEADERFLAG_AA)) {
s += "aa ";
- if (getHeaderFlag(MessageFlag::TC()))
+ }
+ if (getHeaderFlag(HEADERFLAG_TC)) {
s += "tc ";
- if (getHeaderFlag(MessageFlag::RD()))
+ }
+ if (getHeaderFlag(HEADERFLAG_RD)) {
s += "rd ";
- if (getHeaderFlag(MessageFlag::RA()))
+ }
+ if (getHeaderFlag(HEADERFLAG_RA)) {
s += "ra ";
- if (getHeaderFlag(MessageFlag::AD()))
+ }
+ if (getHeaderFlag(HEADERFLAG_AD)) {
s += "ad ";
- if (getHeaderFlag(MessageFlag::CD()))
+ }
+ if (getHeaderFlag(HEADERFLAG_CD)) {
s += "cd ";
+ }
// for simplicity, don't consider the update case for now
s += "; QUESTION: " +
- lexical_cast<string>(impl_->counts_[Section::QUESTION().getCode()]);
+ lexical_cast<string>(impl_->counts_[SECTION_QUESTION]);
s += ", ANSWER: " +
- lexical_cast<string>(impl_->counts_[Section::ANSWER().getCode()]);
+ lexical_cast<string>(impl_->counts_[SECTION_ANSWER]);
s += ", AUTHORITY: " +
- lexical_cast<string>(impl_->counts_[Section::AUTHORITY().getCode()]);
-
- unsigned int arcount = impl_->counts_[Section::ADDITIONAL().getCode()];
+ lexical_cast<string>(impl_->counts_[SECTION_AUTHORITY]);
+
+ unsigned int arcount = impl_->counts_[SECTION_ADDITIONAL];
if (impl_->edns_ != NULL) {
++arcount;
}
@@ -678,31 +704,31 @@
if (!impl_->questions_.empty()) {
s += "\n;; " +
- string(sectiontext[Section::QUESTION().getCode()]) + " SECTION:\n";
+ string(sectiontext[SECTION_QUESTION]) + " SECTION:\n";
for_each(impl_->questions_.begin(), impl_->questions_.end(),
- SectionFormatter<QuestionPtr>(Section::QUESTION(), s));
- }
- if (!impl_->rrsets_[sectionCodeToId(Section::ANSWER())].empty()) {
+ SectionFormatter<QuestionPtr>(SECTION_QUESTION, s));
+ }
+ if (!impl_->rrsets_[SECTION_ANSWER].empty()) {
s += "\n;; " +
- string(sectiontext[Section::ANSWER().getCode()]) + " SECTION:\n";
- for_each(impl_->rrsets_[sectionCodeToId(Section::ANSWER())].begin(),
- impl_->rrsets_[sectionCodeToId(Section::ANSWER())].end(),
- SectionFormatter<RRsetPtr>(Section::ANSWER(), s));
- }
- if (!impl_->rrsets_[sectionCodeToId(Section::AUTHORITY())].empty()) {
+ string(sectiontext[SECTION_ANSWER]) + " SECTION:\n";
+ for_each(impl_->rrsets_[SECTION_ANSWER].begin(),
+ impl_->rrsets_[SECTION_ANSWER].end(),
+ SectionFormatter<RRsetPtr>(SECTION_ANSWER, s));
+ }
+ if (!impl_->rrsets_[SECTION_AUTHORITY].empty()) {
s += "\n;; " +
- string(sectiontext[Section::AUTHORITY().getCode()]) + " SECTION:\n";
- for_each(impl_->rrsets_[sectionCodeToId(Section::AUTHORITY())].begin(),
- impl_->rrsets_[sectionCodeToId(Section::AUTHORITY())].end(),
- SectionFormatter<RRsetPtr>(Section::AUTHORITY(), s));
- }
- if (!impl_->rrsets_[sectionCodeToId(Section::ADDITIONAL())].empty()) {
+ string(sectiontext[SECTION_AUTHORITY]) + " SECTION:\n";
+ for_each(impl_->rrsets_[SECTION_AUTHORITY].begin(),
+ impl_->rrsets_[SECTION_AUTHORITY].end(),
+ SectionFormatter<RRsetPtr>(SECTION_AUTHORITY, s));
+ }
+ if (!impl_->rrsets_[SECTION_ADDITIONAL].empty()) {
s += "\n;; " +
- string(sectiontext[Section::ADDITIONAL().getCode()]) +
+ string(sectiontext[SECTION_ADDITIONAL]) +
" SECTION:\n";
- for_each(impl_->rrsets_[sectionCodeToId(Section::ADDITIONAL())].begin(),
- impl_->rrsets_[sectionCodeToId(Section::ADDITIONAL())].end(),
- SectionFormatter<RRsetPtr>(Section::ADDITIONAL(), s));
+ for_each(impl_->rrsets_[SECTION_ADDITIONAL].begin(),
+ impl_->rrsets_[SECTION_ADDITIONAL].end(),
+ SectionFormatter<RRsetPtr>(SECTION_ADDITIONAL, s));
}
return (s);
@@ -725,14 +751,14 @@
impl_->edns_ = EDNSPtr();
impl_->flags_ &= MESSAGE_REPLYPRESERVE;
- setHeaderFlag(MessageFlag::QR());
-
- impl_->rrsets_[sectionCodeToId(Section::ANSWER())].clear();
- impl_->counts_[Section::ANSWER().getCode()] = 0;
- impl_->rrsets_[sectionCodeToId(Section::AUTHORITY())].clear();
- impl_->counts_[Section::AUTHORITY().getCode()] = 0;
- impl_->rrsets_[sectionCodeToId(Section::ADDITIONAL())].clear();
- impl_->counts_[Section::ADDITIONAL().getCode()] = 0;
+ setHeaderFlag(HEADERFLAG_QR, true);
+
+ impl_->rrsets_[SECTION_ANSWER].clear();
+ impl_->counts_[SECTION_ANSWER] = 0;
+ impl_->rrsets_[SECTION_AUTHORITY].clear();
+ impl_->counts_[SECTION_AUTHORITY] = 0;
+ impl_->rrsets_[SECTION_ADDITIONAL].clear();
+ impl_->counts_[SECTION_ADDITIONAL] = 0;
}
///
@@ -840,33 +866,34 @@
/// RRsets iterators
///
const SectionIterator<RRsetPtr>
-Message::beginSection(const Section& section) const {
- if (section == Section::QUESTION()) {
+Message::beginSection(const Section section) const {
+ if (section >= MessageImpl::NUM_SECTIONS) {
+ isc_throw(OutOfRange, "Invalid message section: " << section);
+ }
+ if (section == SECTION_QUESTION) {
isc_throw(InvalidMessageSection,
"RRset iterator is requested for question");
}
- return (RRsetIterator(
- RRsetIteratorImpl(
- impl_->rrsets_[sectionCodeToId(section)].begin())));
+ return (RRsetIterator(RRsetIteratorImpl(impl_->rrsets_[section].begin())));
}
const SectionIterator<RRsetPtr>
-Message::endSection(const Section& section) const {
- if (section == Section::QUESTION()) {
+Message::endSection(const Section section) const {
+ if (section >= MessageImpl::NUM_SECTIONS) {
+ isc_throw(OutOfRange, "Invalid message section: " << section);
+ }
+ if (section == SECTION_QUESTION) {
isc_throw(InvalidMessageSection,
"RRset iterator is requested for question");
}
- return (RRsetIterator(
- RRsetIteratorImpl(
- impl_->rrsets_[sectionCodeToId(section)].end())));
+ return (RRsetIterator(RRsetIteratorImpl(impl_->rrsets_[section].end())));
}
ostream&
operator<<(ostream& os, const Message& message) {
return (os << message.toText());
}
-
} // end of namespace dns
} // end of namespace isc
Modified: branches/trac299/src/lib/dns/message.h
==============================================================================
--- branches/trac299/src/lib/dns/message.h (original)
+++ branches/trac299/src/lib/dns/message.h Sun Nov 7 11:01:06 2010
@@ -87,133 +87,6 @@
template <typename T>
struct SectionIteratorImpl;
-
-/// \brief The \c MessageFlag class objects represent standard flag bits
-/// of the header section of DNS messages.
-///
-/// Constant objects are defined for standard flags.
-class MessageFlag {
-public:
- /// \brief Returns the corresponding bit of the MessageFlag.
- ///
- /// Note: this value is intended to be used for rendering or parsing
- /// low level wire-format data. Applications should use abstract
- /// interfaces. This also means the interface is not well sophisticated,
- /// and we should revisit the design.
- uint16_t getBit() const { return (flagbit_); }
- static const MessageFlag& QR();
- static const MessageFlag& AA();
- static const MessageFlag& TC();
- static const MessageFlag& RD();
- static const MessageFlag& RA();
- static const MessageFlag& AD();
- static const MessageFlag& CD();
-private:
- MessageFlag(uint16_t flagbit) : flagbit_(flagbit) {}
- uint16_t flagbit_;
-};
-
-inline const MessageFlag&
-MessageFlag::QR() {
- static MessageFlag f(0x8000);
- return (f);
-}
-
-inline const MessageFlag&
-MessageFlag::AA() {
- static MessageFlag f(0x0400);
- return (f);
-}
-
-inline const MessageFlag&
-MessageFlag::TC() {
- static MessageFlag f(0x0200);
- return (f);
-}
-
-inline const MessageFlag&
-MessageFlag::RD() {
- static MessageFlag f(0x0100);
- return (f);
-}
-
-inline const MessageFlag&
-MessageFlag::RA() {
- static MessageFlag f(0x0080);
- return (f);
-}
-
-inline const MessageFlag&
-MessageFlag::AD() {
- static MessageFlag f(0x0020);
- return (f);
-}
-
-inline const MessageFlag&
-MessageFlag::CD() {
- static MessageFlag f(0x0010);
- return (f);
-}
-
-/// \brief The \c Section class objects represent DNS message sections such
-/// as the header, question, or answer.
-///
-/// Note: this class doesn't seem to be very useful. We should probably
-/// revisit this design.
-///
-/// Note: whether or not it's represented as a class, we'll need a way
-/// to represent more advanced sections such as those used in dynamic updates.
-/// This is a TODO item.
-///
-/// Constant objects are defined for standard flags.
-class Section {
-public:
- /// \brief Returns the relative position of the \c Section in DNS messages.
- unsigned int getCode() const { return (code_); }
- bool operator==(const Section& other) const
- { return (code_ == other.code_); }
- bool operator!=(const Section& other) const
- { return (code_ != other.code_); }
-
- static const Section& QUESTION();
- static const Section& ANSWER();
- static const Section& AUTHORITY();
- static const Section& ADDITIONAL();
-private:
- enum {
- SECTION_QUESTION = 0,
- SECTION_ANSWER = 1,
- SECTION_AUTHORITY = 2,
- SECTION_ADDITIONAL = 3
- };
-
- Section(int code) : code_(code) {}
- unsigned int code_;
-};
-
-inline const Section&
-Section::QUESTION() {
- static Section s(SECTION_QUESTION);
- return (s);
-}
-
-inline const Section&
-Section::ANSWER() {
- static Section s(SECTION_ANSWER);
- return (s);
-}
-
-inline const Section&
-Section::AUTHORITY() {
- static Section s(SECTION_AUTHORITY);
- return (s);
-}
-
-inline const Section&
-Section::ADDITIONAL() {
- static Section s(SECTION_ADDITIONAL);
- return (s);
-}
/// \c SectionIterator is a templated class to provide standard-compatible
/// iterators for Questions and RRsets for a given DNS message section.
@@ -274,19 +147,109 @@
/// of RR in the message.
class Message {
public:
+ /// Constants to specify the operation mode of the \c Message.
enum Mode {
- PARSE = 0,
- RENDER = 1
+ PARSE = 0, ///< Parse mode (handling an incoming message)
+ RENDER = 1 ///< Render mode (building an outgoing message)
};
+ /// \brief Constants for flag bit fields of a DNS message header.
+ ///
+ /// Only the defined constants are valid where a header flag is required
+ /// in this library (e.g., in \c Message::setHeaderFlag()).
+ /// Since these are enum constants, however, invalid value could be passed
+ /// via casting without an error at compilation time.
+ /// It is generally the callee's responsibility to check and reject invalid
+ /// values.
+ /// Of course, applications shouldn't pass invalid values even if the
+ /// callee does not perform proper validation; the result in such usage
+ /// is undefined.
+ ///
+ /// In the current implementation, the defined values happen to be
+ /// a 16-bit integer with one bit being set corresponding to the
+ /// specified flag in the second 16 bits of the DNS Header section
+ /// in order to make the internal implementation simpler.
+ /// For example, \c HEADERFLAG_QR is defined to be 0x8000 as the QR
+ /// bit is the most significant bit of the 2nd 16 bits of the header.
+ /// However, applications should not assume this coincidence and
+ /// must solely use the enum representations.
+ /// Any usage based on the assumption of the underlying values is invalid
+ /// and the result is undefined.
+ ///
+ /// Likewise, bit wise operations such as AND or OR on the flag values
+ /// are invalid and are not guaranteed to work, even if it could compile
+ /// with casting.
+ /// For example, the following code will compile:
+ /// \code const uint16_t combined_flags =
+ /// static_cast<uint16_t>(Message::HEADERFLAG_AA) |
+ /// static_cast<uint16_t>(Message::HEADERFLAG_CD);
+ /// message->setHeaderFlag(static_cast<Message::HeaderFlag>(combined_flags));
+ /// \endcode
+ /// and (with the current definition) happens to work as if it were
+ /// validly written as follows:
+ /// \code message->setHeaderFlag(Message::HEADERFLAG_AA);
+ /// message->setHeaderFlag(Message::HEADERFLAG_CD);
+ /// \endcode
+ /// But the former notation is invalid and may not work in future versions.
+ /// We did not try to prohibit such usage at compilation time, e.g., by
+ /// introducing a separately defined class considering the balance
+ /// between the complexity and advantage, but hopefully the cast notation
+ /// is sufficiently ugly to prevent proliferation of the usage.
+ enum HeaderFlag {
+ HEADERFLAG_QR = 0x8000, ///< Query (if cleared) or response (if set)
+ HEADERFLAG_AA = 0x0400, ///< Authoritative answer
+ HEADERFLAG_TC = 0x0200, ///< Truncation
+ HEADERFLAG_RD = 0x0100, ///< Recursion desired
+ HEADERFLAG_RA = 0x0080, ///< Recursion available
+ HEADERFLAG_AD = 0x0020, ///< DNSSEC checking disabled (RFC4035)
+ HEADERFLAG_CD = 0x0010 ///< Authentic %data (RFC4035)
+ };
+
+ /// \brief Constants to specify sections of a DNS message.
+ ///
+ /// The sections are those defined in RFC 1035 excluding the Header
+ /// section; the fields of the Header section are accessed via specific
+ /// methods of the \c Message class (e.g., \c getQid()).
+ ///
+ /// <b>Open Design Issue:</b>
+ /// In the current implementation the values for the constants are
+ /// sorted in the order of appearance in DNS messages, i.e.,
+ /// from %Question to Additional.
+ /// So, for example,
+ /// code <code>section >= Message::SECTION_AUTHORITY</code> can be
+ /// used to do something in or after the Authority section.
+ /// This would be convenient, but it is not clear if it's really a good
+ /// idea to rely on relationship between the underlying values of enum
+ /// constants. At the moment, applications are discouraged to rely on
+ /// this implementation detail. We will see if such usage is sufficiently
+ /// common to officially support it.
+ ///
+ /// Note also that since we don't define \c operator++ for this enum,
+ /// the following code intending to iterate over all sections will
+ /// \b not compile:
+ /// \code for (Section s; s <= SECTION_ADDITIONAL; ++s) { // ++s undefined
+ /// // do something
+ /// } \endcode
+ /// This is intentional at this moment, and we'll see if we need to allow
+ /// that as we have more experiences with this library.
+ ///
+ /// <b>Future Extension:</b> We'll probably also define constants for
+ /// the section names used in dynamic updates in future versions.
+ enum Section {
+ SECTION_QUESTION = 0, ///< %Question section
+ SECTION_ANSWER = 1, ///< Answer section
+ SECTION_AUTHORITY = 2, ///< Authority section
+ SECTION_ADDITIONAL = 3 ///< Additional section
+ };
+
///
/// \name Constructors and Destructor
///
- /// Note: The copy constructor and the assignment operator are intentionally
- /// defined as private. The intended use case wouldn't require copies of
- /// a \c Message object; once created, it would normally be expected to
- /// be reused, changing the mode from \c PARSE to \c RENDER, and vice
- /// versa.
+ /// Note: The copy constructor and the assignment operator are
+ /// intentionally defined as private.
+ /// The intended use case wouldn't require copies of a \c Message object;
+ /// once created, it would normally be expected to be reused, changing the
+ /// mode from \c PARSE to \c RENDER, and vice versa.
//@{
public:
/// \brief The constructor.
@@ -301,26 +264,51 @@
public:
/// \brief Return whether the specified header flag bit is set in the
/// header section.
- bool getHeaderFlag(const MessageFlag& flag) const;
-
- /// \brief Set the specified header flag bit is set in the header section.
- ///
- /// Only allowed in the \c RENDER mode.
- void setHeaderFlag(const MessageFlag& flag);
-
- /// \brief Clear the specified header flag bit is set in the header section.
- ///
- /// Only allowed in the \c RENDER mode.
- /// Note: it may make more sense to integrate this method into \c
- /// \c setHeaderFlag() with an additional argument.
- void clearHeaderFlag(const MessageFlag& flag);
+ ///
+ /// This method is basically exception free, but if
+ /// \c flag is not a valid constant of the \c HeaderFlag type,
+ /// an exception of class \c InvalidParameter will be thrown.
+ ///
+ /// \param flag The header flag constant to test.
+ /// \return \c true if the specified flag is set; otherwise \c false.
+ bool getHeaderFlag(const HeaderFlag flag) const;
+
+ /// \brief Set or clear the specified header flag bit in the header
+ /// section.
+ ///
+ /// The optional parameter \c on indicates the operation mode,
+ /// set or clear; if it's \c true the corresponding flag will be set;
+ /// otherwise the flag will be cleared.
+ /// In either case the original state of the flag does not affect the
+ /// operation; for example, if a flag is already set and the "set"
+ /// operation is attempted, it effectively results in no operation.
+ ///
+ /// The parameter \c on can be omitted, in which case a value of \c true
+ /// (i.e., set operation) will be assumed.
+ /// This is based on the observation that the flag would have to be set
+ /// in the vast majority of the cases where an application needs to
+ /// use this method.
+ ///
+ /// This method is only allowed in the \c RENDER mode;
+ /// if the \c Message is in other mode, an exception of class
+ /// InvalidMessageOperation will be thrown.
+ ///
+ /// If \c flag is not a valid constant of the \c HeaderFlag type,
+ /// an exception of class \c InvalidParameter will be thrown.
+ ///
+ /// \param flag The header flag constant to set or clear.
+ /// \param on If \c true the flag will be set; otherwise the flag will be
+ /// cleared.
+ void setHeaderFlag(const HeaderFlag flag, const bool on = true);
/// \brief Return the query ID given in the header section of the message.
qid_t getQid() const;
/// \brief Set the query ID of the header section of the message.
///
- /// Only allowed in the \c RENDER mode.
+ /// This method is only allowed in the \c RENDER mode;
+ /// if the \c Message is in other mode, an exception of class
+ /// InvalidMessageOperation will be thrown.
void setQid(qid_t qid);
/// \brief Return the Response Code of the message.
@@ -338,7 +326,9 @@
/// \brief Set the Response Code of the message.
///
- /// Only allowed in the \c RENDER mode.
+ /// This method is only allowed in the \c RENDER mode;
+ /// if the \c Message is in other mode, an exception of class
+ /// InvalidMessageOperation will be thrown.
///
/// If the specified code is an EDNS extended RCODE, an EDNS OPT RR will be
/// included in the message.
@@ -354,7 +344,9 @@
/// \brief Set the OPCODE of the header section of the message.
///
- /// Only allowed in the \c RENDER mode.
+ /// This method is only allowed in the \c RENDER mode;
+ /// if the \c Message is in other mode, an exception of class
+ /// InvalidMessageOperation will be thrown.
void setOpcode(const Opcode& opcode);
/// \brief Return, if any, the EDNS associated with the message.
@@ -367,15 +359,38 @@
/// \brief Set EDNS for the message.
///
- /// Only allowed in the \c RENDER mode; otherwise an exception of class
- /// \c InvalidMessageOperation will be thrown.
+ /// This method is only allowed in the \c RENDER mode;
+ /// if the \c Message is in other mode, an exception of class
+ /// InvalidMessageOperation will be thrown.
///
/// \param edns A shared pointer to an \c EDNS object to be set in
/// \c Message.
void setEDNS(ConstEDNSPtr edns);
/// \brief Returns the number of RRs contained in the given section.
- unsigned int getRRCount(const Section& section) const;
+ ///
+ /// In the \c PARSE mode, the returned value may not be identical to
+ /// the actual number of RRs of the incoming message that is parsed.
+ /// The \c Message class handles some "meta" RRs such as EDNS OPT RR
+ /// separately. This method doesn't include such RRs.
+ /// Also, a future version of the parser will detect and unify duplicate
+ /// RRs (which should be rare in practice though), in which case
+ /// the stored RRs in the \c Message object will be fewer than the RRs
+ /// originally contained in the incoming message.
+ ///
+ /// Likewise, in the \c RENDER mode, even if \c EDNS is set in the
+ /// \c Message, this method doesn't count the corresponding OPT RR
+ /// in the Additional section.
+ ///
+ /// This method is basically exception free, but if
+ /// \c section is not a valid constant of the \c Section type,
+ /// an exception of class \c OutOfRange will be thrown.
+ ///
+ /// \param section The section in the message where RRs should be
+ /// counted.
+ /// \return The number of RRs stored in the specified section of the
+ /// message.
+ unsigned int getRRCount(const Section section) const;
/// \brief Return an iterator corresponding to the beginning of the
/// Question section of the message.
@@ -387,15 +402,23 @@
/// \brief Return an iterator corresponding to the beginning of the
/// given section (other than Question) of the message.
- const RRsetIterator beginSection(const Section& section) const;
+ ///
+ /// \c section must be a valid constant of the \c Section type;
+ /// otherwise, an exception of class \c OutOfRange will be thrown.
+ const RRsetIterator beginSection(const Section section) const;
/// \brief Return an iterator corresponding to the end of the
/// given section (other than Question) of the message.
- const RRsetIterator endSection(const Section& section) const;
+ ///
+ /// \c section must be a valid constant of the \c Section type;
+ /// otherwise, an exception of class \c OutOfRange will be thrown.
+ const RRsetIterator endSection(const Section section) const;
/// \brief Add a (pointer like object of) Question to the message.
///
- /// Only allowed in the \c RENDER mode.
+ /// This method is only allowed in the \c RENDER mode;
+ /// if the \c Message is in other mode, an exception of class
+ /// InvalidMessageOperation will be thrown.
void addQuestion(QuestionPtr question);
/// \brief Add a (pointer like object of) Question to the message.
@@ -406,7 +429,9 @@
/// form may be more intuitive and may make more sense for performance
/// insensitive applications.
///
- /// Only allowed in the \c RENDER mode.
+ /// This method is only allowed in the \c RENDER mode;
+ /// if the \c Message is in other mode, an exception of class
+ /// InvalidMessageOperation will be thrown.
void addQuestion(const Question& question);
/// \brief Add a (pointer like object of) RRset to the given section
@@ -415,23 +440,34 @@
/// This interface takes into account the RRSIG possibly attached to
/// \c rrset. This interface design needs to be revisited later.
///
- /// Only allowed in the \c RENDER mode.
- ///
- /// Note that addRRset() does not currently check for duplicate
+ /// This method is only allowed in the \c RENDER mode;
+ /// if the \c Message is in other mode, an exception of class
+ /// InvalidMessageOperation will be thrown.
+ /// \c section must be a valid constant of the \c Section type;
+ /// otherwise, an exception of class \c OutOfRange will be thrown.
+ ///
+ /// Note that \c addRRset() does not currently check for duplicate
/// data before inserting RRsets. The caller is responsible for
- /// checking for these (see hasRRset() below).
- void addRRset(const Section& section, RRsetPtr rrset, bool sign = false);
+ /// checking for these (see \c hasRRset() below).
+ void addRRset(const Section section, RRsetPtr rrset, bool sign = false);
/// \brief Determine whether the given section already has an RRset
- /// matching the name and type of this one
- bool hasRRset(const Section& section, RRsetPtr rrset);
+ /// matching the given name, RR class and RR type.
+ ///
+ /// \c section must be a valid constant of the \c Section type;
+ /// otherwise, an exception of class \c OutOfRange will be thrown.
+ ///
+ /// This should probably be extended to be a "find" method that returns
+ /// a matching RRset if found.
+ bool hasRRset(const Section section, const Name& name,
+ const RRClass& rrclass, const RRType& rrtype);
// The following methods are not currently implemented.
//void removeQuestion(QuestionPtr question);
- //void removeRRset(const Section& section, RRsetPtr rrset);
+ //void removeRRset(const Section section, RRsetPtr rrset);
// notyet:
- //void addRR(const Section& section, const RR& rr);
- //void removeRR(const Section& section, const RR& rr);
+ //void addRR(const Section section, const RR& rr);
+ //void removeRR(const Section section, const RR& rr);
/// \brief Clear the message content (if any) and reinitialize it in the
/// specified mode.
@@ -475,9 +511,6 @@
///
/// With EDNS the maximum size can be increased per message.
static const uint16_t DEFAULT_MAX_UDPSIZE = 512;
-
- /// \brief The highest EDNS version this implementation supports.
- static const uint8_t EDNS_SUPPORTED_VERSION = 0;
//@}
private:
Modified: branches/trac299/src/lib/dns/python/Makefile.am
==============================================================================
--- branches/trac299/src/lib/dns/python/Makefile.am (original)
+++ branches/trac299/src/lib/dns/python/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,6 +1,7 @@
SUBDIRS = . tests
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS)
pyexec_LTLIBRARIES = pydnspp.la
Modified: branches/trac299/src/lib/dns/python/message_python.cc
==============================================================================
--- branches/trac299/src/lib/dns/python/message_python.cc (original)
+++ branches/trac299/src/lib/dns/python/message_python.cc Sun Nov 7 11:01:06 2010
@@ -14,6 +14,7 @@
// $Id$
+#include <exceptions/exceptions.h>
#include <dns/message.h>
using namespace isc::dns;
@@ -35,340 +36,9 @@
// and static wrappers around the methods we export), a list of methods,
// and a type description
-
-//
-// MessageFlag
-//
-class s_MessageFlag : public PyObject {
-public:
- const MessageFlag* messageflag;
-};
-
-static int MessageFlag_init(s_MessageFlag* self, PyObject* args);
-static void MessageFlag_destroy(s_MessageFlag* self);
-
-static PyObject* MessageFlag_getBit(s_MessageFlag* self);
-static PyObject* MessageFlag_QR(s_MessageFlag* self);
-static PyObject* MessageFlag_AA(s_MessageFlag* self);
-static PyObject* MessageFlag_TC(s_MessageFlag* self);
-static PyObject* MessageFlag_RD(s_MessageFlag* self);
-static PyObject* MessageFlag_RA(s_MessageFlag* self);
-static PyObject* MessageFlag_AD(s_MessageFlag* self);
-static PyObject* MessageFlag_CD(s_MessageFlag* self);
-
-static PyMethodDef MessageFlag_methods[] = {
- { "get_bit", reinterpret_cast<PyCFunction>(MessageFlag_getBit), METH_NOARGS, "Returns the flag bit" },
- { "QR", reinterpret_cast<PyCFunction>(MessageFlag_QR), METH_NOARGS | METH_STATIC, "Creates a QR MessageFlag" },
- { "AA", reinterpret_cast<PyCFunction>(MessageFlag_AA), METH_NOARGS | METH_STATIC, "Creates a AA MessageFlag" },
- { "TC", reinterpret_cast<PyCFunction>(MessageFlag_TC), METH_NOARGS | METH_STATIC, "Creates a TC MessageFlag" },
- { "RD", reinterpret_cast<PyCFunction>(MessageFlag_RD), METH_NOARGS | METH_STATIC, "Creates a RD MessageFlag" },
- { "RA", reinterpret_cast<PyCFunction>(MessageFlag_RA), METH_NOARGS | METH_STATIC, "Creates a RA MessageFlag" },
- { "AD", reinterpret_cast<PyCFunction>(MessageFlag_AD), METH_NOARGS | METH_STATIC, "Creates a AD MessageFlag" },
- { "CD", reinterpret_cast<PyCFunction>(MessageFlag_CD), METH_NOARGS | METH_STATIC, "Creates a CD MessageFlag" },
- { NULL, NULL, 0, NULL }
-};
-
-static PyTypeObject messageflag_type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "pydnspp.MessageFlag",
- sizeof(s_MessageFlag), // tp_basicsize
- 0, // tp_itemsize
- (destructor)MessageFlag_destroy, // tp_dealloc
- NULL, // tp_print
- NULL, // tp_getattr
- NULL, // tp_setattr
- NULL, // tp_reserved
- NULL, // tp_repr
- NULL, // tp_as_number
- NULL, // tp_as_sequence
- NULL, // tp_as_mapping
- NULL, // tp_hash
- NULL, // tp_call
- NULL, // tp_str
- NULL, // tp_getattro
- NULL, // tp_setattro
- NULL, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "The MessageFlag class objects represent standard "
- "flag bits of the header section of DNS messages.",
- NULL, // tp_traverse
- NULL, // tp_clear
- NULL, // tp_richcompare
- 0, // tp_weaklistoffset
- NULL, // tp_iter
- NULL, // tp_iternext
- MessageFlag_methods, // tp_methods
- NULL, // tp_members
- NULL, // tp_getset
- NULL, // tp_base
- NULL, // tp_dict
- NULL, // tp_descr_get
- NULL, // tp_descr_set
- 0, // tp_dictoffset
- (initproc)MessageFlag_init, // tp_init
- NULL, // tp_alloc
- PyType_GenericNew, // tp_new
- NULL, // tp_free
- NULL, // tp_is_gc
- NULL, // tp_bases
- NULL, // tp_mro
- NULL, // tp_cache
- NULL, // tp_subclasses
- NULL, // tp_weaklist
- NULL, // tp_del
- 0 // tp_version_tag
-};
-
-static int
-MessageFlag_init(s_MessageFlag* self UNUSED_PARAM,
- PyObject* args UNUSED_PARAM)
-{
- PyErr_SetString(PyExc_NotImplementedError,
- "MessageFlag can't be built directly");
- return (-1);
-}
-
-static void
-MessageFlag_destroy(s_MessageFlag* self) {
- // We only use the consts from MessageFlag, so don't
- // delete self->messageflag here
- self->messageflag = NULL;
- Py_TYPE(self)->tp_free(self);
-}
-
-static PyObject*
-MessageFlag_getBit(s_MessageFlag* self) {
- return (Py_BuildValue("I", self->messageflag->getBit()));
-}
-
-static PyObject*
-MessageFlag_createStatic(const MessageFlag& flag) {
- s_MessageFlag* ret = PyObject_New(s_MessageFlag, &messageflag_type);
- if (ret != NULL) {
- ret->messageflag = &flag;
- }
- return (ret);
-}
-
-static PyObject*
-MessageFlag_QR(s_MessageFlag* self UNUSED_PARAM) {
- return (MessageFlag_createStatic(MessageFlag::QR()));
-}
-
-static PyObject*
-MessageFlag_AA(s_MessageFlag* self UNUSED_PARAM) {
- return (MessageFlag_createStatic(MessageFlag::AA()));
-}
-
-static PyObject*
-MessageFlag_TC(s_MessageFlag* self UNUSED_PARAM) {
- return (MessageFlag_createStatic(MessageFlag::TC()));
-}
-
-static PyObject*
-MessageFlag_RD(s_MessageFlag* self UNUSED_PARAM) {
- return (MessageFlag_createStatic(MessageFlag::RD()));
-}
-
-static PyObject*
-MessageFlag_RA(s_MessageFlag* self UNUSED_PARAM) {
- return (MessageFlag_createStatic(MessageFlag::RA()));
-}
-
-static PyObject*
-MessageFlag_AD(s_MessageFlag* self UNUSED_PARAM) {
- return (MessageFlag_createStatic(MessageFlag::AD()));
-}
-
-static PyObject*
-MessageFlag_CD(s_MessageFlag* self UNUSED_PARAM) {
- return (MessageFlag_createStatic(MessageFlag::CD()));
-}
-
-//
-// End of MessageFlag wrapper
-//
-
//
// Section
//
-
-// TODO: iterator?
-
-class s_Section : public PyObject {
-public:
- const Section* section;
-};
-
-static int Section_init(s_Section* self, PyObject* args);
-static void Section_destroy(s_Section* self);
-
-static PyObject* Section_getCode(s_Section* self);
-static PyObject* Section_QUESTION(s_Section* self);
-static PyObject* Section_ANSWER(s_Section* self);
-static PyObject* Section_AUTHORITY(s_Section* self);
-static PyObject* Section_ADDITIONAL(s_Section* self);
-static PyObject* Section_richcmp(s_Section* self, s_Section* other, int op);
-
-static PyMethodDef Section_methods[] = {
- { "get_code", reinterpret_cast<PyCFunction>(Section_getCode), METH_NOARGS, "Returns the code value" },
- { "QUESTION", reinterpret_cast<PyCFunction>(Section_QUESTION), METH_NOARGS | METH_STATIC, "Creates a QUESTION Section" },
- { "ANSWER", reinterpret_cast<PyCFunction>(Section_ANSWER), METH_NOARGS | METH_STATIC, "Creates an ANSWER Section" },
- { "AUTHORITY", reinterpret_cast<PyCFunction>(Section_AUTHORITY), METH_NOARGS | METH_STATIC, "Creates an AUTHORITY Section" },
- { "ADDITIONAL", reinterpret_cast<PyCFunction>(Section_ADDITIONAL), METH_NOARGS | METH_STATIC, "Creates an ADDITIONAL Section" },
- { NULL, NULL, 0, NULL }
-};
-
-static PyTypeObject section_type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "pydnspp.Section",
- sizeof(s_Section), // tp_basicsize
- 0, // tp_itemsize
- (destructor)Section_destroy, // tp_dealloc
- NULL, // tp_print
- NULL, // tp_getattr
- NULL, // tp_setattr
- NULL, // tp_reserved
- NULL, // tp_repr
- NULL, // tp_as_number
- NULL, // tp_as_sequence
- NULL, // tp_as_mapping
- NULL, // tp_hash
- NULL, // tp_call
- NULL, // tp_str
- NULL, // tp_getattro
- NULL, // tp_setattro
- NULL, // tp_as_buffer
- Py_TPFLAGS_DEFAULT, // tp_flags
- "The Section class objects represent DNS message sections such "
- "as the header, question, or answer.",
- NULL, // tp_traverse
- NULL, // tp_clear
- (richcmpfunc)Section_richcmp, // tp_richcompare
- 0, // tp_weaklistoffset
- NULL, // tp_iter
- NULL, // tp_iternext
- Section_methods, // tp_methods
- NULL, // tp_members
- NULL, // tp_getset
- NULL, // tp_base
- NULL, // tp_dict
- NULL, // tp_descr_get
- NULL, // tp_descr_set
- 0, // tp_dictoffset
- (initproc)Section_init, // tp_init
- NULL, // tp_alloc
- PyType_GenericNew, // tp_new
- NULL, // tp_free
- NULL, // tp_is_gc
- NULL, // tp_bases
- NULL, // tp_mro
- NULL, // tp_cache
- NULL, // tp_subclasses
- NULL, // tp_weaklist
- NULL, // tp_del
- 0 // tp_version_tag
-};
-
-
-static int
-Section_init(s_Section* self UNUSED_PARAM,
- PyObject* args UNUSED_PARAM)
-{
- PyErr_SetString(PyExc_NotImplementedError,
- "Section can't be built directly");
- return (-1);
-}
-
-static void
-Section_destroy(s_Section* self) {
- // We only use the consts from Section, so don't
- // delete self->section here
- self->section = NULL;
- Py_TYPE(self)->tp_free(self);
-}
-
-static PyObject*
-Section_getCode(s_Section* self) {
- return (Py_BuildValue("I", self->section->getCode()));
-}
-
-static PyObject*
-Section_createStatic(const Section& section) {
- s_Section* ret = PyObject_New(s_Section, §ion_type);
- if (ret != NULL) {
- ret->section = §ion;
- }
- return (ret);
-}
-
-
-static PyObject*
-Section_QUESTION(s_Section* self UNUSED_PARAM) {
- return (Section_createStatic(Section::QUESTION()));
-}
-
-static PyObject*
-Section_ANSWER(s_Section* self UNUSED_PARAM) {
- return (Section_createStatic(Section::ANSWER()));
-}
-
-static PyObject*
-Section_AUTHORITY(s_Section* self UNUSED_PARAM) {
- return (Section_createStatic(Section::AUTHORITY()));
-}
-
-static PyObject*
-Section_ADDITIONAL(s_Section* self UNUSED_PARAM) {
- return (Section_createStatic(Section::ADDITIONAL()));
-}
-
-static PyObject*
-Section_richcmp(s_Section* self, s_Section* other, int op) {
- bool c = false;
-
- // Check for null and if the types match. If different type,
- // simply return False
- if (!other || (self->ob_type != other->ob_type)) {
- Py_RETURN_FALSE;
- }
-
- // Only equals and not equals here, unorderable type
- switch (op) {
- case Py_LT:
- PyErr_SetString(PyExc_TypeError, "Unorderable type; Section");
- return (NULL);
- break;
- case Py_LE:
- PyErr_SetString(PyExc_TypeError, "Unorderable type; Section");
- return (NULL);
- break;
- case Py_EQ:
- c = (*self->section == *other->section);
- break;
- case Py_NE:
- c = (*self->section != *other->section);
- break;
- case Py_GT:
- PyErr_SetString(PyExc_TypeError, "Unorderable type; Section");
- return (NULL);
- break;
- case Py_GE:
- PyErr_SetString(PyExc_TypeError, "Unorderable type; Section");
- return (NULL);
- break;
- }
- if (c)
- Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
-}
-
-//
-// End of Section wrapper
-//
-
-
//
// Message
@@ -391,7 +61,6 @@
static PyObject* Message_getHeaderFlag(s_Message* self, PyObject* args);
static PyObject* Message_setHeaderFlag(s_Message* self, PyObject* args);
-static PyObject* Message_clearHeaderFlag(s_Message* self, PyObject* args);
static PyObject* Message_getQid(s_Message* self);
static PyObject* Message_setQid(s_Message* self, PyObject* args);
static PyObject* Message_getRcode(s_Message* self);
@@ -425,15 +94,13 @@
// 3. Argument type
// 4. Documentation
static PyMethodDef Message_methods[] = {
- { "get_header_flag", reinterpret_cast<PyCFunction>(Message_getHeaderFlag), METH_VARARGS,
+ { "get_header_flag", reinterpret_cast<PyCFunction>(Message_getHeaderFlag),
+ METH_VARARGS,
"Return whether the specified header flag bit is set in the "
"header section. Takes a MessageFlag object as the only argument." },
- { "set_header_flag", reinterpret_cast<PyCFunction>(Message_setHeaderFlag), METH_VARARGS,
+ { "set_header_flag",
+ reinterpret_cast<PyCFunction>(Message_setHeaderFlag), METH_VARARGS,
"Sets the specified header flag bit to 1. The message must be in "
- "RENDER mode. If not, an InvalidMessageOperation is raised. "
- "Takes a MessageFlag object as the only argument." },
- { "clear_header_flag", reinterpret_cast<PyCFunction>(Message_clearHeaderFlag), METH_VARARGS,
- "Sets the specified header flag bit to 0. The message must be in "
"RENDER mode. If not, an InvalidMessageOperation is raised. "
"Takes a MessageFlag object as the only argument." },
{ "get_qid", reinterpret_cast<PyCFunction>(Message_getQid), METH_NOARGS,
@@ -562,8 +229,6 @@
static int
Message_init(s_Message* self, PyObject* args) {
unsigned int i;
- // The constructor argument can be a string ("IN"), an integer (1),
- // or a sequence of numbers between 0 and 255 (wire code)
if (PyArg_ParseTuple(args, "I", &i)) {
PyErr_Clear();
@@ -593,12 +258,16 @@
static PyObject*
Message_getHeaderFlag(s_Message* self, PyObject* args) {
- s_MessageFlag* messageflag;
- if (!PyArg_ParseTuple(args, "O!", &messageflag_type, &messageflag)) {
- return (NULL);
- }
-
- if (self->message->getHeaderFlag(*messageflag->messageflag)) {
+ unsigned int messageflag;
+ if (!PyArg_ParseTuple(args, "I", &messageflag)) {
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError,
+ "no valid type in get_header_flag argument");
+ return (NULL);
+ }
+
+ if (self->message->getHeaderFlag(
+ static_cast<Message::HeaderFlag>(messageflag))) {
Py_RETURN_TRUE;
} else {
Py_RETURN_FALSE;
@@ -607,38 +276,33 @@
static PyObject*
Message_setHeaderFlag(s_Message* self, PyObject* args) {
- s_MessageFlag* messageflag;
- if (!PyArg_ParseTuple(args, "O!", &messageflag_type, &messageflag)) {
- return (NULL);
- }
-
- try {
- self->message->setHeaderFlag(*messageflag->messageflag);
+ int messageflag;
+ PyObject *on = Py_True;
+
+ if (!PyArg_ParseTuple(args, "i|O!", &messageflag, &PyBool_Type, &on)) {
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError,
+ "no valid type in set_header_flag argument");
+ return (NULL);
+ }
+ if (messageflag < 0) {
+ PyErr_SetString(PyExc_TypeError, "invalid Message header flag");
+ return (NULL);
+ }
+
+ try {
+ self->message->setHeaderFlag(
+ static_cast<Message::HeaderFlag>(messageflag), on == Py_True);
Py_RETURN_NONE;
} catch (const InvalidMessageOperation& imo) {
PyErr_Clear();
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
- }
-}
-
-static PyObject*
-Message_clearHeaderFlag(s_Message* self, PyObject* args) {
- s_MessageFlag* messageflag;
- if (!PyArg_ParseTuple(args, "O!", &messageflag_type, &messageflag)) {
- return (NULL);
- }
-
- try {
- self->message->clearHeaderFlag(*messageflag->messageflag);
- Py_RETURN_NONE;
- } catch (const InvalidMessageOperation& imo) {
- PyErr_Clear();
- PyErr_SetString(po_InvalidMessageOperation, imo.what());
- return (NULL);
- }
-
- Py_RETURN_NONE;
+ } catch (const isc::InvalidParameter& ip) {
+ PyErr_Clear();
+ PyErr_SetString(po_InvalidParameter, ip.what());
+ return (NULL);
+ }
}
static PyObject*
@@ -774,58 +438,107 @@
static PyObject*
Message_getRRCount(s_Message* self, PyObject* args) {
- s_Section *section;
- if (!PyArg_ParseTuple(args, "O!", §ion_type, §ion)) {
- return (NULL);
- }
- return (Py_BuildValue("I", self->message->getRRCount(*section->section)));
+ unsigned int section;
+ if (!PyArg_ParseTuple(args, "I", §ion)) {
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError,
+ "no valid type in get_rr_count argument");
+ return (NULL);
+ }
+ try {
+ return (Py_BuildValue("I", self->message->getRRCount(
+ static_cast<Message::Section>(section))));
+ } catch (const isc::OutOfRange& ex) {
+ PyErr_SetString(PyExc_OverflowError, ex.what());
+ return (NULL);
+ }
}
// TODO use direct iterators for these? (or simply lists for now?)
static PyObject*
Message_getQuestion(s_Message* self) {
+ QuestionIterator qi, qi_end;
+ try {
+ qi = self->message->beginQuestion();
+ qi_end = self->message->endQuestion();
+ } catch (const InvalidMessageSection& ex) {
+ PyErr_SetString(po_InvalidMessageSection, ex.what());
+ return (NULL);
+ } catch (...) {
+ PyErr_SetString(po_IscException,
+ "Unexpected exception in getting section iterators");
+ return (NULL);
+ }
+
PyObject* list = PyList_New(0);
-
- for (QuestionIterator qi = self->message->beginQuestion();
- qi != self->message->endQuestion();
- ++qi) {
- s_Question *question = static_cast<s_Question*>(question_type.tp_alloc(&question_type, 0));
- if (question != NULL) {
- question->question = *qi;
- if (question->question == NULL)
- {
- Py_DECREF(question);
- return (NULL);
- }
- }
- PyList_Append(list, question);
+ if (list == NULL) {
+ return (NULL);
+ }
+
+ for (; qi != qi_end; ++qi) {
+ s_Question *question = static_cast<s_Question*>(
+ question_type.tp_alloc(&question_type, 0));
+ if (question == NULL) {
+ Py_DECREF(question);
+ Py_DECREF(list);
+ return (NULL);
+ }
+ question->question = *qi;
+ if (PyList_Append(list, question) == -1) {
+ Py_DECREF(question);
+ Py_DECREF(list);
+ return (NULL);
+ }
+ Py_DECREF(question);
}
return (list);
}
static PyObject*
Message_getSection(s_Message* self, PyObject* args) {
- s_Section *section;
- if (!PyArg_ParseTuple(args, "O!", §ion_type, §ion)) {
- return (NULL);
- }
+ unsigned int section;
+ if (!PyArg_ParseTuple(args, "I", §ion)) {
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError,
+ "no valid type in get_section argument");
+ return (NULL);
+ }
+ RRsetIterator rrsi, rrsi_end;
+ try {
+ rrsi = self->message->beginSection(
+ static_cast<Message::Section>(section));
+ rrsi_end = self->message->endSection(
+ static_cast<Message::Section>(section));
+ } catch (const isc::OutOfRange& ex) {
+ PyErr_SetString(PyExc_OverflowError, ex.what());
+ return (NULL);
+ } catch (const InvalidMessageSection& ex) {
+ PyErr_SetString(po_InvalidMessageSection, ex.what());
+ return (NULL);
+ } catch (...) {
+ PyErr_SetString(po_IscException,
+ "Unexpected exception in getting section iterators");
+ return (NULL);
+ }
+
PyObject* list = PyList_New(0);
-
- for (RRsetIterator rrsi = self->message->beginSection(*section->section);
- rrsi != self->message->endSection(*section->section);
- ++rrsi) {
-
- s_RRset *rrset = static_cast<s_RRset*>(rrset_type.tp_alloc(&rrset_type, 0));
- if (rrset != NULL) {
- rrset->rrset = *rrsi;
- if (rrset->rrset == NULL)
- {
+ if (list == NULL) {
+ return (NULL);
+ }
+ for (; rrsi != rrsi_end; ++rrsi) {
+ s_RRset *rrset = static_cast<s_RRset*>(
+ rrset_type.tp_alloc(&rrset_type, 0));
+ if (rrset == NULL) {
Py_DECREF(rrset);
Py_DECREF(list);
return (NULL);
- }
- }
- PyList_Append(list, rrset);
+ }
+ rrset->rrset = *rrsi;
+ if (PyList_Append(list, rrset) == -1) {
+ Py_DECREF(rrset);
+ Py_DECREF(list);
+ return (NULL);
+ }
// PyList_Append increases refcount, so we remove ours since
// we don't need it anymore
Py_DECREF(rrset);
@@ -854,33 +567,33 @@
static PyObject*
Message_addRRset(s_Message* self, PyObject* args) {
PyObject *sign = Py_False;
- s_Section* section;
+ unsigned int section;
s_RRset* rrset;
- if (!PyArg_ParseTuple(args, "O!O!|O!", §ion_type, §ion,
- &rrset_type, &rrset,
- &PyBool_Type, &sign)) {
- return (NULL);
- }
-
- try {
- if (sign == Py_True) {
- self->message->addRRset(*section->section, rrset->rrset, true);
- } else {
- self->message->addRRset(*section->section, rrset->rrset, false);
- }
+ if (!PyArg_ParseTuple(args, "IO!|O!", §ion, &rrset_type, &rrset,
+ &PyBool_Type, &sign)) {
+ return (NULL);
+ }
+
+ try {
+ self->message->addRRset(static_cast<Message::Section>(section),
+ rrset->rrset, sign == Py_True);
Py_RETURN_NONE;
} catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
+ } catch (const isc::OutOfRange& ex) {
+ PyErr_SetString(PyExc_OverflowError, ex.what());
+ return (NULL);
+ } catch (...) {
+ PyErr_SetString(po_IscException,
+ "Unexpected exception in adding RRset");
+ return (NULL);
}
}
static PyObject*
Message_clear(s_Message* self, PyObject* args) {
unsigned int i;
- // The constructor argument can be a string ("IN"), an integer (1),
- // or a sequence of numbers between 0 and 255 (wire code)
-
if (PyArg_ParseTuple(args, "I", &i)) {
PyErr_Clear();
if (i == Message::PARSE) {
@@ -890,7 +603,8 @@
self->message->clear(Message::RENDER);
Py_RETURN_NONE;
} else {
- PyErr_SetString(PyExc_TypeError, "Message mode must be Message.PARSE or Message.RENDER");
+ PyErr_SetString(PyExc_TypeError,
+ "Message mode must be Message.PARSE or Message.RENDER");
return (NULL);
}
} else {
@@ -979,62 +693,64 @@
// Module Initialization, all statics are initialized here
bool
initModulePart_Message(PyObject* mod) {
-
- // add methods to class
- if (PyType_Ready(&messageflag_type) < 0) {
- return (false);
- }
- Py_INCREF(&messageflag_type);
- PyModule_AddObject(mod, "MessageFlag",
- reinterpret_cast<PyObject*>(&messageflag_type));
-
-
- if (PyType_Ready(&opcode_type) < 0) {
- return (false);
- }
- Py_INCREF(&opcode_type);
- PyModule_AddObject(mod, "Opcode",
- reinterpret_cast<PyObject*>(&opcode_type));
-
- if (PyType_Ready(&rcode_type) < 0) {
- return (false);
- }
- Py_INCREF(&rcode_type);
- PyModule_AddObject(mod, "Rcode",
- reinterpret_cast<PyObject*>(&rcode_type));
-
- if (PyType_Ready(§ion_type) < 0) {
- return (false);
- }
- Py_INCREF(§ion_type);
- PyModule_AddObject(mod, "Section",
- reinterpret_cast<PyObject*>(§ion_type));
-
-
if (PyType_Ready(&message_type) < 0) {
return (false);
}
+ Py_INCREF(&message_type);
// Class variables
// These are added to the tp_dict of the type object
//
- addClassVariable(message_type, "PARSE", Py_BuildValue("I", Message::PARSE));
- addClassVariable(message_type, "RENDER", Py_BuildValue("I", Message::RENDER));
- addClassVariable(message_type, "DEFAULT_MAX_UDPSIZE", Py_BuildValue("I", Message::DEFAULT_MAX_UDPSIZE));
+ addClassVariable(message_type, "PARSE",
+ Py_BuildValue("I", Message::PARSE));
+ addClassVariable(message_type, "RENDER",
+ Py_BuildValue("I", Message::RENDER));
+
+ addClassVariable(message_type, "HEADERFLAG_QR",
+ Py_BuildValue("I", Message::HEADERFLAG_QR));
+ addClassVariable(message_type, "HEADERFLAG_AA",
+ Py_BuildValue("I", Message::HEADERFLAG_AA));
+ addClassVariable(message_type, "HEADERFLAG_TC",
+ Py_BuildValue("I", Message::HEADERFLAG_TC));
+ addClassVariable(message_type, "HEADERFLAG_RD",
+ Py_BuildValue("I", Message::HEADERFLAG_RD));
+ addClassVariable(message_type, "HEADERFLAG_RA",
+ Py_BuildValue("I", Message::HEADERFLAG_RA));
+ addClassVariable(message_type, "HEADERFLAG_AD",
+ Py_BuildValue("I", Message::HEADERFLAG_AD));
+ addClassVariable(message_type, "HEADERFLAG_CD",
+ Py_BuildValue("I", Message::HEADERFLAG_CD));
+
+ addClassVariable(message_type, "SECTION_QUESTION",
+ Py_BuildValue("I", Message::SECTION_QUESTION));
+ addClassVariable(message_type, "SECTION_ANSWER",
+ Py_BuildValue("I", Message::SECTION_ANSWER));
+ addClassVariable(message_type, "SECTION_AUTHORITY",
+ Py_BuildValue("I", Message::SECTION_AUTHORITY));
+ addClassVariable(message_type, "SECTION_ADDITIONAL",
+ Py_BuildValue("I", Message::SECTION_ADDITIONAL));
+
+ addClassVariable(message_type, "DEFAULT_MAX_UDPSIZE",
+ Py_BuildValue("I", Message::DEFAULT_MAX_UDPSIZE));
/* Class-specific exceptions */
- po_MessageTooShort = PyErr_NewException("pydnspp.MessageTooShort", NULL, NULL);
+ po_MessageTooShort = PyErr_NewException("pydnspp.MessageTooShort", NULL,
+ NULL);
PyModule_AddObject(mod, "MessageTooShort", po_MessageTooShort);
- po_InvalidMessageSection = PyErr_NewException("pydnspp.InvalidMessageSection", NULL, NULL);
+ po_InvalidMessageSection =
+ PyErr_NewException("pydnspp.InvalidMessageSection", NULL, NULL);
PyModule_AddObject(mod, "InvalidMessageSection", po_InvalidMessageSection);
- po_InvalidMessageOperation = PyErr_NewException("pydnspp.InvalidMessageOperation", NULL, NULL);
- PyModule_AddObject(mod, "InvalidMessageOperation", po_InvalidMessageOperation);
- po_InvalidMessageUDPSize = PyErr_NewException("pydnspp.InvalidMessageUDPSize", NULL, NULL);
+ po_InvalidMessageOperation =
+ PyErr_NewException("pydnspp.InvalidMessageOperation", NULL, NULL);
+ PyModule_AddObject(mod, "InvalidMessageOperation",
+ po_InvalidMessageOperation);
+ po_InvalidMessageUDPSize =
+ PyErr_NewException("pydnspp.InvalidMessageUDPSize", NULL, NULL);
PyModule_AddObject(mod, "InvalidMessageUDPSize", po_InvalidMessageUDPSize);
- po_DNSMessageBADVERS = PyErr_NewException("pydnspp.DNSMessageBADVERS", NULL, NULL);
+ po_DNSMessageBADVERS = PyErr_NewException("pydnspp.DNSMessageBADVERS",
+ NULL, NULL);
PyModule_AddObject(mod, "DNSMessageBADVERS", po_DNSMessageBADVERS);
- Py_INCREF(&message_type);
PyModule_AddObject(mod, "Message",
reinterpret_cast<PyObject*>(&message_type));
Modified: branches/trac299/src/lib/dns/python/tests/message_python_test.py
==============================================================================
--- branches/trac299/src/lib/dns/python/tests/message_python_test.py (original)
+++ branches/trac299/src/lib/dns/python/tests/message_python_test.py Sun Nov 7 11:01:06 2010
@@ -22,61 +22,6 @@
from pydnspp import *
from testutil import *
-class MessageFlagTest(unittest.TestCase):
- def test_init(self):
- self.assertRaises(NotImplementedError, MessageFlag)
-
- def test_get_bit(self):
- self.assertEqual(0x8000, MessageFlag.QR().get_bit())
- self.assertEqual(0x0400, MessageFlag.AA().get_bit())
- self.assertEqual(0x0200, MessageFlag.TC().get_bit())
- self.assertEqual(0x0100, MessageFlag.RD().get_bit())
- self.assertEqual(0x0080, MessageFlag.RA().get_bit())
- self.assertEqual(0x0020, MessageFlag.AD().get_bit())
- self.assertEqual(0x0010, MessageFlag.CD().get_bit())
-
-class SectionTest(unittest.TestCase):
-
- def test_init(self):
- self.assertRaises(NotImplementedError, Section)
-
- def test_get_code(self):
- self.assertEqual(0, Section.QUESTION().get_code())
- self.assertEqual(1, Section.ANSWER().get_code())
- self.assertEqual(2, Section.AUTHORITY().get_code())
- self.assertEqual(3, Section.ADDITIONAL().get_code())
-
- def test_richcmp(self):
- s1 = Section.QUESTION()
- s2 = Section.ANSWER()
- s3 = Section.ANSWER()
- self.assertTrue(s2 == s3)
- self.assertTrue(s1 != s2)
- self.assertFalse(s1 == s2)
- self.assertFalse(s1 == 1)
- # can't use assertRaises here...
- try:
- s1 < s2
- self.fail("operation that should have raised an error unexpectedly succeeded")
- except Exception as err:
- self.assertEqual(TypeError, type(err))
- try:
- s1 <= s2
- self.fail("operation that should have raised an error unexpectedly succeeded")
- except Exception as err:
- self.assertEqual(TypeError, type(err))
- try:
- s1 > s2
- self.fail("operation that should have raised an error unexpectedly succeeded")
- except Exception as err:
- self.assertEqual(TypeError, type(err))
- try:
- s1 >= s2
- self.fail("operation that should have raised an error unexpectedly succeeded")
- except Exception as err:
- self.assertEqual(TypeError, type(err))
-
-
# helper functions for tests taken from c++ unittests
if "TESTDATA_PATH" in os.environ:
testdata_path = os.environ["TESTDATA_PATH"]
@@ -105,15 +50,16 @@
message_render.set_qid(0x1035)
message_render.set_opcode(Opcode.QUERY())
message_render.set_rcode(Rcode.NOERROR())
- message_render.set_header_flag(MessageFlag.QR())
- message_render.set_header_flag(MessageFlag.RD())
- message_render.set_header_flag(MessageFlag.AA())
- message_render.add_question(Question(Name("test.example.com"), RRClass("IN"), RRType("A")))
+ message_render.set_header_flag(Message.HEADERFLAG_QR)
+ message_render.set_header_flag(Message.HEADERFLAG_RD)
+ message_render.set_header_flag(Message.HEADERFLAG_AA)
+ message_render.add_question(Question(Name("test.example.com"),
+ RRClass("IN"), RRType("A")))
rrset = RRset(Name("test.example.com"), RRClass("IN"),
RRType("A"), RRTTL(3600))
rrset.add_rdata(Rdata(RRType("A"), RRClass("IN"), "192.0.2.1"))
rrset.add_rdata(Rdata(RRType("A"), RRClass("IN"), "192.0.2.2"))
- message_render.add_rrset(Section.ANSWER(), rrset)
+ message_render.add_rrset(Message.SECTION_ANSWER, rrset)
return message_render
@@ -122,29 +68,56 @@
def setUp(self):
self.p = Message(Message.PARSE)
self.r = Message(Message.RENDER)
-
+
+ self.rrset_a = RRset(Name("example.com"), RRClass("IN"), RRType("A"),
+ RRTTL(3600))
+ self.rrset_a.add_rdata(Rdata(RRType("A"), RRClass("IN"), "192.0.2.1"))
+ self.rrset_a.add_rdata(Rdata(RRType("A"), RRClass("IN"), "192.0.2.2"))
+
+ self.rrset_aaaa = RRset(Name("example.com"), RRClass("IN"),
+ RRType("AAAA"), RRTTL(3600))
+ self.rrset_aaaa.add_rdata(Rdata(RRType("AAAA"), RRClass("IN"),
+ "2001:db8::134"))
+
+ self.bogus_section = Message.SECTION_ADDITIONAL + 1
+
def test_init(self):
self.assertRaises(TypeError, Message, 3)
self.assertRaises(TypeError, Message, "wrong")
- def test_get_header_flag(self):
+ def test_header_flag(self): # set and get methods
self.assertRaises(TypeError, self.p.get_header_flag, "wrong")
- self.assertFalse(self.p.get_header_flag(MessageFlag.AA()))
-
- def test_set_clear_header_flag(self):
self.assertRaises(TypeError, self.r.set_header_flag, "wrong")
- self.assertRaises(TypeError, self.r.clear_header_flag, "wrong")
-
- self.assertFalse(self.r.get_header_flag(MessageFlag.AA()))
- self.r.set_header_flag(MessageFlag.AA())
- self.assertTrue(self.r.get_header_flag(MessageFlag.AA()))
- self.r.clear_header_flag(MessageFlag.AA())
- self.assertFalse(self.r.get_header_flag(MessageFlag.AA()))
-
- self.assertRaises(InvalidMessageOperation,
- self.p.set_header_flag, MessageFlag.AA())
- self.assertRaises(InvalidMessageOperation,
- self.p.clear_header_flag, MessageFlag.AA())
+
+ self.assertFalse(self.r.get_header_flag(Message.HEADERFLAG_QR))
+ self.assertFalse(self.r.get_header_flag(Message.HEADERFLAG_AA))
+ self.assertFalse(self.r.get_header_flag(Message.HEADERFLAG_TC))
+ self.assertFalse(self.r.get_header_flag(Message.HEADERFLAG_RD))
+ self.assertFalse(self.r.get_header_flag(Message.HEADERFLAG_RA))
+ self.assertFalse(self.r.get_header_flag(Message.HEADERFLAG_AD))
+ self.assertFalse(self.r.get_header_flag(Message.HEADERFLAG_CD))
+
+ self.r.set_header_flag(Message.HEADERFLAG_QR)
+ self.assertTrue(self.r.get_header_flag(Message.HEADERFLAG_QR))
+
+ self.r.set_header_flag(Message.HEADERFLAG_AA, True)
+ self.assertTrue(self.r.get_header_flag(Message.HEADERFLAG_AA))
+
+ self.r.set_header_flag(Message.HEADERFLAG_AA, False)
+ self.assertFalse(self.r.get_header_flag(Message.HEADERFLAG_AA))
+
+ self.assertRaises(InvalidParameter, self.r.set_header_flag, 0)
+ self.assertRaises(InvalidParameter, self.r.set_header_flag, 0x7000)
+ self.assertRaises(InvalidParameter, self.r.set_header_flag, 0x0800)
+ self.assertRaises(InvalidParameter, self.r.set_header_flag, 0x10000)
+ self.assertRaises(TypeError, self.r.set_header_flag, 0x80000000)
+ # this would cause overflow and result in a "valid" flag
+ self.assertRaises(TypeError, self.r.set_header_flag,
+ Message.HEADERFLAG_AA | 0x100000000)
+ self.assertRaises(TypeError, self.r.set_header_flag, -1)
+
+ self.assertRaises(InvalidMessageOperation,
+ self.p.set_header_flag, Message.HEADERFLAG_AA)
def test_set_qid(self):
self.assertRaises(TypeError, self.r.set_qid, "wrong")
@@ -195,52 +168,77 @@
self.r.set_edns(edns)
self.assertEqual(1024, self.r.get_edns().get_udp_size())
+ def test_get_rr_count(self):
+ # counts also tested in add_section
+ self.assertEqual(0, self.r.get_rr_count(Message.SECTION_QUESTION))
+ self.assertEqual(0, self.r.get_rr_count(Message.SECTION_ANSWER))
+ self.assertEqual(0, self.r.get_rr_count(Message.SECTION_AUTHORITY))
+ self.assertEqual(0, self.r.get_rr_count(Message.SECTION_ADDITIONAL))
+
+ self.r.add_question(Question(Name("example.com"), RRClass("IN"),
+ RRType("A")))
+ self.assertEqual(1, self.r.get_rr_count(Message.SECTION_QUESTION))
+
+ self.r.add_rrset(Message.SECTION_ANSWER, self.rrset_a)
+ self.assertEqual(2, self.r.get_rr_count(Message.SECTION_ANSWER))
+
+ factoryFromFile(self.p, "message_fromWire11.wire")
+ self.assertEqual(1, self.r.get_rr_count(Message.SECTION_QUESTION))
+ self.assertEqual(0, self.r.get_rr_count(Message.SECTION_ADDITIONAL))
+
+ self.assertRaises(OverflowError, self.r.get_rr_count,
+ self.bogus_section)
+ self.assertRaises(TypeError, self.r.get_rr_count, "wrong")
+
def test_get_section(self):
self.assertRaises(TypeError, self.r.get_section, "wrong")
- rrset = RRset(Name("example.com"), RRClass("IN"), RRType("A"), RRTTL(3600))
- rrset.add_rdata(Rdata(RRType("A"), RRClass("IN"), "192.0.2.1"))
- rrset.add_rdata(Rdata(RRType("A"), RRClass("IN"), "192.0.2.2"))
- section_rrset = [rrset]
+ section_rrset = [self.rrset_a]
self.assertRaises(InvalidMessageOperation, self.p.add_rrset,
- Section.ANSWER(), rrset)
+ Message.SECTION_ANSWER, self.rrset_a)
- self.assertFalse(compare_rrset_list(section_rrset, self.r.get_section(Section.ANSWER())))
- self.assertEqual(0, self.r.get_rr_count(Section.ANSWER()))
- self.r.add_rrset(Section.ANSWER(), rrset)
- self.assertTrue(compare_rrset_list(section_rrset, self.r.get_section(Section.ANSWER())))
- self.assertEqual(2, self.r.get_rr_count(Section.ANSWER()))
-
- self.assertFalse(compare_rrset_list(section_rrset, self.r.get_section(Section.AUTHORITY())))
- self.assertEqual(0, self.r.get_rr_count(Section.AUTHORITY()))
- self.r.add_rrset(Section.AUTHORITY(), rrset)
- self.assertTrue(compare_rrset_list(section_rrset, self.r.get_section(Section.AUTHORITY())))
- self.assertEqual(2, self.r.get_rr_count(Section.AUTHORITY()))
-
- self.assertFalse(compare_rrset_list(section_rrset, self.r.get_section(Section.ADDITIONAL())))
- self.assertEqual(0, self.r.get_rr_count(Section.ADDITIONAL()))
- self.r.add_rrset(Section.ADDITIONAL(), rrset)
- self.assertTrue(compare_rrset_list(section_rrset, self.r.get_section(Section.ADDITIONAL())))
- self.assertEqual(2, self.r.get_rr_count(Section.ADDITIONAL()))
-
- def test_get_rr_count(self):
- self.assertRaises(TypeError, self.r.get_rr_count, "wrong")
- # counts also tested in add_section
+ self.assertFalse(compare_rrset_list(section_rrset, self.r.get_section(Message.SECTION_ANSWER)))
+ self.assertEqual(0, self.r.get_rr_count(Message.SECTION_ANSWER))
+ self.r.add_rrset(Message.SECTION_ANSWER, self.rrset_a)
+ self.assertTrue(compare_rrset_list(section_rrset, self.r.get_section(Message.SECTION_ANSWER)))
+ self.assertEqual(2, self.r.get_rr_count(Message.SECTION_ANSWER))
+
+ self.assertFalse(compare_rrset_list(section_rrset, self.r.get_section(Message.SECTION_AUTHORITY)))
+ self.assertEqual(0, self.r.get_rr_count(Message.SECTION_AUTHORITY))
+ self.r.add_rrset(Message.SECTION_AUTHORITY, self.rrset_a)
+ self.assertTrue(compare_rrset_list(section_rrset, self.r.get_section(Message.SECTION_AUTHORITY)))
+ self.assertEqual(2, self.r.get_rr_count(Message.SECTION_AUTHORITY))
+
+ self.assertFalse(compare_rrset_list(section_rrset, self.r.get_section(Message.SECTION_ADDITIONAL)))
+ self.assertEqual(0, self.r.get_rr_count(Message.SECTION_ADDITIONAL))
+ self.r.add_rrset(Message.SECTION_ADDITIONAL, self.rrset_a)
+ self.assertTrue(compare_rrset_list(section_rrset, self.r.get_section(Message.SECTION_ADDITIONAL)))
+ self.assertEqual(2, self.r.get_rr_count(Message.SECTION_ADDITIONAL))
def test_add_question(self):
self.assertRaises(TypeError, self.r.add_question, "wrong", "wrong")
q = Question(Name("example.com"), RRClass("IN"), RRType("A"))
qs = [q]
self.assertFalse(compare_rrset_list(qs, self.r.get_question()))
- self.assertEqual(0, self.r.get_rr_count(Section.QUESTION()))
+ self.assertEqual(0, self.r.get_rr_count(Message.SECTION_QUESTION))
self.r.add_question(q)
self.assertTrue(compare_rrset_list(qs, self.r.get_question()))
- self.assertEqual(1, self.r.get_rr_count(Section.QUESTION()))
+ self.assertEqual(1, self.r.get_rr_count(Message.SECTION_QUESTION))
def test_add_rrset(self):
self.assertRaises(TypeError, self.r.add_rrset, "wrong")
- # actual addition already tested in get_section
+ self.assertRaises(TypeError, self.r.add_rrset)
+
+ # we can currently only test the no-sign case.
+ self.r.add_rrset(Message.SECTION_ANSWER, self.rrset_a)
+ self.assertEqual(2, self.r.get_rr_count(Message.SECTION_ANSWER))
+
+ def test_bad_add_rrset(self):
+ self.assertRaises(InvalidMessageOperation, self.p.add_rrset,
+ Message.SECTION_ANSWER, self.rrset_a)
+ self.assertRaises(OverflowError, self.r.add_rrset,
+ self.bogus_section, self.rrset_a)
def test_clear(self):
self.assertEqual(None, self.r.clear(Message.PARSE))
@@ -308,22 +306,22 @@
self.assertEqual(0x1035, message_parse.get_qid())
self.assertEqual(Opcode.QUERY(), message_parse.get_opcode())
self.assertEqual(Rcode.NOERROR(), message_parse.get_rcode())
- self.assertTrue(message_parse.get_header_flag(MessageFlag.QR()))
- self.assertTrue(message_parse.get_header_flag(MessageFlag.RD()))
- self.assertTrue(message_parse.get_header_flag(MessageFlag.AA()))
+ self.assertTrue(message_parse.get_header_flag(Message.HEADERFLAG_QR))
+ self.assertTrue(message_parse.get_header_flag(Message.HEADERFLAG_RD))
+ self.assertTrue(message_parse.get_header_flag(Message.HEADERFLAG_AA))
#QuestionPtr q = *message_parse.beginQuestion()
q = message_parse.get_question()[0]
self.assertEqual(test_name, q.get_name())
self.assertEqual(RRType("A"), q.get_type())
self.assertEqual(RRClass("IN"), q.get_class())
- self.assertEqual(1, message_parse.get_rr_count(Section.QUESTION()))
- self.assertEqual(2, message_parse.get_rr_count(Section.ANSWER()))
- self.assertEqual(0, message_parse.get_rr_count(Section.AUTHORITY()))
- self.assertEqual(0, message_parse.get_rr_count(Section.ADDITIONAL()))
-
- #RRsetPtr rrset = *message_parse.beginSection(Section.ANSWER())
- rrset = message_parse.get_section(Section.ANSWER())[0]
+ self.assertEqual(1, message_parse.get_rr_count(Message.SECTION_QUESTION))
+ self.assertEqual(2, message_parse.get_rr_count(Message.SECTION_ANSWER))
+ self.assertEqual(0, message_parse.get_rr_count(Message.SECTION_AUTHORITY))
+ self.assertEqual(0, message_parse.get_rr_count(Message.SECTION_ADDITIONAL))
+
+ #RRsetPtr rrset = *message_parse.beginSection(Message.SECTION_ANSWER)
+ rrset = message_parse.get_section(Message.SECTION_ANSWER)[0]
self.assertEqual(test_name, rrset.get_name())
self.assertEqual(RRType("A"), rrset.get_type())
self.assertEqual(RRClass("IN"), rrset.get_class())
Modified: branches/trac299/src/lib/dns/python/tests/messagerenderer_python_test.py
==============================================================================
--- branches/trac299/src/lib/dns/python/tests/messagerenderer_python_test.py (original)
+++ branches/trac299/src/lib/dns/python/tests/messagerenderer_python_test.py Sun Nov 7 11:01:06 2010
@@ -38,15 +38,15 @@
self.message1 = message
message = Message(Message.RENDER)
message.set_qid(123)
- message.set_header_flag(MessageFlag.AA())
- message.set_header_flag(MessageFlag.QR())
+ message.set_header_flag(Message.HEADERFLAG_AA, True)
+ message.set_header_flag(Message.HEADERFLAG_QR, True)
message.set_opcode(Opcode.QUERY())
message.set_rcode(Rcode.NOERROR())
message.add_question(Question(name, c, t))
rrset = RRset(name, c, t, ttl)
rrset.add_rdata(Rdata(t, c, "192.0.2.98"))
rrset.add_rdata(Rdata(t, c, "192.0.2.99"))
- message.add_rrset(Section.AUTHORITY(), rrset)
+ message.add_rrset(Message.SECTION_AUTHORITY, rrset)
self.message2 = message
self.renderer1 = MessageRenderer()
Modified: branches/trac299/src/lib/dns/rdata/generic/opt_41.cc
==============================================================================
--- branches/trac299/src/lib/dns/rdata/generic/opt_41.cc (original)
+++ branches/trac299/src/lib/dns/rdata/generic/opt_41.cc Sun Nov 7 11:01:06 2010
@@ -65,7 +65,8 @@
int
OPT::compare(const Rdata& other) const {
//const OPT& other_opt = dynamic_cast<const OPT&>(other);
- dynamic_cast<const OPT&>(other); // right now we don't need other_opt
+ // right now we don't need other_opt:
+ static_cast<void>(dynamic_cast<const OPT&>(other));
return (0);
}
Modified: branches/trac299/src/lib/dns/tests/Makefile.am
==============================================================================
--- branches/trac299/src/lib/dns/tests/Makefile.am (original)
+++ branches/trac299/src/lib/dns/tests/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,6 +1,7 @@
SUBDIRS = testdata .
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
AM_CPPFLAGS += -DTEST_DATA_SRCDIR=\"$(srcdir)/testdata\"
AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/dns/tests/testdata\"
Modified: branches/trac299/src/lib/dns/tests/edns_unittest.cc
==============================================================================
--- branches/trac299/src/lib/dns/tests/edns_unittest.cc (original)
+++ branches/trac299/src/lib/dns/tests/edns_unittest.cc Sun Nov 7 11:01:06 2010
@@ -32,7 +32,7 @@
#include <gtest/gtest.h>
-#include "unittest_util.h"
+#include <dns/tests/unittest_util.h>
using isc::UnitTestUtil;
using namespace std;
Modified: branches/trac299/src/lib/dns/tests/message_unittest.cc
==============================================================================
--- branches/trac299/src/lib/dns/tests/message_unittest.cc (original)
+++ branches/trac299/src/lib/dns/tests/message_unittest.cc Sun Nov 7 11:01:06 2010
@@ -35,6 +35,7 @@
using isc::UnitTestUtil;
using namespace std;
+using namespace isc;
using namespace isc::dns;
using namespace isc::dns::rdata;
@@ -51,24 +52,45 @@
//
const uint16_t Message::DEFAULT_MAX_UDPSIZE;
+const Name test_name("test.example.com");
namespace {
class MessageTest : public ::testing::Test {
protected:
MessageTest() : obuffer(0), renderer(obuffer),
message_parse(Message::PARSE),
- message_render(Message::RENDER)
- {}
+ message_render(Message::RENDER),
+ bogus_section(static_cast<Message::Section>(
+ Message::SECTION_ADDITIONAL + 1))
+ {
+ rrset_a = RRsetPtr(new RRset(test_name, RRClass::IN(),
+ RRType::A(), RRTTL(3600)));
+ rrset_a->addRdata(in::A("192.0.2.1"));
+ rrset_a->addRdata(in::A("192.0.2.2"));
+
+ rrset_aaaa = RRsetPtr(new RRset(test_name, RRClass::IN(),
+ RRType::AAAA(), RRTTL(3600)));
+ rrset_aaaa->addRdata(in::AAAA("2001:db8::1234"));
+
+ rrset_rrsig = RRsetPtr(new RRset(test_name, RRClass::IN(),
+ RRType::RRSIG(), RRTTL(3600)));
+ rrset_rrsig->addRdata(generic::RRSIG("AAAA 5 3 7200 20100322084538 "
+ "20100220084538 1 example.com "
+ "FAKEFAKEFAKEFAKE"));
+ rrset_aaaa->addRRsig(rrset_rrsig);
+ }
static Question factoryFromFile(const char* datafile);
OutputBuffer obuffer;
MessageRenderer renderer;
Message message_parse;
Message message_render;
+ const Message::Section bogus_section;
+ RRsetPtr rrset_a; // A RRset with two RDATAs
+ RRsetPtr rrset_aaaa; // AAAA RRset with one RDATA with RRSIG
+ RRsetPtr rrset_rrsig; // RRSIG for the AAAA RRset
static void factoryFromFile(Message& message, const char* datafile);
};
-
-const Name test_name("test.example.com");
void
MessageTest::factoryFromFile(Message& message, const char* datafile) {
@@ -77,6 +99,52 @@
InputBuffer buffer(&data[0], data.size());
message.fromWire(buffer);
+}
+
+TEST_F(MessageTest, headerFlag) {
+ // by default no flag is set
+ EXPECT_FALSE(message_render.getHeaderFlag(Message::HEADERFLAG_QR));
+ EXPECT_FALSE(message_render.getHeaderFlag(Message::HEADERFLAG_AA));
+ EXPECT_FALSE(message_render.getHeaderFlag(Message::HEADERFLAG_TC));
+ EXPECT_FALSE(message_render.getHeaderFlag(Message::HEADERFLAG_RD));
+ EXPECT_FALSE(message_render.getHeaderFlag(Message::HEADERFLAG_RA));
+ EXPECT_FALSE(message_render.getHeaderFlag(Message::HEADERFLAG_AD));
+ EXPECT_FALSE(message_render.getHeaderFlag(Message::HEADERFLAG_CD));
+
+ // set operation: by default it will be on
+ message_render.setHeaderFlag(Message::HEADERFLAG_QR);
+ EXPECT_TRUE(message_render.getHeaderFlag(Message::HEADERFLAG_QR));
+
+ // it can be set to on explicitly, too
+ message_render.setHeaderFlag(Message::HEADERFLAG_AA, true);
+ EXPECT_TRUE(message_render.getHeaderFlag(Message::HEADERFLAG_AA));
+
+ // the bit can also be cleared
+ message_render.setHeaderFlag(Message::HEADERFLAG_AA, false);
+ EXPECT_FALSE(message_render.getHeaderFlag(Message::HEADERFLAG_AA));
+
+ // Invalid flag values
+ EXPECT_THROW(message_render.setHeaderFlag(
+ static_cast<Message::HeaderFlag>(0)), InvalidParameter);
+ EXPECT_THROW(message_render.setHeaderFlag(
+ static_cast<Message::HeaderFlag>(0x7000)),
+ InvalidParameter);
+ EXPECT_THROW(message_render.setHeaderFlag(
+ static_cast<Message::HeaderFlag>(0x0800)),
+ InvalidParameter);
+ EXPECT_THROW(message_render.setHeaderFlag(
+ static_cast<Message::HeaderFlag>(0x0040)),
+ InvalidParameter);
+ EXPECT_THROW(message_render.setHeaderFlag(
+ static_cast<Message::HeaderFlag>(0x10000)),
+ InvalidParameter);
+ EXPECT_THROW(message_render.setHeaderFlag(
+ static_cast<Message::HeaderFlag>(0x80000000)),
+ InvalidParameter);
+
+ // set operation isn't allowed in the parse mode.
+ EXPECT_THROW(message_parse.setHeaderFlag(Message::HEADERFLAG_QR),
+ InvalidMessageOperation);
}
TEST_F(MessageTest, getEDNS) {
@@ -99,25 +167,126 @@
EXPECT_EQ(edns, message_render.getEDNS());
}
+TEST_F(MessageTest, getRRCount) {
+ // by default all counters should be 0
+ EXPECT_EQ(0, message_render.getRRCount(Message::SECTION_QUESTION));
+ EXPECT_EQ(0, message_render.getRRCount(Message::SECTION_ANSWER));
+ EXPECT_EQ(0, message_render.getRRCount(Message::SECTION_AUTHORITY));
+ EXPECT_EQ(0, message_render.getRRCount(Message::SECTION_ADDITIONAL));
+
+ message_render.addQuestion(Question(Name("test.example.com"),
+ RRClass::IN(), RRType::A()));
+ EXPECT_EQ(1, message_render.getRRCount(Message::SECTION_QUESTION));
+
+ // rrset_a contains two RRs
+ message_render.addRRset(Message::SECTION_ANSWER, rrset_a);
+ EXPECT_EQ(2, message_render.getRRCount(Message::SECTION_ANSWER));
+
+ // parse a message containing a Question and EDNS OPT RR.
+ // OPT shouldn't be counted as normal RR, so result of getRRCount
+ // shouldn't change.
+ factoryFromFile(message_parse, "message_fromWire11.wire");
+ EXPECT_EQ(1, message_render.getRRCount(Message::SECTION_QUESTION));
+ EXPECT_EQ(0, message_render.getRRCount(Message::SECTION_ADDITIONAL));
+
+ // out-of-band section ID
+ EXPECT_THROW(message_parse.getRRCount(bogus_section), OutOfRange);
+}
+
+TEST_F(MessageTest, addRRset) {
+ // default case
+ message_render.addRRset(Message::SECTION_ANSWER, rrset_a);
+ EXPECT_EQ(rrset_a,
+ *message_render.beginSection(Message::SECTION_ANSWER));
+ EXPECT_EQ(2, message_render.getRRCount(Message::SECTION_ANSWER));
+
+ // signed RRset, default case
+ message_render.clear(Message::RENDER);
+ message_render.addRRset(Message::SECTION_ANSWER, rrset_aaaa);
+ EXPECT_EQ(rrset_aaaa,
+ *message_render.beginSection(Message::SECTION_ANSWER));
+ EXPECT_EQ(1, message_render.getRRCount(Message::SECTION_ANSWER));
+
+ // signed RRset, add with the RRSIG. getRRCount() should return 2
+ message_render.clear(Message::RENDER);
+ message_render.addRRset(Message::SECTION_ANSWER, rrset_aaaa, true);
+ EXPECT_EQ(rrset_aaaa,
+ *message_render.beginSection(Message::SECTION_ANSWER));
+ EXPECT_EQ(2, message_render.getRRCount(Message::SECTION_ANSWER));
+
+ // signed RRset, add explicitly without RRSIG.
+ message_render.clear(Message::RENDER);
+ message_render.addRRset(Message::SECTION_ANSWER, rrset_aaaa, false);
+ EXPECT_EQ(rrset_aaaa,
+ *message_render.beginSection(Message::SECTION_ANSWER));
+ EXPECT_EQ(1, message_render.getRRCount(Message::SECTION_ANSWER));
+}
+
+TEST_F(MessageTest, badAddRRset) {
+ // addRRset() isn't allowed in the parse mode.
+ EXPECT_THROW(message_parse.addRRset(Message::SECTION_ANSWER,
+ rrset_a), InvalidMessageOperation);
+ // out-of-band section ID
+ EXPECT_THROW(message_render.addRRset(bogus_section, rrset_a), OutOfRange);
+}
+
+TEST_F(MessageTest, hasRRset) {
+ message_render.addRRset(Message::SECTION_ANSWER, rrset_a);
+ EXPECT_TRUE(message_render.hasRRset(Message::SECTION_ANSWER, test_name,
+ RRClass::IN(), RRType::A()));
+ // section doesn't match
+ EXPECT_FALSE(message_render.hasRRset(Message::SECTION_ADDITIONAL, test_name,
+ RRClass::IN(), RRType::A()));
+ // name doesn't match
+ EXPECT_FALSE(message_render.hasRRset(Message::SECTION_ANSWER,
+ Name("nomatch.example"),
+ RRClass::IN(), RRType::A()));
+ // RR class doesn't match
+ EXPECT_FALSE(message_render.hasRRset(Message::SECTION_ANSWER, test_name,
+ RRClass::CH(), RRType::A()));
+ // RR type doesn't match
+ EXPECT_FALSE(message_render.hasRRset(Message::SECTION_ANSWER, test_name,
+ RRClass::IN(), RRType::AAAA()));
+
+ // out-of-band section ID
+ EXPECT_THROW(message_render.hasRRset(bogus_section, test_name,
+ RRClass::IN(), RRType::A()),
+ OutOfRange);
+}
+
+TEST_F(MessageTest, badBeginSection) {
+ // valid cases are tested via other tests
+ EXPECT_THROW(message_render.beginSection(Message::SECTION_QUESTION),
+ InvalidMessageSection);
+ EXPECT_THROW(message_render.beginSection(bogus_section), OutOfRange);
+}
+
+TEST_F(MessageTest, badEndSection) {
+ // valid cases are tested via other tests
+ EXPECT_THROW(message_render.endSection(Message::SECTION_QUESTION),
+ InvalidMessageSection);
+ EXPECT_THROW(message_render.endSection(bogus_section), OutOfRange);
+}
+
TEST_F(MessageTest, fromWire) {
factoryFromFile(message_parse, "message_fromWire1");
EXPECT_EQ(0x1035, message_parse.getQid());
EXPECT_EQ(Opcode::QUERY(), message_parse.getOpcode());
EXPECT_EQ(Rcode::NOERROR(), message_parse.getRcode());
- EXPECT_TRUE(message_parse.getHeaderFlag(MessageFlag::QR()));
- EXPECT_TRUE(message_parse.getHeaderFlag(MessageFlag::RD()));
- EXPECT_TRUE(message_parse.getHeaderFlag(MessageFlag::AA()));
+ EXPECT_TRUE(message_parse.getHeaderFlag(Message::HEADERFLAG_QR));
+ EXPECT_TRUE(message_parse.getHeaderFlag(Message::HEADERFLAG_RD));
+ EXPECT_TRUE(message_parse.getHeaderFlag(Message::HEADERFLAG_AA));
QuestionPtr q = *message_parse.beginQuestion();
EXPECT_EQ(test_name, q->getName());
EXPECT_EQ(RRType::A(), q->getType());
EXPECT_EQ(RRClass::IN(), q->getClass());
- EXPECT_EQ(1, message_parse.getRRCount(Section::QUESTION()));
- EXPECT_EQ(2, message_parse.getRRCount(Section::ANSWER()));
- EXPECT_EQ(0, message_parse.getRRCount(Section::AUTHORITY()));
- EXPECT_EQ(0, message_parse.getRRCount(Section::ADDITIONAL()));
-
- RRsetPtr rrset = *message_parse.beginSection(Section::ANSWER());
+ EXPECT_EQ(1, message_parse.getRRCount(Message::SECTION_QUESTION));
+ EXPECT_EQ(2, message_parse.getRRCount(Message::SECTION_ANSWER));
+ EXPECT_EQ(0, message_parse.getRRCount(Message::SECTION_AUTHORITY));
+ EXPECT_EQ(0, message_parse.getRRCount(Message::SECTION_ADDITIONAL));
+
+ RRsetPtr rrset = *message_parse.beginSection(Message::SECTION_ANSWER);
EXPECT_EQ(test_name, rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
EXPECT_EQ(RRClass::IN(), rrset->getClass());
@@ -157,21 +326,17 @@
message_render.setQid(0x1035);
message_render.setOpcode(Opcode::QUERY());
message_render.setRcode(Rcode::NOERROR());
- message_render.setHeaderFlag(MessageFlag::QR());
- message_render.setHeaderFlag(MessageFlag::RD());
- message_render.setHeaderFlag(MessageFlag::AA());
+ message_render.setHeaderFlag(Message::HEADERFLAG_QR, true);
+ message_render.setHeaderFlag(Message::HEADERFLAG_RD, true);
+ message_render.setHeaderFlag(Message::HEADERFLAG_AA, true);
message_render.addQuestion(Question(Name("test.example.com"), RRClass::IN(),
RRType::A()));
- RRsetPtr rrset = RRsetPtr(new RRset(Name("test.example.com"), RRClass::IN(),
- RRType::A(), RRTTL(3600)));
- rrset->addRdata(in::A("192.0.2.1"));
- rrset->addRdata(in::A("192.0.2.2"));
- message_render.addRRset(Section::ANSWER(), rrset);
-
- EXPECT_EQ(1, message_render.getRRCount(Section::QUESTION()));
- EXPECT_EQ(2, message_render.getRRCount(Section::ANSWER()));
- EXPECT_EQ(0, message_render.getRRCount(Section::AUTHORITY()));
- EXPECT_EQ(0, message_render.getRRCount(Section::ADDITIONAL()));
+ message_render.addRRset(Message::SECTION_ANSWER, rrset_a);
+
+ EXPECT_EQ(1, message_render.getRRCount(Message::SECTION_QUESTION));
+ EXPECT_EQ(2, message_render.getRRCount(Message::SECTION_ANSWER));
+ EXPECT_EQ(0, message_render.getRRCount(Message::SECTION_AUTHORITY));
+ EXPECT_EQ(0, message_render.getRRCount(Message::SECTION_ADDITIONAL));
message_render.toWire(renderer);
vector<unsigned char> data;
Modified: branches/trac299/src/lib/dns/tests/name_unittest.cc
==============================================================================
--- branches/trac299/src/lib/dns/tests/name_unittest.cc (original)
+++ branches/trac299/src/lib/dns/tests/name_unittest.cc Sun Nov 7 11:01:06 2010
@@ -348,8 +348,8 @@
UnitTestUtil::readWireData(string("01610376697803636f6d00"), data);
Name("a.vix.com.").toWire(buffer);
- EXPECT_EQ(true, buffer.getLength() == data.size() &&
- memcmp(buffer.getData(), &data[0], data.size()) == 0);
+ EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, &data[0], data.size(),
+ buffer.getData(), buffer.getLength());
}
//
@@ -363,8 +363,8 @@
UnitTestUtil::readWireData(string("01610376697803636f6d00"), data);
Name("a.vix.com.").toWire(renderer);
- EXPECT_EQ(true, buffer.getLength() == data.size() &&
- memcmp(buffer.getData(), &data[0], data.size()) == 0);
+ EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, &data[0], data.size(),
+ buffer.getData(), buffer.getLength());
}
//
@@ -434,9 +434,9 @@
}
TEST_F(NameTest, isWildcard) {
- EXPECT_EQ(false, example_name.isWildcard());
- EXPECT_EQ(true, Name("*.a.example.com").isWildcard());
- EXPECT_EQ(false, Name("a.*.example.com").isWildcard());
+ EXPECT_FALSE(example_name.isWildcard());
+ EXPECT_TRUE(Name("*.a.example.com").isWildcard());
+ EXPECT_FALSE(Name("a.*.example.com").isWildcard());
}
TEST_F(NameTest, concatenate) {
Modified: branches/trac299/src/lib/dns/tests/rdata_ns_unittest.cc
==============================================================================
--- branches/trac299/src/lib/dns/tests/rdata_ns_unittest.cc (original)
+++ branches/trac299/src/lib/dns/tests/rdata_ns_unittest.cc Sun Nov 7 11:01:06 2010
@@ -112,7 +112,7 @@
TEST_F(Rdata_NS_Test, compare) {
generic::NS small("a.example");
generic::NS large("example");
- EXPECT_EQ(true, Name("a.example") > Name("example"));
+ EXPECT_TRUE(Name("a.example") > Name("example"));
EXPECT_GT(0, small.compare(large));
}
Modified: branches/trac299/src/lib/dns/tests/rdata_ptr_unittest.cc
==============================================================================
--- branches/trac299/src/lib/dns/tests/rdata_ptr_unittest.cc (original)
+++ branches/trac299/src/lib/dns/tests/rdata_ptr_unittest.cc Sun Nov 7 11:01:06 2010
@@ -116,7 +116,7 @@
TEST_F(Rdata_PTR_Test, compare) {
generic::PTR small("a.example");
generic::PTR large("example");
- EXPECT_EQ(true, Name("a.example") > Name("example"));
+ EXPECT_TRUE(Name("a.example") > Name("example"));
EXPECT_GT(0, small.compare(large));
}
Modified: branches/trac299/src/lib/dns/tests/rdata_unittest.cc
==============================================================================
--- branches/trac299/src/lib/dns/tests/rdata_unittest.cc (original)
+++ branches/trac299/src/lib/dns/tests/rdata_unittest.cc Sun Nov 7 11:01:06 2010
@@ -283,7 +283,7 @@
// Check the case where the order is different from the owner name
// comparison:
- EXPECT_EQ(true, small > large);
+ EXPECT_TRUE(small > large);
EXPECT_EQ(-1, compareNames(small, large));
EXPECT_EQ(1, compareNames(large, small));
Modified: branches/trac299/src/lib/python/isc/Makefile.am
==============================================================================
--- branches/trac299/src/lib/python/isc/Makefile.am (original)
+++ branches/trac299/src/lib/python/isc/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,4 +1,4 @@
-SUBDIRS = datasrc cc config log net notify utils # Util
+SUBDIRS = datasrc cc config log net notify util
python_PYTHON = __init__.py
Modified: branches/trac299/src/lib/python/isc/cc/data.py
==============================================================================
--- branches/trac299/src/lib/python/isc/cc/data.py (original)
+++ branches/trac299/src/lib/python/isc/cc/data.py Sun Nov 7 11:01:06 2010
@@ -31,10 +31,8 @@
to_remove = []
if type(a) != dict or type(b) != dict:
raise DataTypeError("Not a dict in remove_identical()")
- for ka in a.keys():
- if ka in b and a[ka] == b[ka]:
- to_remove.append(ka)
- for id in to_remove:
+ duplicate_keys = [key for key in a.keys() if key in b and a[key] == b[key]]
+ for id in duplicate_keys:
del(a[id])
def merge(orig, new):
@@ -43,17 +41,20 @@
new it will be removed in orig."""
if type(orig) != dict or type(new) != dict:
raise DataTypeError("Not a dict in merge()")
- for kn in new.keys():
- if kn in orig:
- if new[kn]:
- if type(new[kn]) == dict:
- merge(orig[kn], new[kn])
- else:
- orig[kn] = new[kn]
- else:
- del orig[kn]
- else:
- orig[kn] = new[kn]
+ orig.update(new)
+ remove_null_items(orig)
+
+def remove_null_items(d):
+ """Recursively removes all (key,value) pairs from d where the
+ value is None"""
+ null_keys = []
+ for key in d.keys():
+ if type(d[key]) == dict:
+ remove_null_items(d[key])
+ elif d[key] is None:
+ null_keys.append(key)
+ for k in null_keys:
+ del d[k]
def find(element, identifier):
"""Returns the subelement in the given data element, raises DataNotFoundError if not found"""
Modified: branches/trac299/src/lib/python/isc/cc/session.py
==============================================================================
--- branches/trac299/src/lib/python/isc/cc/session.py (original)
+++ branches/trac299/src/lib/python/isc/cc/session.py Sun Nov 7 11:01:06 2010
@@ -78,6 +78,8 @@
raise SessionError("Session has been closed.")
if type(env) == dict:
env = isc.cc.message.to_wire(env)
+ if len(env) > 65535:
+ raise ProtocolError("Envelope too large")
if type(msg) == dict:
msg = isc.cc.message.to_wire(msg)
self._socket.setblocking(1)
@@ -113,9 +115,6 @@
if (seq == None and "reply" not in env) or (seq != None and "reply" in env and seq == env["reply"]):
return env, msg
else:
- tmp = None
- if "reply" in env:
- tmp = env["reply"]
self._queue.append((env,msg))
return self.recvmsg(nonblock, seq)
else:
Modified: branches/trac299/src/lib/python/isc/cc/tests/session_test.py
==============================================================================
--- branches/trac299/src/lib/python/isc/cc/tests/session_test.py (original)
+++ branches/trac299/src/lib/python/isc/cc/tests/session_test.py Sun Nov 7 11:01:06 2010
@@ -137,6 +137,11 @@
sess.close()
self.assertRaises(SessionError, sess.sendmsg, {}, {"hello": "a"})
+ def test_env_too_large(self):
+ sess = MySession()
+ largeenv = { "a": "b"*65535 }
+ self.assertRaises(ProtocolError, sess.sendmsg, largeenv, {"hello": "a"})
+
def test_session_sendmsg(self):
sess = MySession()
sess.sendmsg({}, {"hello": "a"})
Modified: branches/trac299/src/lib/python/isc/config/ccsession.py
==============================================================================
--- branches/trac299/src/lib/python/isc/config/ccsession.py (original)
+++ branches/trac299/src/lib/python/isc/config/ccsession.py Sun Nov 7 11:01:06 2010
@@ -176,13 +176,12 @@
self._session.close()
def check_command(self, nonblock=True):
- """Check whether there is a command or configuration update
- on the channel. Call the corresponding callback function if
- there is. This function does a read on the cc session, and
- returns nothing. It will respond to any command by either
- an error or the answer message returned by the callback,
- unless the latter is None.
-
+ """Check whether there is a command or configuration update on
+ the channel. This function does a read on the cc session, and
+ returns nothing.
+ It calls check_command_without_recvmsg()
+ to parse the received message.
+
If nonblock is True, it just checks if there's a command
and does nothing if there isn't. If nonblock is False, it
waits until it arrives. It temporarily sets timeout to infinity,
@@ -193,7 +192,13 @@
msg, env = self._session.group_recvmsg(nonblock)
finally:
self._session.set_timeout(timeout_orig)
-
+ self.check_command_without_recvmsg(msg, env)
+
+ def check_command_without_recvmsg(self, msg, env):
+ """Parse the given message to see if there is a command or a
+ configuration update. Calls the corresponding handler
+ functions if present. Responds on the channel if the
+ handler returns a message."""
# should we default to an answer? success-by-default? unhandled error?
if msg is not None and not 'result' in msg:
answer = None
@@ -211,7 +216,8 @@
newc = self._remote_module_configs[module_name].get_local_config()
isc.cc.data.merge(newc, new_config)
self._remote_module_configs[module_name].set_local_config(newc)
- return
+ # For other modules, we're not supposed to answer
+ return
# ok, so apparently this update is for us.
errors = []
Modified: branches/trac299/src/lib/python/isc/config/tests/ccsession_test.py
==============================================================================
--- branches/trac299/src/lib/python/isc/config/tests/ccsession_test.py (original)
+++ branches/trac299/src/lib/python/isc/config/tests/ccsession_test.py Sun Nov 7 11:01:06 2010
@@ -370,6 +370,112 @@
self.assertEqual({'result': [0]},
fake_session.get_message('Spec2', None))
+ def test_check_command_block_timeout(self):
+ """Check it works if session has timeout and it sets it back."""
+ def cmd_check(mccs, session):
+ session.set_timeout(1)
+ mccs.check_command(False)
+ fake_session = self.common_check_command_check(
+ self.my_command_handler_ok, cmd_check)
+ self.assertEqual(len(fake_session.message_queue), 1)
+ self.assertEqual({'result': [0]},
+ fake_session.get_message('Spec2', None))
+ self.assertEqual(fake_session.get_timeout(), 1)
+
+ def test_check_command_blocks_forever(self):
+ """Check it would wait forever checking a command."""
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec2.spec", None, None, fake_session)
+ mccs.set_command_handler(self.my_command_handler_ok)
+ self.assertRaises(WouldBlockForever, lambda: mccs.check_command(False))
+
+ def test_check_command_blocks_forever_timeout(self):
+ """Like above, but it should wait forever even with timeout here."""
+ fake_session = FakeModuleCCSession()
+ fake_session.set_timeout(1)
+ mccs = self.create_session("spec2.spec", None, None, fake_session)
+ mccs.set_command_handler(self.my_command_handler_ok)
+ self.assertRaises(WouldBlockForever, lambda: mccs.check_command(False))
+
+ def test_check_command_without_recvmsg1(self):
+ "copied from test_check_command2"
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec1.spec", None, None, fake_session)
+ mccs.set_config_handler(self.my_config_handler_ok)
+ self.assertEqual(len(fake_session.message_queue), 0)
+ cmd = isc.config.ccsession.create_command(isc.config.ccsession.COMMAND_CONFIG_UPDATE, { 'Spec1': 'abcd' })
+ env = { 'group': 'Spec1', 'from':None };
+ mccs.check_command_without_recvmsg(cmd, env)
+ self.assertEqual(len(fake_session.message_queue), 1)
+ self.assertEqual({'result': [1, 'No config_data specification']},
+ fake_session.get_message('Spec1', None))
+
+ def test_check_command_without_recvmsg2(self):
+ "copied from test_check_command3"
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec2.spec", None, None, fake_session)
+ mccs.set_config_handler(self.my_config_handler_ok)
+ self.assertEqual(len(fake_session.message_queue), 0)
+ cmd = isc.config.ccsession.create_command(isc.config.ccsession.COMMAND_CONFIG_UPDATE, { 'Spec2': { 'item1': 2 }})
+ self.assertEqual(len(fake_session.message_queue), 0)
+ env = { 'group':'Spec2', 'from':None }
+ mccs.check_command_without_recvmsg(cmd, env)
+ self.assertEqual(len(fake_session.message_queue), 1)
+ self.assertEqual({'result': [0]},
+ fake_session.get_message('Spec2', None))
+
+ def test_check_command_without_recvmsg3(self):
+ "copied from test_check_command7"
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec2.spec", None, None, fake_session)
+ mccs.set_command_handler(self.my_command_handler_ok)
+ self.assertEqual(len(fake_session.message_queue), 0)
+ cmd = isc.config.ccsession.create_command("print_message", "just a message")
+ env = { 'group':'Spec2', 'from':None }
+ self.assertEqual(len(fake_session.message_queue), 0)
+ mccs.check_command_without_recvmsg(cmd, env)
+ self.assertEqual({'result': [0]},
+ fake_session.get_message('Spec2', None))
+
+ def test_check_command_without_recvmsg_remote_module(self):
+ "copied from test_check_command3"
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec1.spec", None, None, fake_session)
+ mccs.set_config_handler(self.my_config_handler_ok)
+ self.assertEqual(len(fake_session.message_queue), 0)
+
+ fake_session.group_sendmsg(None, 'Spec2')
+ rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
+ print(fake_session.message_queue)
+ self.assertEqual({'command': ['get_config', {'module_name': 'Spec2'}]},
+ fake_session.get_message('ConfigManager', None))
+ self.assertEqual(len(fake_session.message_queue), 0)
+
+ cmd = isc.config.ccsession.create_command(isc.config.ccsession.COMMAND_CONFIG_UPDATE, { 'Spec2': { 'item1': 2 }})
+ env = { 'group':'Spec2', 'from':None }
+ self.assertEqual(len(fake_session.message_queue), 0)
+ mccs.check_command_without_recvmsg(cmd, env)
+ self.assertEqual(len(fake_session.message_queue), 0)
+
+ def test_check_command_without_recvmsg_remote_module2(self):
+ "copied from test_check_command3"
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec1.spec", None, None, fake_session)
+ mccs.set_config_handler(self.my_config_handler_ok)
+ self.assertEqual(len(fake_session.message_queue), 0)
+
+ fake_session.group_sendmsg(None, 'Spec2')
+ rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
+ self.assertEqual({'command': ['get_config', {'module_name': 'Spec2'}]},
+ fake_session.get_message('ConfigManager', None))
+ self.assertEqual(len(fake_session.message_queue), 0)
+
+ cmd = isc.config.ccsession.create_command(isc.config.ccsession.COMMAND_CONFIG_UPDATE, { 'Spec3': { 'item1': 2 }})
+ env = { 'group':'Spec3', 'from':None }
+ self.assertEqual(len(fake_session.message_queue), 0)
+ mccs.check_command_without_recvmsg(cmd, env)
+ self.assertEqual(len(fake_session.message_queue), 0)
+
def test_check_command_block_timeout(self):
"""Check it works if session has timeout and it sets it back."""
def cmd_check(mccs, session):
Modified: branches/trac299/src/lib/python/isc/datasrc/master.py
==============================================================================
--- branches/trac299/src/lib/python/isc/datasrc/master.py (original)
+++ branches/trac299/src/lib/python/isc/datasrc/master.py Sun Nov 7 11:01:06 2010
@@ -269,7 +269,7 @@
if second[-1] == '.':
self.__origin = second
elif not self.__origin:
- raise MasterFileError("$ORIGIN is not absolute in record:%s" % s)
+ raise MasterFileError("$ORIGIN is not absolute in record: %s" % s)
elif self.__origin != '.':
self.__origin = second + '.' + self.__origin
else:
Modified: branches/trac299/src/lib/python/isc/notify/notify_out.py
==============================================================================
--- branches/trac299/src/lib/python/isc/notify/notify_out.py (original)
+++ branches/trac299/src/lib/python/isc/notify/notify_out.py Sun Nov 7 11:01:06 2010
@@ -402,13 +402,13 @@
msg.set_qid(qid)
msg.set_opcode(Opcode.NOTIFY())
msg.set_rcode(Rcode.NOERROR())
- msg.set_header_flag(MessageFlag.AA())
+ msg.set_header_flag(Message.HEADERFLAG_AA)
question = Question(Name(zone_name), RRClass(zone_class), RRType('SOA'))
msg.add_question(question)
# Add soa record to answer section
soa_record = sqlite3_ds.get_zone_rrset(zone_name, zone_name, 'SOA', self._db_file)
rrset_soa = self._create_rrset_from_db_record(soa_record[0], zone_class)
- msg.add_rrset(Section.ANSWER(), rrset_soa)
+ msg.add_rrset(Message.SECTION_ANSWER, rrset_soa)
return msg, qid
def _handle_notify_reply(self, zone_notify_info, msg_data):
@@ -420,7 +420,7 @@
try:
errstr = 'notify reply error: '
msg.from_wire(msg_data)
- if not msg.get_header_flag(MessageFlag.QR()):
+ if not msg.get_header_flag(Message.HEADERFLAG_QR):
self._log_msg('error', errstr + 'bad flags')
return _BAD_QR
Modified: branches/trac299/src/lib/xfr/Makefile.am
==============================================================================
--- branches/trac299/src/lib/xfr/Makefile.am (original)
+++ branches/trac299/src/lib/xfr/Makefile.am Sun Nov 7 11:01:06 2010
@@ -1,8 +1,12 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
+AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS) -Wno-strict-aliasing
AM_CXXFLAGS += -Wno-unused-parameter # see src/lib/cc/Makefile.am
+if USE_CLANGPP
+AM_CXXFLAGS += -Wno-error
+endif
CLEANFILES = *.gcno *.gcda
More information about the bind10-changes
mailing list