Browse Source

[2429] define MAX_TTL in rrttl.h, as its bare value, not in form of RRTTL

JINMEI Tatuya 12 years ago
parent
commit
2aa24772e0
3 changed files with 16 additions and 7 deletions
  1. 1 7
      src/lib/dns/master_loader.cc
  2. 4 0
      src/lib/dns/rrttl.cc
  3. 11 0
      src/lib/dns/rrttl.h

+ 1 - 7
src/lib/dns/master_loader.cc

@@ -52,7 +52,6 @@ public:
                      const MasterLoaderCallbacks& callbacks,
                      const AddRRCallback& add_callback,
                      MasterLoader::Options options) :
-        MAX_TTL(0x7fffffff),
         lexer_(),
         zone_origin_(zone_origin),
         zone_class_(zone_class),
@@ -158,7 +157,7 @@ private:
     // RR and the lexer is positioned at the next line.  It's just for
     // calculating the accurate source line when callback is necessary.
     void limitTTL(RRTTL& ttl, bool post_parsing) {
-        if (ttl > MAX_TTL) {
+        if (ttl.getValue() > RRTTL::MAX_TTL) {
             const size_t src_line = lexer_.getSourceLine() -
                 (post_parsing ? 1 : 0);
             callbacks_.warning(lexer_.getSourceName(), src_line,
@@ -306,11 +305,6 @@ private:
     }
 
 private:
-    // RFC2181 Section 8 specifies TTLs are unsigned 32-bit integer,
-    // effectively limiting the maximum value to 2^32-1.  This constant
-    // represent a TTL of the max value.
-    const RRTTL MAX_TTL;
-
     MasterLexer lexer_;
     const Name zone_origin_;
     const RRClass zone_class_;

+ 4 - 0
src/lib/dns/rrttl.cc

@@ -57,6 +57,10 @@ Unit units[] = {
 namespace isc {
 namespace dns {
 
+// The actual definition of a static const member, in case it's address is
+// needed.
+const uint32_t RRTTL::MAX_TTL;
+
 namespace {
 bool
 parseTTLStr(const string& ttlstr, uint32_t& ttlval, string* error_txt) {

+ 11 - 0
src/lib/dns/rrttl.h

@@ -267,6 +267,17 @@ public:
     { return (ttlval_ > other.ttlval_); }
     //@}
 
+    ///
+    /// \name Protocol constants
+    ///
+    //@{
+    /// \brief Max allowable value for TTLs, as defined in RFC2181, Sec. 8.
+    ///
+    /// \note At the moment an RRTTL object can have a value larger than
+    /// this limit.  We may revisit it in a future version.
+    static const uint32_t MAX_TTL = 0x7fffffff;
+    //@}
+
 private:
     uint32_t ttlval_;
 };