BIND 10 trac493, updated. 6b5705bb7f6fac495f8b3e050ce9089997416ccb [trac493] Add canMessageBeCached() to message utility functions
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Mar 3 09:34:51 UTC 2011
The branch, trac493 has been updated
via 6b5705bb7f6fac495f8b3e050ce9089997416ccb (commit)
from e9cd09d4a41cfb46af3a89e57f7d3184c602dc06 (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 6b5705bb7f6fac495f8b3e050ce9089997416ccb
Author: Ocean Wang <wanghaidong at cnnic.cn>
Date: Thu Mar 3 17:34:17 2011 +0800
[trac493] Add canMessageBeCached() to message utility functions
-----------------------------------------------------------------------
Summary of changes:
src/lib/cache/message_cache.cc | 5 +----
src/lib/cache/message_utility.cc | 18 +++++++++++++++---
src/lib/cache/message_utility.h | 5 +++++
3 files changed, 21 insertions(+), 7 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/cache/message_cache.cc b/src/lib/cache/message_cache.cc
index 80346ad..1c3f9e0 100644
--- a/src/lib/cache/message_cache.cc
+++ b/src/lib/cache/message_cache.cc
@@ -61,10 +61,7 @@ MessageCache::lookup(const isc::dns::Name& qname,
bool
MessageCache::update(const Message& msg) {
- // If the message is a negative response, but no SOA record is found in
- // the authority section, the message cannot be cached
- if (isNegativeResponse(msg) &&
- !hasTheRecordInAuthoritySection(msg, RRType::SOA())){
+ if (!canMessageBeCached(msg)){
return (false);
}
diff --git a/src/lib/cache/message_utility.cc b/src/lib/cache/message_utility.cc
index a662ae6..25bf7ee 100644
--- a/src/lib/cache/message_utility.cc
+++ b/src/lib/cache/message_utility.cc
@@ -24,7 +24,8 @@ namespace cache {
namespace MessageUtility{
bool
-hasTheRecordInAuthoritySection(const isc::dns::Message& msg, const isc::dns::RRType& type)
+hasTheRecordInAuthoritySection(const isc::dns::Message& msg,
+ const isc::dns::RRType& type)
{
for (RRsetIterator iter = msg.beginSection(Message::SECTION_AUTHORITY);
iter != msg.endSection(Message::SECTION_AUTHORITY);
@@ -38,8 +39,7 @@ hasTheRecordInAuthoritySection(const isc::dns::Message& msg, const isc::dns::RRT
}
bool
-isNegativeResponse(const isc::dns::Message& msg)
-{
+isNegativeResponse(const isc::dns::Message& msg) {
if (msg.getRcode() == Rcode::NXDOMAIN()) {
return (true);
} else if (msg.getRcode() == Rcode::NOERROR()) {
@@ -58,6 +58,18 @@ isNegativeResponse(const isc::dns::Message& msg)
return (false);
}
+bool
+canMessageBeCached(const isc::dns::Message& msg) {
+ // If the message is a negative response, but no SOA record is found in
+ // the authority section, the message cannot be cached
+ if (isNegativeResponse(msg) &&
+ !hasTheRecordInAuthoritySection(msg, RRType::SOA())){
+ return (false);
+ }
+
+ return (true);
+}
+
} // namespace MessageUtility
} // namespace cache
} // namespace isc
diff --git a/src/lib/cache/message_utility.h b/src/lib/cache/message_utility.h
index 58b366f..0976179 100644
--- a/src/lib/cache/message_utility.h
+++ b/src/lib/cache/message_utility.h
@@ -43,6 +43,11 @@ bool hasTheRecordInAuthoritySection(const isc::dns::Message& msg,
/// \param msg The response message
bool isNegativeResponse(const isc::dns::Message& msg);
+/// \brief Check whether the message can be cached
+///
+/// \param msg The response message
+bool canMessageBeCached(const isc::dns::Message& msg);
+
} // namespace MessageUtility
} // namespace cache
} // namespace isc
More information about the bind10-changes
mailing list