Commit 0337c552 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[1198] some trivial cleanups:

 - constify things as much as possible
 - a bit of style fixes (brace position, etc)
parent 63f318aa
......@@ -392,17 +392,18 @@ DatabaseClient::Finder::findNSECCover(const Name& name) {
DatabaseClient::Finder::DelegationSearchResult
DatabaseClient::Finder::findDelegationPoint(const isc::dns::Name& name,
const FindOptions options) {
const FindOptions options)
{
// Result of search
isc::dns::RRsetPtr result_rrset;
isc::dns::ConstRRsetPtr result_rrset;
ZoneFinder::Result result_status = SUCCESS;
// In case we are in GLUE_OK mode and start matching wildcards,
// we can't do it under NS, so we store it here to check
isc::dns::RRsetPtr first_ns;
isc::dns::ConstRRsetPtr first_ns;
// Are we searching for glue?
bool glue_ok((options & FIND_GLUE_OK) != 0);
const bool glue_ok((options & FIND_GLUE_OK) != 0);
// First, do we have any kind of delegation (NS/DNAME) here?
const Name origin(getOrigin());
......@@ -418,14 +419,14 @@ DatabaseClient::Finder::findDelegationPoint(const isc::dns::Name& name,
// Go through all superdomains from the origin down searching for nodes
// that indicate a delegation (NS or DNAME).
for (int i = remove_labels; i > 0; --i) {
Name superdomain(name.split(i));
const Name superdomain(name.split(i));
// Note if this is the origin.
bool not_origin = (i != remove_labels);
const bool not_origin = (i != remove_labels);
// Look if there's NS or DNAME (but ignore the NS in origin)
FoundRRsets found = getRRsets(superdomain.toText(), DELEGATION_TYPES(),
not_origin);
const FoundRRsets found = getRRsets(superdomain.toText(),
DELEGATION_TYPES(), not_origin);
if (found.first) {
// It contains some RRs, so it exists.
last_known = superdomain.getLabelCount();
......@@ -470,13 +471,13 @@ DatabaseClient::Finder::findDelegationPoint(const isc::dns::Name& name,
}
DatabaseClient::Finder::WildcardSearchResult
DatabaseClient::Finder::findWildcardMatch(const isc::dns::Name& name,
const isc::dns::RRType& type,
const FindOptions options,
isc::dns::RRsetPtr& first_ns,
size_t last_known) {
DatabaseClient::Finder::findWildcardMatch(
const isc::dns::Name& name, const isc::dns::RRType& type,
const FindOptions options, const isc::dns::ConstRRsetPtr& first_ns,
size_t last_known)
{
// Result of search
isc::dns::RRsetPtr result_rrset;
isc::dns::ConstRRsetPtr result_rrset;
ZoneFinder::Result result_status = SUCCESS;
// Search options
......@@ -593,24 +594,24 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_FIND_RECORDS)
.arg(accessor_->getDBName()).arg(name).arg(type);
bool glue_ok((options & FIND_GLUE_OK) != 0);
const bool glue_ok((options & FIND_GLUE_OK) != 0);
const bool dnssec_data((options & FIND_DNSSEC) != 0);
bool records_found = false; // Distinguish between NXDOMAIN and NXRRSET
bool get_cover = false;
isc::dns::RRsetPtr result_rrset;
isc::dns::ConstRRsetPtr result_rrset;
ZoneFinder::Result result_status = SUCCESS;
const Name origin(getOrigin());
// First stage: go throught all superdomains from the origin down,
// searching for nodes that indicate a delegation (NS or DNAME).
DelegationSearchResult dresult = findDelegationPoint(name, options);
const DelegationSearchResult dresult = findDelegationPoint(name, options);
result_status = dresult.code;
result_rrset = dresult.rrset;
// In case we are in GLUE_OK mode and start matching wildcards,
// we can't do it under NS, so we store it here to check
isc::dns::RRsetPtr first_ns = dresult.first_ns;
const isc::dns::ConstRRsetPtr first_ns = dresult.first_ns;
size_t last_known = dresult.last_known;
if (!result_rrset) { // Only if we didn't find a redirect already
......@@ -620,8 +621,8 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
// And we don't consider the NS in origin
WantedTypes final_types(FINAL_TYPES());
final_types.insert(type);
FoundRRsets found = getRRsets(name.toText(), final_types,
name != origin);
const FoundRRsets found = getRRsets(name.toText(), final_types,
name != origin);
records_found = found.first;
// NS records, CNAME record and Wanted Type records
......@@ -675,10 +676,9 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
// It's not an empty non-terminal so check for wildcards.
// We remove labels one by one and look for the wildcard there.
// Go up to first non-empty domain.
WildcardSearchResult wresult = findWildcardMatch(name, type,
options,
first_ns,
last_known);
const WildcardSearchResult wresult =
findWildcardMatch(name, type, options, first_ns,
last_known);
result_status = wresult.code;
result_rrset = wresult.rrset;
records_found = wresult.records_found;
......
......@@ -836,16 +836,16 @@ public:
/// deriving it from a parent class was deemed not worthwhile.
struct DelegationSearchResult {
DelegationSearchResult(const ZoneFinder::Result param_code,
const isc::dns::RRsetPtr param_rrset,
const isc::dns::RRsetPtr param_ns,
const isc::dns::ConstRRsetPtr param_rrset,
const isc::dns::ConstRRsetPtr param_ns,
size_t param_last_known) :
code(param_code), rrset(param_rrset),
first_ns(param_ns),
last_known(param_last_known)
{}
const ZoneFinder::Result code; ///< Result code
const isc::dns::RRsetPtr rrset; ///< Pointer to RRset found
const isc::dns::RRsetPtr first_ns; ///< Pointer to first NS found
const isc::dns::ConstRRsetPtr rrset; ///< Pointer to RRset found
const isc::dns::ConstRRsetPtr first_ns; ///< Pointer to first NS found
const size_t last_known; ///< No. labels in last non-empty domain
};
......@@ -865,13 +865,13 @@ public:
/// deriving it from a parent class was deemed not worthwhile.
struct WildcardSearchResult {
WildcardSearchResult(const ZoneFinder::Result param_code,
const isc::dns::RRsetPtr param_rrset,
const isc::dns::ConstRRsetPtr param_rrset,
const bool param_found) :
code(param_code), rrset(param_rrset),
records_found(param_found)
{}
const ZoneFinder::Result code; ///< Result code
const isc::dns::RRsetPtr rrset; ///< Pointer to RRset found
const isc::dns::ConstRRsetPtr rrset; ///< Pointer to RRset found
const bool records_found; ///< true => NXRRSET
};
......@@ -998,9 +998,10 @@ public:
* NXDOMAIN or an NXRRSET.
*/
WildcardSearchResult
findWildcardMatch(const isc::dns::Name& name,
const isc::dns::RRType& type, const FindOptions options,
isc::dns::RRsetPtr& first_ns, size_t last_known);
findWildcardMatch(
const isc::dns::Name& name,
const isc::dns::RRType& type, const FindOptions options,
const isc::dns::ConstRRsetPtr& first_ns, size_t last_known);
/**
* \brief Checks if something lives below this domain.
......
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