From: JINMEI Tatuya Date: Fri, 11 May 2012 08:58:37 +0000 (-0700) Subject: [1808-2] extracted NSEC-getting code for normal NXRRSET case to a helper func. X-Git-Tag: trac2351_base~226^2~156^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=911f3f6bcb273fb4edf35771530ea5e4d81796d8;p=thirdparty%2Fkea.git [1808-2] extracted NSEC-getting code for normal NXRRSET case to a helper func. this simplifies the main code, and avoids using the same log ID twice. --- diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc index 386c325436..3e73e26970 100644 --- a/src/lib/datasrc/memory_datasrc.cc +++ b/src/lib/datasrc/memory_datasrc.cc @@ -1255,6 +1255,24 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl { } } + // A helper function for the NXRRSET case in find(). If the zone is + // NSEC-signed and DNSSEC records are requested, try to find NSEC + // on the given node, and return it if found; return NULL for all other + // cases. + ConstRBNodeRRsetPtr getNSECForNXRRSET(FindOptions options, + const DomainNode& node) const + { + if (zone_data_->nsec_signed_ && + (options & ZoneFinder::FIND_DNSSEC) != 0) { + const Domain::const_iterator found = + node.getData()->find(RRType::NSEC()); + if (found != node.getData()->end()) { + return (found->second); + } + } + return (ConstRBNodeRRsetPtr()); + } + // Set up FindContext object as a return value of find(), taking into // account wildcard matches and DNSSEC information. We set the NSEC/NSEC3 // flag when applicable regardless of the find option; the caller would @@ -1367,23 +1385,9 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl { rename)); } } - // No exact match or CNAME. This is NXRRSET case. If with DNSSEC query, - // get the NSEC RRset, returns with result code NXRRSET. - if (zone_data_->nsec_signed_ && (options & ZoneFinder::FIND_DNSSEC) != 0) { - found = node->getData()->find(RRType::NSEC()); - if (found != node->getData()->end()) { - LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_NXRRSET).arg(type). - arg(name); - return (createFindResult(NXRRSET, - prepareRRset(name, found->second, - rename, options), - rename)); - } - } - // No exact match or CNAME. Return NXRRSET. - LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_NXRRSET).arg(type). - arg(name); - return (createFindResult(NXRRSET, ConstRBNodeRRsetPtr(), rename)); + // No exact match or CNAME. Get NSEC if necessary and return NXRRSET. + return (createFindResult(NXRRSET, getNSECForNXRRSET(options, *node), + rename)); } };