Commit 34dd2565 authored by Yoshitaka Aharen's avatar Yoshitaka Aharen
Browse files

[2157] add getter method

parent 50c6b204
......@@ -126,25 +126,25 @@ Counters::Counters() :
void
Counters::incRequest(const MessageAttributes& msgattrs) {
// protocols carrying request
if (msgattrs.req_ip_version_ == AF_INET) {
if (msgattrs.getRequestIPVersion() == AF_INET) {
server_msg_counter_.inc(MSG_REQUEST_IPV4);
} else if (msgattrs.req_ip_version_ == AF_INET6) {
} else if (msgattrs.getRequestIPVersion() == AF_INET6) {
server_msg_counter_.inc(MSG_REQUEST_IPV6);
}
if (msgattrs.req_transport_protocol_ == IPPROTO_UDP) {
if (msgattrs.getRequestTransportProtocol() == IPPROTO_UDP) {
server_msg_counter_.inc(MSG_REQUEST_UDP);
} else if (msgattrs.req_transport_protocol_ == IPPROTO_TCP) {
} else if (msgattrs.getRequestTransportProtocol() == IPPROTO_TCP) {
server_msg_counter_.inc(MSG_REQUEST_TCP);
}
// request TSIG
if (msgattrs.req_is_tsig_) {
if (msgattrs.getRequestSigTSIG()) {
server_msg_counter_.inc(MSG_REQUEST_TSIG);
}
if (msgattrs.req_is_sig0_) {
if (msgattrs.getRequestSigSIG0()) {
server_msg_counter_.inc(MSG_REQUEST_SIG0);
}
if (msgattrs.req_is_badsig_) {
if (msgattrs.getRequestSigBadSig()) {
server_msg_counter_.inc(MSG_REQUEST_BADSIG);
// If signature validation is failed, no other query attributes are
// reliable. Skip processing of the rest of query counters.
......@@ -152,20 +152,20 @@ Counters::incRequest(const MessageAttributes& msgattrs) {
}
// request EDNS
if (msgattrs.req_is_edns_0_) {
if (msgattrs.getRequestEDNS0()) {
server_msg_counter_.inc(MSG_REQUEST_EDNS0);
}
if (msgattrs.req_is_edns_badver_) {
if (msgattrs.getRequestEDNSBadVer()) {
server_msg_counter_.inc(MSG_REQUEST_BADEDNSVER);
}
// request DNSSEC
if (msgattrs.req_is_dnssec_ok_) {
if (msgattrs.getRequestDO()) {
server_msg_counter_.inc(MSG_REQUEST_DNSSEC_OK);
}
// OPCODE
server_msg_counter_.inc(opcode_to_msgcounter[msgattrs.req_opcode_]);
server_msg_counter_.inc(opcode_to_msgcounter[msgattrs.getRequestOpCode()]);
}
void
......@@ -176,7 +176,7 @@ Counters::incResponse(const MessageAttributes& msgattrs,
server_msg_counter_.inc(MSG_RESPONSE);
// response truncated
if (msgattrs.res_is_truncated_) {
if (msgattrs.getResponseTruncated()) {
server_msg_counter_.inc(MSG_RESPONSE_TRUNCATED);
}
......@@ -187,7 +187,7 @@ Counters::incResponse(const MessageAttributes& msgattrs,
}
// response TSIG
if (msgattrs.req_is_tsig_) {
if (msgattrs.getRequestSigTSIG()) {
// assume response is TSIG signed if request is TSIG signed
server_msg_counter_.inc(MSG_RESPONSE_TSIG);
}
......
......@@ -37,11 +37,7 @@ namespace statistics {
///
/// This class holds some attributes related to a DNS message
/// for statistics data collection.
///
/// This class does not have getter methods since it exposes private members
/// to \c Counters directly.
class MessageAttributes {
friend class Counters;
private:
// request attributes
int req_ip_version_; // IP version
......@@ -65,24 +61,59 @@ public:
reset();
};
/// \brief Get request opcode.
/// \return opcode of a request
/// \throw None
int getRequestOpCode() const {
return (req_opcode_);
};
/// \brief Set request opcode.
/// \throw None
void setRequestOpCode(const int opcode) {
req_opcode_ = opcode;
};
/// \brief Get IP version carrying a request.
/// \return IP version carrying a request
/// \throw None
int getRequestIPVersion() const {
return (req_ip_version_);
};
/// \brief Set IP version carrying a request.
/// \throw None
void setRequestIPVersion(const int ip_version) {
req_ip_version_ = ip_version;
};
/// \brief Get transport protocol carrying a request.
/// \return Transport protocol carrying a request
/// \throw None
int getRequestTransportProtocol() const {
return (req_transport_protocol_);
};
/// \brief Set transport protocol carrying a request.
/// \throw None
void setRequestTransportProtocol(const int transport_protocol) {
req_transport_protocol_ = transport_protocol;
};
/// \brief Get request is EDNS version 0.
/// \return true if EDNS version 0
/// \throw None
bool getRequestEDNS0() const {
return (req_is_edns_0_);
};
/// \brief Get request is EDNS version other than 0.
/// \return true if EDNS version other than 0
/// \throw None
bool getRequestEDNSBadVer() const {
return (req_is_edns_badver_);
};
/// \brief Set request EDNS attributes.
/// \throw None
void setRequestEDNS(const bool is_edns_0, const bool is_edns_badver) {
......@@ -90,12 +121,40 @@ public:
req_is_edns_badver_ = is_edns_badver;
};
/// \brief Set request DO bit.
/// \brief Get request DNSSEC OK (DO) bit.
/// \return true if DNSSEC OK bit is set
/// \throw None
bool getRequestDO() const {
return (req_is_dnssec_ok_);
};
/// \brief Set request DNSSEC OK (DO) bit.
/// \throw None
void setRequestDO(const bool is_dnssec_ok) {
req_is_dnssec_ok_ = is_dnssec_ok;
};
/// \brief Get request TSIG signed and verified.
/// \return true if request is TSIG signed and verified
/// \throw None
bool getRequestSigTSIG() const {
return (req_is_tsig_);
};
/// \brief Get request SIG(0) signed and verified.
/// \return true if request is SIG(0) signed and verified
/// \throw None
bool getRequestSigSIG0() const {
return (req_is_sig0_);
};
/// \brief Get request signature is bad.
/// \return true if request signature is bad
/// \throw None
bool getRequestSigBadSig() const {
return (req_is_badsig_);
};
/// \brief Set request TSIG attributes.
/// \throw None
void setRequestSig(const bool is_tsig, const bool is_sig0,
......@@ -106,6 +165,13 @@ public:
req_is_badsig_ = is_badsig;
};
/// \brief Get if the response is truncated.
/// \return true if the response is truncated
/// \throw None
bool getResponseTruncated() const {
return (res_is_truncated_);
};
/// \brief Set if the response is truncated.
/// \throw None
void setResponseTruncated(const bool is_truncated) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment