BIND 10 trac2155_2, updated. 3f6ddec37ff9bb49440ce6ceaf02842c74d0b865 [2155] added some notes to the mapping tables of counter item
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Oct 12 07:19:10 UTC 2012
The branch, trac2155_2 has been updated
via 3f6ddec37ff9bb49440ce6ceaf02842c74d0b865 (commit)
via c638fb4e2776b24b7ecf3c071086056d5cc9d78f (commit)
via 43f01176f71c387638ff876b7ce31dd42f6bdb9d (commit)
via 124780d941405d05a2a2906160a3c479a8417abc (commit)
via 67a6dccbdd9fe5b08b80224fd395fab676cb704c (commit)
via fb4eb0b2229e58f19526247193c427fe7af8b9b2 (commit)
via c522619b6b3555c5fa0fc8367b6ebc4e72e9335d (commit)
via 35eb49f72a3dceb354e300469d0c4f342ddb3c8a (commit)
from a8a40b6805377c49a9671bd93cb510bfef946a87 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3f6ddec37ff9bb49440ce6ceaf02842c74d0b865
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Fri Oct 12 16:17:20 2012 +0900
[2155] added some notes to the mapping tables of counter item
commit c638fb4e2776b24b7ecf3c071086056d5cc9d78f
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Fri Oct 12 14:21:15 2012 +0900
[2155] update test case according to the review comment
commit 43f01176f71c387638ff876b7ce31dd42f6bdb9d
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Wed Oct 10 19:34:26 2012 +0900
[2155] fixed wrong comment
commit 124780d941405d05a2a2906160a3c479a8417abc
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Wed Oct 10 19:32:37 2012 +0900
[2155] inline methods in a canonical way
commit 67a6dccbdd9fe5b08b80224fd395fab676cb704c
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Wed Oct 10 19:09:58 2012 +0900
[2155] use auto-generated copy constructor
commit fb4eb0b2229e58f19526247193c427fe7af8b9b2
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Wed Oct 10 18:40:50 2012 +0900
[2155] checkCountersAllZeroExcept() returns void
commit c522619b6b3555c5fa0fc8367b6ebc4e72e9335d
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Wed Oct 10 17:06:15 2012 +0900
[2155] remove meaningless NULL check
commit 35eb49f72a3dceb354e300469d0c4f342ddb3c8a
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Wed Oct 10 16:31:15 2012 +0900
[2155] added notes for including header files with EXTRA_DIST
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/statistics.cc | 35 +-
src/bin/auth/statistics.h | 146 +++----
src/bin/auth/statistics_items.h | 594 ++++++++++++++---------------
src/bin/auth/tests/auth_srv_unittest.cc | 26 +-
src/bin/auth/tests/statistics_unittest.cc | 6 +-
src/lib/statistics/Makefile.am | 4 +-
src/lib/statistics/counter.h | 52 +--
src/lib/statistics/counter_dict.h | 144 +++----
8 files changed, 461 insertions(+), 546 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/statistics.cc b/src/bin/auth/statistics.cc
index a179a77..b310b23 100644
--- a/src/bin/auth/statistics.cc
+++ b/src/bin/auth/statistics.cc
@@ -121,24 +121,21 @@ CountersImpl::inc(const QRAttributes& qrattrs, const Message& response) {
unsigned int qtype_type = QR_QTYPE_OTHER;
const QuestionIterator qiter = response.beginQuestion();
if (qiter != response.endQuestion()) {
- // get the first and only question section
- const QuestionPtr qptr = *qiter;
- if (qptr != NULL) {
- // get the qtype code
- const unsigned int qtype = qptr->getType().getCode();
- if (qtype < 258) {
- // qtype 0..257
- qtype_type = QRQTypeToQRCounterType[qtype];
- } else if (qtype < 32768) {
- // qtype 258..32767
- qtype_type = QR_QTYPE_OTHER;
- } else if (qtype < 32770) {
- // qtype 32768..32769
- qtype_type = QR_QTYPE_TA + (qtype - 32768);
- } else {
- // qtype 32770..65535
- qtype_type = QR_QTYPE_OTHER;
- }
+ // get the first and only question section and
+ // get the qtype code
+ const unsigned int qtype = (*qiter)->getType().getCode();
+ if (qtype < 258) {
+ // qtype 0..257: lookup qtype-countertype table
+ qtype_type = QRQTypeToQRCounterType[qtype];
+ } else if (qtype < 32768) {
+ // qtype 258..32767: (Unassigned)
+ qtype_type = QR_QTYPE_OTHER;
+ } else if (qtype < 32770) {
+ // qtype 32768..32769: TA and DLV
+ qtype_type = QR_QTYPE_TA + (qtype - 32768);
+ } else {
+ // qtype 32770..65535: (Unassigned, Private use, Reserved)
+ qtype_type = QR_QTYPE_OTHER;
}
}
server_qr_counter_.inc(qtype_type);
@@ -173,7 +170,7 @@ CountersImpl::inc(const QRAttributes& qrattrs, const Message& response) {
const unsigned int rcode = response.getRcode().getCode();
unsigned int rcode_type = QR_RCODE_OTHER;
if (rcode < 23) {
- // rcode 0..22
+ // rcode 0..22: lookup rcode-countertype table
rcode_type = QRRCodeToQRCounterType[rcode];
} else {
// opcode larger than 22 is reserved or unassigned
diff --git a/src/bin/auth/statistics.h b/src/bin/auth/statistics.h
index f3efa7d..34d5f61 100644
--- a/src/bin/auth/statistics.h
+++ b/src/bin/auth/statistics.h
@@ -62,120 +62,90 @@ public:
/// This constructor is mostly exception free. But it may still throw
/// a standard exception if memory allocation fails inside the method.
///
- inline QRAttributes();
+ inline QRAttributes() :
+ req_ip_version_(0), req_transport_protocol_(0),
+ req_opcode_(0),
+ req_is_edns_0_(false), req_is_edns_badver_(false),
+ req_is_dnssec_ok_(false),
+ req_is_tsig_(false), req_is_sig0_(false), req_is_badsig_(false),
+ zone_origin_(),
+ answer_sent_(false),
+ res_is_truncated_(false)
+ {};
+
/// The destructor.
///
/// This method never throws an exception.
///
- inline ~QRAttributes();
+ inline ~QRAttributes() {};
/// \brief Set query opcode.
/// \throw None
- inline void setQueryOpCode(const int opcode);
+ inline void setQueryOpCode(const int opcode) {
+ req_opcode_ = opcode;
+ };
/// \brief Set IP version carrying a query.
/// \throw None
- inline void setQueryIPVersion(const int ip_version);
+ inline void setQueryIPVersion(const int ip_version) {
+ req_ip_version_ = ip_version;
+ };
/// \brief Set transport protocol carrying a query.
/// \throw None
- inline void setQueryTransportProtocol(const int transport_protocol);
+ inline void setQueryTransportProtocol(const int transport_protocol) {
+ req_transport_protocol_ = transport_protocol;
+ };
/// \brief Set query EDNS attributes.
/// \throw None
- inline void setQueryEDNS(const bool is_edns_0, const bool is_edns_badver);
+ inline void setQueryEDNS(const bool is_edns_0, const bool is_edns_badver) {
+ req_is_edns_0_ = is_edns_0;
+ req_is_edns_badver_ = is_edns_badver;
+ };
/// \brief Set query DO bit.
/// \throw None
- inline void setQueryDO(const bool is_dnssec_ok);
+ inline void setQueryDO(const bool is_dnssec_ok) {
+ req_is_dnssec_ok_ = is_dnssec_ok;
+ };
/// \brief Set query TSIG attributes.
/// \throw None
inline void setQuerySig(const bool is_tsig, const bool is_sig0,
- const bool is_badsig);
+ const bool is_badsig)
+ {
+ req_is_tsig_ = is_tsig;
+ req_is_sig0_ = is_sig0;
+ req_is_badsig_ = is_badsig;
+ };
/// \brief Set zone origin.
/// \throw None
- inline void setOrigin(const std::string& origin);
- /// \brief Set if the answer has sent.
+ inline void setOrigin(const std::string& origin) {
+ zone_origin_ = origin;
+ };
+ /// \brief Set if the answer was sent.
/// \throw None
- inline void answerWasSent();
+ inline void answerWasSent() {
+ answer_sent_ = true;
+ };
/// \brief Set if the response is truncated.
/// \throw None
- inline void setResponseTruncated(const bool is_truncated);
+ inline void setResponseTruncated(const bool is_truncated) {
+ res_is_truncated_ = is_truncated;
+ };
/// \brief Reset attributes.
/// \throw None
- inline void reset();
+ inline void reset() {
+ req_ip_version_ = 0;
+ req_transport_protocol_ = 0;
+ req_opcode_ = 0;
+ req_is_edns_0_ = false;
+ req_is_edns_badver_ = false;
+ req_is_dnssec_ok_ = false;
+ req_is_tsig_ = false;
+ req_is_sig0_ = false;
+ req_is_badsig_ = false;
+ zone_origin_.clear();
+ answer_sent_ = false;
+ res_is_truncated_ = false;
+ };
};
-inline QRAttributes::QRAttributes() :
- req_ip_version_(0), req_transport_protocol_(0),
- req_opcode_(0),
- req_is_edns_0_(false), req_is_edns_badver_(false),
- req_is_dnssec_ok_(false),
- req_is_tsig_(false), req_is_sig0_(false), req_is_badsig_(false),
- zone_origin_(),
- answer_sent_(false),
- res_is_truncated_(false)
-{}
-
-inline QRAttributes::~QRAttributes()
-{}
-
-inline void
-QRAttributes::setQueryIPVersion(const int ip_version) {
- req_ip_version_ = ip_version;
-}
-
-inline void
-QRAttributes::setQueryTransportProtocol(const int transport_protocol) {
- req_transport_protocol_ = transport_protocol;
-}
-
-inline void
-QRAttributes::setQueryOpCode(const int opcode) {
- req_opcode_ = opcode;
-}
-
-inline void
-QRAttributes::setQueryEDNS(const bool is_edns_0, const bool is_edns_badver) {
- req_is_edns_0_ = is_edns_0;
- req_is_edns_badver_ = is_edns_badver;
-}
-
-inline void
-QRAttributes::setQueryDO(const bool is_dnssec_ok) {
- req_is_dnssec_ok_ = is_dnssec_ok;
-}
-
-inline void
-QRAttributes::setQuerySig(const bool is_tsig, const bool is_sig0,
- const bool is_badsig)
-{
- req_is_tsig_ = is_tsig;
- req_is_sig0_ = is_sig0;
- req_is_badsig_ = is_badsig;
-}
-
-inline void
-QRAttributes::answerWasSent() {
- answer_sent_ = true;
-}
-
-inline void
-QRAttributes::setResponseTruncated(const bool is_truncated) {
- res_is_truncated_ = is_truncated;
-}
-
-inline void
-QRAttributes::reset() {
- req_ip_version_ = 0;
- req_transport_protocol_ = 0;
- req_opcode_ = 0;
- req_is_edns_0_ = false;
- req_is_edns_badver_ = false;
- req_is_dnssec_ok_ = false;
- req_is_tsig_ = false;
- req_is_sig0_ = false;
- req_is_badsig_ = false;
- zone_origin_.clear();
- answer_sent_ = false;
- res_is_truncated_ = false;
-}
-
/// \brief Set of query counters.
///
/// \c Counters is set of query counters class. It holds query counters
diff --git a/src/bin/auth/statistics_items.h b/src/bin/auth/statistics_items.h
index eb5d249..5839206 100644
--- a/src/bin/auth/statistics_items.h
+++ b/src/bin/auth/statistics_items.h
@@ -297,307 +297,307 @@ const struct CounterTypeTree QRCounterTree[] = {
};
const int QROpCodeToQRCounterType[16] = {
- QR_OPCODE_QUERY,
- QR_OPCODE_IQUERY,
- QR_OPCODE_STATUS,
- QR_OPCODE_OTHER,
- QR_OPCODE_NOTIFY,
- QR_OPCODE_UPDATE,
- QR_OPCODE_OTHER,
- QR_OPCODE_OTHER,
- QR_OPCODE_OTHER,
- QR_OPCODE_OTHER,
- QR_OPCODE_OTHER,
- QR_OPCODE_OTHER,
- QR_OPCODE_OTHER,
- QR_OPCODE_OTHER,
- QR_OPCODE_OTHER,
- QR_OPCODE_OTHER
+ QR_OPCODE_QUERY, // Opcode = 0: Query
+ QR_OPCODE_IQUERY, // Opcode = 1: Iquery
+ QR_OPCODE_STATUS, // Opcode = 2: STATUS
+ QR_OPCODE_OTHER, // Opcode = 3: (Unassigned)
+ QR_OPCODE_NOTIFY, // Opcode = 4: Notify
+ QR_OPCODE_UPDATE, // Opcode = 5: Update
+ QR_OPCODE_OTHER, // Opcode = 6: (Unassigned)
+ QR_OPCODE_OTHER, // Opcode = 7: (Unassigned)
+ QR_OPCODE_OTHER, // Opcode = 8: (Unassigned)
+ QR_OPCODE_OTHER, // Opcode = 9: (Unassigned)
+ QR_OPCODE_OTHER, // Opcode = 10: (Unassigned)
+ QR_OPCODE_OTHER, // Opcode = 11: (Unassigned)
+ QR_OPCODE_OTHER, // Opcode = 12: (Unassigned)
+ QR_OPCODE_OTHER, // Opcode = 13: (Unassigned)
+ QR_OPCODE_OTHER, // Opcode = 14: (Unassigned)
+ QR_OPCODE_OTHER // Opcode = 15: (Unassigned)
};
const int QRQTypeToQRCounterType[258] = {
- QR_QTYPE_OTHER,
- QR_QTYPE_A,
- QR_QTYPE_NS,
- QR_QTYPE_MD,
- QR_QTYPE_MF,
- QR_QTYPE_CNAME,
- QR_QTYPE_SOA,
- QR_QTYPE_MB,
- QR_QTYPE_MG,
- QR_QTYPE_MR,
- QR_QTYPE_NULL,
- QR_QTYPE_WKS,
- QR_QTYPE_PTR,
- QR_QTYPE_HINFO,
- QR_QTYPE_MINFO,
- QR_QTYPE_MX,
- QR_QTYPE_TXT,
- QR_QTYPE_RP,
- QR_QTYPE_AFSDB,
- QR_QTYPE_X25,
- QR_QTYPE_ISDN,
- QR_QTYPE_RT,
- QR_QTYPE_NSAP,
- QR_QTYPE_NSAP_PTR,
- QR_QTYPE_SIG,
- QR_QTYPE_KEY,
- QR_QTYPE_PX,
- QR_QTYPE_GPOS,
- QR_QTYPE_AAAA,
- QR_QTYPE_LOC,
- QR_QTYPE_NXT,
- QR_QTYPE_EID,
- QR_QTYPE_NIMLOC,
- QR_QTYPE_SRV,
- QR_QTYPE_ATMA,
- QR_QTYPE_NAPTR,
- QR_QTYPE_KX,
- QR_QTYPE_CERT,
- QR_QTYPE_A6,
- QR_QTYPE_DNAME,
- QR_QTYPE_SINK,
- QR_QTYPE_OPT,
- QR_QTYPE_APL,
- QR_QTYPE_DS,
- QR_QTYPE_SSHFP,
- QR_QTYPE_IPSECKEY,
- QR_QTYPE_RRSIG,
- QR_QTYPE_NSEC,
- QR_QTYPE_DNSKEY,
- QR_QTYPE_DHCID,
- QR_QTYPE_NSEC3,
- QR_QTYPE_NSEC3PARAM,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_HIP,
- QR_QTYPE_NINFO,
- QR_QTYPE_RKEY,
- QR_QTYPE_TALINK,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_SPF,
- QR_QTYPE_UINFO,
- QR_QTYPE_UID,
- QR_QTYPE_GID,
- QR_QTYPE_UNSPEC,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_OTHER,
- QR_QTYPE_TKEY,
- QR_QTYPE_TSIG,
- QR_QTYPE_IXFR,
- QR_QTYPE_AXFR,
- QR_QTYPE_MAILB,
- QR_QTYPE_MAILA,
- QR_QTYPE_OTHER,
- QR_QTYPE_URI,
- QR_QTYPE_CAA
+ QR_QTYPE_OTHER, // RRtype = 0: special use
+ QR_QTYPE_A, // RRtype = 1: A
+ QR_QTYPE_NS, // RRtype = 2: NS
+ QR_QTYPE_MD, // RRtype = 3: MD
+ QR_QTYPE_MF, // RRtype = 4: MF
+ QR_QTYPE_CNAME, // RRtype = 5: CNAME
+ QR_QTYPE_SOA, // RRtype = 6: SOA
+ QR_QTYPE_MB, // RRtype = 7: MB
+ QR_QTYPE_MG, // RRtype = 8: MG
+ QR_QTYPE_MR, // RRtype = 9: MR
+ QR_QTYPE_NULL, // RRtype = 10: NULL
+ QR_QTYPE_WKS, // RRtype = 11: WKS
+ QR_QTYPE_PTR, // RRtype = 12: PTR
+ QR_QTYPE_HINFO, // RRtype = 13: HINFO
+ QR_QTYPE_MINFO, // RRtype = 14: MINFO
+ QR_QTYPE_MX, // RRtype = 15: MX
+ QR_QTYPE_TXT, // RRtype = 16: TXT
+ QR_QTYPE_RP, // RRtype = 17: RP
+ QR_QTYPE_AFSDB, // RRtype = 18: AFSDB
+ QR_QTYPE_X25, // RRtype = 19: X25
+ QR_QTYPE_ISDN, // RRtype = 20: ISDN
+ QR_QTYPE_RT, // RRtype = 21: RT
+ QR_QTYPE_NSAP, // RRtype = 22: NSAP
+ QR_QTYPE_NSAP_PTR, // RRtype = 23: NSAP-PTR
+ QR_QTYPE_SIG, // RRtype = 24: SIG
+ QR_QTYPE_KEY, // RRtype = 25: KEY
+ QR_QTYPE_PX, // RRtype = 26: PX
+ QR_QTYPE_GPOS, // RRtype = 27: GPOS
+ QR_QTYPE_AAAA, // RRtype = 28: AAAA
+ QR_QTYPE_LOC, // RRtype = 29: LOC
+ QR_QTYPE_NXT, // RRtype = 30: NXT
+ QR_QTYPE_EID, // RRtype = 31: EID
+ QR_QTYPE_NIMLOC, // RRtype = 32: NIMLOC
+ QR_QTYPE_SRV, // RRtype = 33: SRV
+ QR_QTYPE_ATMA, // RRtype = 34: ATMA
+ QR_QTYPE_NAPTR, // RRtype = 35: NAPTR
+ QR_QTYPE_KX, // RRtype = 36: KX
+ QR_QTYPE_CERT, // RRtype = 37: CERT
+ QR_QTYPE_A6, // RRtype = 38: A6
+ QR_QTYPE_DNAME, // RRtype = 39: DNAME
+ QR_QTYPE_SINK, // RRtype = 40: SINK
+ QR_QTYPE_OPT, // RRtype = 41: OPT
+ QR_QTYPE_APL, // RRtype = 42: APL
+ QR_QTYPE_DS, // RRtype = 43: DS
+ QR_QTYPE_SSHFP, // RRtype = 44: SSHFP
+ QR_QTYPE_IPSECKEY, // RRtype = 45: IPSECKEY
+ QR_QTYPE_RRSIG, // RRtype = 46: RRSIG
+ QR_QTYPE_NSEC, // RRtype = 47: NSEC
+ QR_QTYPE_DNSKEY, // RRtype = 48: DNSKEY
+ QR_QTYPE_DHCID, // RRtype = 49: DHCID
+ QR_QTYPE_NSEC3, // RRtype = 50: NSEC3
+ QR_QTYPE_NSEC3PARAM, // RRtype = 51: NSEC3PARAM
+ QR_QTYPE_OTHER, // RRtype = 52: TLSA
+ QR_QTYPE_OTHER, // RRtype = 53: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 54: (Unassigned)
+ QR_QTYPE_HIP, // RRtype = 55: HIP
+ QR_QTYPE_NINFO, // RRtype = 56: NINFO
+ QR_QTYPE_RKEY, // RRtype = 57: RKEY
+ QR_QTYPE_TALINK, // RRtype = 58: TALINK
+ QR_QTYPE_OTHER, // RRtype = 59: CDS
+ QR_QTYPE_OTHER, // RRtype = 60: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 61: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 62: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 63: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 64: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 65: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 66: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 67: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 68: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 69: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 70: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 71: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 72: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 73: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 74: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 75: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 76: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 77: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 78: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 79: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 80: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 81: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 82: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 83: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 84: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 85: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 86: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 87: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 88: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 89: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 90: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 91: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 92: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 93: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 94: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 95: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 96: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 97: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 98: (Unassigned)
+ QR_QTYPE_SPF, // RRtype = 99: SPF
+ QR_QTYPE_UINFO, // RRtype = 100: UINFO
+ QR_QTYPE_UID, // RRtype = 101: UID
+ QR_QTYPE_GID, // RRtype = 102: GID
+ QR_QTYPE_UNSPEC, // RRtype = 103: UNSPEC
+ QR_QTYPE_OTHER, // RRtype = 104: NID
+ QR_QTYPE_OTHER, // RRtype = 105: L32
+ QR_QTYPE_OTHER, // RRtype = 106: L64
+ QR_QTYPE_OTHER, // RRtype = 107: LP
+ QR_QTYPE_OTHER, // RRtype = 108: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 109: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 110: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 111: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 112: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 113: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 114: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 115: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 116: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 117: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 118: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 119: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 120: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 121: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 122: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 123: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 124: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 125: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 126: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 127: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 128: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 129: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 130: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 131: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 132: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 133: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 134: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 135: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 136: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 137: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 138: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 139: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 140: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 141: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 142: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 143: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 144: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 145: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 146: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 147: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 148: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 149: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 150: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 151: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 152: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 153: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 154: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 155: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 156: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 157: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 158: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 159: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 160: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 161: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 162: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 163: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 164: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 165: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 166: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 167: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 168: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 169: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 170: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 171: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 172: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 173: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 174: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 175: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 176: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 177: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 178: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 179: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 180: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 181: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 182: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 183: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 184: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 185: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 186: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 187: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 188: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 189: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 190: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 191: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 192: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 193: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 194: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 195: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 196: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 197: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 198: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 199: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 200: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 201: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 202: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 203: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 204: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 205: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 206: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 207: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 208: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 209: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 210: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 211: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 212: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 213: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 214: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 215: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 216: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 217: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 218: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 219: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 220: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 221: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 222: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 223: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 224: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 225: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 226: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 227: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 228: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 229: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 230: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 231: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 232: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 233: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 234: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 235: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 236: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 237: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 238: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 239: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 240: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 241: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 242: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 243: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 244: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 245: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 246: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 247: (Unassigned)
+ QR_QTYPE_OTHER, // RRtype = 248: (Unassigned)
+ QR_QTYPE_TKEY, // RRtype = 249: TKEY
+ QR_QTYPE_TSIG, // RRtype = 250: TSIG
+ QR_QTYPE_IXFR, // RRtype = 251: IXFR
+ QR_QTYPE_AXFR, // RRtype = 252: AXFR
+ QR_QTYPE_MAILB, // RRtype = 253: MAILB
+ QR_QTYPE_MAILA, // RRtype = 254: MAILA
+ QR_QTYPE_OTHER, // RRtype = 255: for All records
+ QR_QTYPE_URI, // RRtype = 256: URI
+ QR_QTYPE_CAA // RRtype = 257: CAA
};
const int QRRCodeToQRCounterType[23] = {
- QR_RCODE_NOERROR,
- QR_RCODE_FORMERR,
- QR_RCODE_SERVFAIL,
- QR_RCODE_NXDOMAIN,
- QR_RCODE_NOTIMP,
- QR_RCODE_REFUSED,
- QR_RCODE_YXDOMAIN,
- QR_RCODE_YXRRSET,
- QR_RCODE_NXRRSET,
- QR_RCODE_NOTAUTH,
- QR_RCODE_NOTZONE,
- QR_RCODE_OTHER,
- QR_RCODE_OTHER,
- QR_RCODE_OTHER,
- QR_RCODE_OTHER,
- QR_RCODE_OTHER,
- QR_RCODE_BADSIGVERS,
- QR_RCODE_BADKEY,
- QR_RCODE_BADTIME,
- QR_RCODE_BADMODE,
- QR_RCODE_BADNAME,
- QR_RCODE_BADALG,
- QR_RCODE_BADTRUNC
+ QR_RCODE_NOERROR, // Rcode = 0: NoError
+ QR_RCODE_FORMERR, // Rcode = 1: FormErr
+ QR_RCODE_SERVFAIL, // Rcode = 2: ServFail
+ QR_RCODE_NXDOMAIN, // Rcode = 3: NXDomain
+ QR_RCODE_NOTIMP, // Rcode = 4: NotImp
+ QR_RCODE_REFUSED, // Rcode = 5: Refused
+ QR_RCODE_YXDOMAIN, // Rcode = 6: YXDomain
+ QR_RCODE_YXRRSET, // Rcode = 7: YXRRSet
+ QR_RCODE_NXRRSET, // Rcode = 8: NXRRSet
+ QR_RCODE_NOTAUTH, // Rcode = 9: NotAuth
+ QR_RCODE_NOTZONE, // Rcode = 10: NotZone
+ QR_RCODE_OTHER, // Rcode = 11: (Unassigned)
+ QR_RCODE_OTHER, // Rcode = 12: (Unassigned)
+ QR_RCODE_OTHER, // Rcode = 13: (Unassigned)
+ QR_RCODE_OTHER, // Rcode = 14: (Unassigned)
+ QR_RCODE_OTHER, // Rcode = 15: (Unassigned)
+ QR_RCODE_BADSIGVERS, // Rcode = 16: BADVERS, BADSIG
+ QR_RCODE_BADKEY, // Rcode = 17: BADKEY
+ QR_RCODE_BADTIME, // Rcode = 18: BADTIME
+ QR_RCODE_BADMODE, // Rcode = 19: BADMODE
+ QR_RCODE_BADNAME, // Rcode = 20: BADNAME
+ QR_RCODE_BADALG, // Rcode = 21: BADALG
+ QR_RCODE_BADTRUNC // Rcode = 22: BADTRUNC
};
} // anonymous namespace
diff --git a/src/bin/auth/tests/auth_srv_unittest.cc b/src/bin/auth/tests/auth_srv_unittest.cc
index 4b673fb..2d5e688 100644
--- a/src/bin/auth/tests/auth_srv_unittest.cc
+++ b/src/bin/auth/tests/auth_srv_unittest.cc
@@ -131,19 +131,8 @@ protected:
// Checks whether all Rcode counters are set to zero
void checkAllRcodeCountersZero() const {
- const std::map<std::string, ConstElementPtr>
- stats_map(server.getStatistics()->mapValue());
-
- const std::string rcode_prefix("rcode.");
- for (std::map<std::string, ConstElementPtr>::const_iterator
- i = stats_map.begin(), e = stats_map.end();
- i != e;
- ++i)
- {
- if (i->first.compare(0, rcode_prefix.size(), rcode_prefix) == 0) {
- checkRcodeCounter(i->first, i->second->intValue(), 0);
- }
- }
+ // with checking NOERROR == 0 and the others are 0
+ checkAllRcodeCountersZeroExcept(Rcode::NOERROR(), 0);
}
// Checks whether all Rcode counters are set to zero except the given
@@ -248,15 +237,24 @@ createBuiltinVersionResponse(const qid_t qid, vector<uint8_t>& data) {
renderer.getLength());
}
+// Check if the item has expected value.
+// Before reading the item, check the item exists.
void
expectCounterItem(ConstElementPtr stats,
const std::string& item, const int expected) {
ConstElementPtr value(Element::create(0));
if (item == "queries.udp" || item == "queries.tcp" || expected != 0) {
+ // if the value of the item is not zero, the item exists and has
+ // expected value
+ // item "queries.udp" and "queries.tcp" exists whether the value
+ // is zero or nonzero
ASSERT_TRUE(stats->find(item, value)) << " Item: " << item;
+ // Get the value of the item with another method because of API bug
+ // (ticket #2302)
value = stats->find(item);
EXPECT_EQ(expected, value->intValue()) << " Item: " << item;
} else {
+ // otherwise the item does not exist
ASSERT_FALSE(stats->find(item, value)) << " Item: " << item <<
std::endl << " Value: " << value->intValue();
}
@@ -1089,7 +1087,7 @@ TEST_F(AuthSrvTest, queryCounterUDPNormal) {
server.processMessage(*io_message, *parse_message, *response_obuffer,
&dnsserv);
// After processing the UDP query, these counters should be incremented:
- // request.tcp, opcode.query, qtype.ns, rcode.refused, response
+ // request.udp, opcode.query, qtype.ns, rcode.refused, response
// and these counters should not be incremented:
// request.tcp
ConstElementPtr stats_after = server.getStatistics();
diff --git a/src/bin/auth/tests/statistics_unittest.cc b/src/bin/auth/tests/statistics_unittest.cc
index ec6ad84..052a70e 100644
--- a/src/bin/auth/tests/statistics_unittest.cc
+++ b/src/bin/auth/tests/statistics_unittest.cc
@@ -53,7 +53,9 @@ protected:
Counters counters;
};
-bool
+// Test if the values of the counters are all zero except for the items
+// specified in except_for.
+void
checkCountersAllZeroExcept(const isc::data::ConstElementPtr counters,
const std::set<std::string>& except_for) {
std::map<std::string, ConstElementPtr> stats_map = counters->mapValue();
@@ -71,8 +73,6 @@ checkCountersAllZeroExcept(const isc::data::ConstElementPtr counters,
<< i->first << " = " << expect << ", actual: "
<< i->second->intValue();
}
-
- return false;
}
TEST_F(CountersTest, incrementNormalQuery) {
diff --git a/src/lib/statistics/Makefile.am b/src/lib/statistics/Makefile.am
index 478f1c1..a395bf5 100644
--- a/src/lib/statistics/Makefile.am
+++ b/src/lib/statistics/Makefile.am
@@ -19,5 +19,7 @@ endif
CLEANFILES = *.gcno *.gcda
-# These header files should be in the distribution.
+# These are header-only shared classes and required to build BIND 10.
+# Include them in the distributed tarball with EXTRA_DIST (like as
+# external sources in ext/).
EXTRA_DIST = counter.h counter_dict.h
diff --git a/src/lib/statistics/counter.h b/src/lib/statistics/counter.h
index ed5c276..af9a5f7 100644
--- a/src/lib/statistics/counter.h
+++ b/src/lib/statistics/counter.h
@@ -46,55 +46,45 @@ public:
/// \param items A number of counter items to hold (greater than 0)
///
/// \throw isc::InvalidParameter \a items is 0
- explicit inline Counter(const size_t items);
+ explicit inline Counter(const size_t items) :
+ counters_(items, InitialValue)
+ {
+ if (items == 0) {
+ isc_throw(isc::InvalidParameter, "Items must not be 0");
+ }
+ };
/// The destructor.
///
/// This method never throws an exception.
- inline ~Counter();
+ inline ~Counter() {};
/// \brief Increment a counter item specified with \a type.
///
/// \param type %Counter item to increment
///
/// \throw isc::OutOfRange \a type is invalid
- inline void inc(const Counter::Type);
+ inline void inc(const Counter::Type type) {
+ if (type >= counters_.size()) {
+ isc_throw(isc::OutOfRange, "Counter type is out of range");
+ }
+ ++counters_.at(type);
+ return;
+ };
/// \brief Get the value of a counter item specified with \a type.
///
/// \param type %Counter item to get the value of
///
/// \throw isc::OutOfRange \a type is invalid
- inline const Counter::Value& get(const Counter::Type) const;
+ inline const Counter::Value& get(const Counter::Type type) const {
+ if (type >= counters_.size()) {
+ isc_throw(isc::OutOfRange, "Counter type is out of range");
+ }
+ return (counters_.at(type));
+ };
};
-inline Counter::Counter(const size_t items) :
- counters_(items, InitialValue)
-{
- if (items == 0) {
- isc_throw(isc::InvalidParameter, "Items must not be 0");
- }
-}
-
-inline Counter::~Counter() {}
-
-inline void
-Counter::inc(const Counter::Type type) {
- if(type >= counters_.size()) {
- isc_throw(isc::OutOfRange, "Counter type is out of range");
- }
- ++counters_.at(type);
- return;
-}
-
-inline const Counter::Value&
-Counter::get(const Counter::Type type) const {
- if(type >= counters_.size()) {
- isc_throw(isc::OutOfRange, "Counter type is out of range");
- }
- return (counters_.at(type));
-}
-
} // namespace statistics
} // namespace isc
diff --git a/src/lib/statistics/counter_dict.h b/src/lib/statistics/counter_dict.h
index 3715fc2..6861abf 100644
--- a/src/lib/statistics/counter_dict.h
+++ b/src/lib/statistics/counter_dict.h
@@ -48,12 +48,50 @@ private:
// specified at the construction of this class.
CounterDictionary();
public:
- explicit inline CounterDictionary(const size_t items);
- inline ~CounterDictionary();
- inline void addElement(const std::string& name);
- inline void deleteElement(const std::string& name);
- inline Counter& getElement(const std::string& name);
- inline Counter& operator[](const std::string& name);
+ explicit inline CounterDictionary(const size_t items) :
+ items_(items)
+ {
+ // The number of items must not be 0
+ if (items == 0) {
+ isc_throw(isc::InvalidParameter, "Items must not be 0");
+ }
+ };
+ inline ~CounterDictionary() {};
+ inline void addElement(const std::string& name) {
+ // throw if the element already exists
+ if (dictionary_.count(name) != 0) {
+ isc_throw(isc::InvalidParameter,
+ "Element " << name << " already exists");
+ }
+ assert(items_ != 0);
+ // Create a new Counter and add to the map
+ dictionary_.insert(
+ DictionaryMap::value_type(name, CounterPtr(new Counter(items_))));
+ };
+ inline void deleteElement(const std::string& name) {
+ size_t result = dictionary_.erase(name);
+ if (result != 1) {
+ // If an element with specified name does not exist, throw
+ // isc::OutOfRange.
+ isc_throw(isc::OutOfRange,
+ "Element " << name << " does not exist");
+ }
+ };
+ inline Counter& getElement(const std::string& name) {
+ DictionaryMap::const_iterator i = dictionary_.find(name);
+ if (i != dictionary_.end()) {
+ // the key was found. return the element.
+ return (*(i->second));
+ } else {
+ // If an element with specified name does not exist, throw
+ // isc::OutOfRange.
+ isc_throw(isc::OutOfRange,
+ "Element " << name << " does not exist");
+ }
+ };
+ inline Counter& operator[](const std::string& name) {
+ return (getElement(name));
+ };
/// \brief \c ConstIterator is a constant iterator that provides an
/// interface for enumerating name of zones stored in CounterDictionary.
///
@@ -79,26 +117,7 @@ public:
///
/// This method never throws an exception.
inline ~ConstIterator() {}
- /// The assignment operator.
- ///
- /// This method is mostly exception free. But it may still
- /// throw a standard exception if memory allocation fails
- /// inside the method.
- inline ConstIterator& operator=(const ConstIterator& source) {
- iterator_ = source.iterator_;
- return (*this);
- }
-
- /// The copy constructor.
- ///
- /// This constructor is mostly exception free. But it may still
- /// throw a standard exception if memory allocation fails
- /// inside the method.
- inline ConstIterator(const ConstIterator& source) :
- iterator_(source.iterator_)
- {}
- //
- // Constructor from implementation detail DictionaryMap::const_iterator
+ /// Constructor from implementation detail DictionaryMap::const_iterator
inline ConstIterator(
DictionaryMap::const_iterator iterator) :
iterator_(iterator)
@@ -126,77 +145,16 @@ public:
DictionaryMap::const_iterator iterator_;
};
- inline ConstIterator begin() const;
- inline ConstIterator end() const;
+ inline ConstIterator begin() const {
+ return (CounterDictionary::ConstIterator(dictionary_.begin()));
+ };
+ inline ConstIterator end() const {
+ return (CounterDictionary::ConstIterator(dictionary_.end()));
+ };
typedef ConstIterator const_iterator;
};
-
-inline CounterDictionary::ConstIterator
-CounterDictionary::begin() const {
- return (CounterDictionary::ConstIterator(dictionary_.begin()));
-}
-
-inline CounterDictionary::ConstIterator
-CounterDictionary::end() const {
- return (CounterDictionary::ConstIterator(dictionary_.end()));
-}
-
-// Constructor with number of items
-inline CounterDictionary::CounterDictionary(const size_t items) :
- items_(items)
-{
- // The number of items must not be 0
- if (items == 0) {
- isc_throw(isc::InvalidParameter, "Items must not be 0");
- }
-}
-
-// Destructor
-inline CounterDictionary::~CounterDictionary() {}
-
-inline void
-CounterDictionary::addElement(const std::string& name) {
- // throw if the element already exists
- if (dictionary_.count(name) != 0) {
- isc_throw(isc::InvalidParameter,
- "Element " << name << " already exists");
- }
- assert(items_ != 0);
- // Create a new Counter and add to the map
- dictionary_.insert(
- DictionaryMap::value_type(name, CounterPtr(new Counter(items_))));
-}
-
-inline void
-CounterDictionary::deleteElement(const std::string& name) {
- size_t result = dictionary_.erase(name);
- if (result != 1) {
- // If an element with specified name does not exist, throw
- // isc::OutOfRange.
- isc_throw(isc::OutOfRange, "Element " << name << " does not exist");
- }
-}
-
-inline Counter&
-CounterDictionary::getElement(const std::string& name) {
- DictionaryMap::const_iterator i = dictionary_.find(name);
- if (i != dictionary_.end()) {
- // the key was found. return the element.
- return (*(i->second));
- } else {
- // If an element with specified name does not exist, throw
- // isc::OutOfRange.
- isc_throw(isc::OutOfRange, "Element " << name << " does not exist");
- }
-}
-
-inline Counter&
-CounterDictionary::operator[](const std::string& name) {
- return (getElement(name));
-}
-
} // namespace statistics
} // namespace isc
More information about the bind10-changes
mailing list