Browse Source

Finish basic function of rrset_entry

Ocean Wang 14 years ago
parent
commit
2aff13f019
3 changed files with 10 additions and 17 deletions
  1. 0 2
      src/lib/cache/message_entry.cc
  2. 6 6
      src/lib/cache/rrset_entry.cc
  3. 4 9
      src/lib/cache/rrset_entry.h

+ 0 - 2
src/lib/cache/message_entry.cc

@@ -19,10 +19,8 @@
 #include <nsas/nsas_entry.h>
 #include <nsas/nsas_entry.h>
 #include <nsas/fetchable.h>
 #include <nsas/fetchable.h>
 #include "message_entry.h"
 #include "message_entry.h"
-#include "rrset_entry.h"
 #include "rrset_cache.h"
 #include "rrset_cache.h"
 
 
-
 using namespace isc::dns;
 using namespace isc::dns;
 using namespace std;
 using namespace std;
 
 

+ 6 - 6
src/lib/cache/rrset_entry.cc

@@ -25,15 +25,15 @@ namespace isc {
 namespace cache {
 namespace cache {
 
 
 RRsetEntry::RRsetEntry(const isc::dns::RRset& rrset, const RRsetTrustLevel& level): 
 RRsetEntry::RRsetEntry(const isc::dns::RRset& rrset, const RRsetTrustLevel& level): 
-    type_(rrset.getClass().getCode()), 
-    class_(rrset.getClass().getCode()), ttl_(0), rr_count_(0), rrsig_count_(0),
-    expire_time_(0), trust_level_(level)
+    expire_time_(time(NULL) + rrset.getTTL().getValue()),
+    trust_level_(level),
+    rrset_(new RRset(rrset.getName(), rrset.getClass(), rrset.getType(), rrset.getTTL()))
 {
 {
 }
 }
 
 
 isc::dns::RRsetPtr
 isc::dns::RRsetPtr
 RRsetEntry::genRRset() const {
 RRsetEntry::genRRset() const {
-    return boost::shared_ptr<isc::dns::RRset> ();
+    return rrset_;
 }
 }
 
 
 time_t
 time_t
@@ -43,8 +43,8 @@ RRsetEntry::getExpireTime() const {
 
 
 HashKey
 HashKey
 RRsetEntry::hashKey() const {
 RRsetEntry::hashKey() const {
-    CacheEntryKey keydata = genCacheEntryKey(name_, type_);
-    return HashKey(keydata.first, keydata.second, RRClass(class_));
+    CacheEntryKey keydata = genCacheEntryKey(rrset_->getName().toText(), rrset_->getType().getCode());
+    return HashKey(keydata.first, keydata.second, RRClass(rrset_->getClass().getCode()));
 }
 }
 
 
 } // namespace cache
 } // namespace cache

+ 4 - 9
src/lib/cache/rrset_entry.h

@@ -17,7 +17,9 @@
 #ifndef __RRSET_ENTRY_H
 #ifndef __RRSET_ENTRY_H
 #define __RRSET_ENTRY_H
 #define __RRSET_ENTRY_H
 
 
+#include <dns/rrset.h>
 #include <dns/message.h>
 #include <dns/message.h>
+#include <dns/rrttl.h>
 #include <nsas/nsas_entry.h>
 #include <nsas/nsas_entry.h>
 #include <nsas/fetchable.h>
 #include <nsas/fetchable.h>
 #include "cache_entry_key.h"
 #include "cache_entry_key.h"
@@ -27,8 +29,6 @@ using namespace isc::nsas;
 namespace isc {
 namespace isc {
 namespace cache {
 namespace cache {
 
 
-class RRset;
-
 /// \enum RRset Trustworthiness
 /// \enum RRset Trustworthiness
 /// For detail of RRset trustworthiness, please refer to
 /// For detail of RRset trustworthiness, please refer to
 /// RFC2181 section5.4.1.
 /// RFC2181 section5.4.1.
@@ -78,7 +78,7 @@ public:
 
 
     /// \brief Get the ttl of the RRset.
     /// \brief Get the ttl of the RRset.
     uint32_t getTTL() const {
     uint32_t getTTL() const {
-        return ttl_;
+        return rrset_->getTTL().getValue();
     }
     }
 
 
     /// \return return hash key
     /// \return return hash key
@@ -90,17 +90,12 @@ public:
     }
     }
 
 
 private:
 private:
-    std::string name_;      // RRset owner name.
-    uint16_t type_;         // RRset type.
-    uint16_t class_;        // RRset class.
-
-    uint32_t ttl_;          // TTL of RRset
     uint32_t rr_count_;     // RRset count
     uint32_t rr_count_;     // RRset count
     uint32_t rrsig_count_;  // RRSIG count
     uint32_t rrsig_count_;  // RRSIG count
 
 
     time_t expire_time_;    // Expiration time of rrset.
     time_t expire_time_;    // Expiration time of rrset.
     RRsetTrustLevel trust_level_; // rrset trustworthiness.
     RRsetTrustLevel trust_level_; // rrset trustworthiness.
-    // sec_status;
+    boost::shared_ptr<isc::dns::RRset> rrset_;
 };
 };
     
     
 typedef boost::shared_ptr<RRsetEntry> RRsetEntryPtr;    
 typedef boost::shared_ptr<RRsetEntry> RRsetEntryPtr;