LCOV - code coverage report
Current view: top level - cache - rrset_entry.h (source / functions) Hit Total Coverage
Test: report.info Lines: 6 8 75.0 %
Date: 2012-05-15 Functions: 4 5 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
       2                 :            : //
       3                 :            : // Permission to use, copy, modify, and/or distribute this software for any
       4                 :            : // purpose with or without fee is hereby granted, provided that the above
       5                 :            : // copyright notice and this permission notice appear in all copies.
       6                 :            : //
       7                 :            : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
       8                 :            : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
       9                 :            : // AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
      10                 :            : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
      11                 :            : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
      12                 :            : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
      13                 :            : // PERFORMANCE OF THIS SOFTWARE.
      14                 :            : 
      15                 :            : #ifndef __RRSET_ENTRY_H
      16                 :            : #define __RRSET_ENTRY_H
      17                 :            : 
      18                 :            : #include <dns/rrset.h>
      19                 :            : #include <dns/message.h>
      20                 :            : #include <dns/rrttl.h>
      21                 :            : #include <nsas/nsas_entry.h>
      22                 :            : #include <nsas/fetchable.h>
      23                 :            : #include "cache_entry_key.h"
      24                 :            : 
      25                 :            : using namespace isc::nsas;
      26                 :            : 
      27                 :            : namespace isc {
      28                 :            : namespace cache {
      29                 :            : 
      30                 :            : /// \enum RRsetTrustLevel
      31                 :            : /// For detail of RRset trustworthiness, please refer to
      32                 :            : /// RFC 2181 section 5.4.1.
      33                 :            : /// Bigger value is more trustworthy.
      34                 :            : enum RRsetTrustLevel {
      35                 :            :     /// Default trust for RRset.
      36                 :            :     RRSET_TRUST_DEFAULT = 0,
      37                 :            :     /// Additional information from non-authoritative answer.
      38                 :            :     RRSET_TRUST_ADDITIONAL_NONAA,
      39                 :            :     /// Data from the authority section of a non-authoritative answer
      40                 :            :     RRSET_TRUST_AUTHORITY_NONAA,
      41                 :            :     /// Additional information from an authoritative answer.
      42                 :            :     RRSET_TRUST_ADDITIONAL_AA,
      43                 :            :     /// Non-authoritative data from the answer section of authoritative
      44                 :            :     /// answers
      45                 :            :     RRSET_TRUST_NONAUTH_ANSWER_AA,
      46                 :            :     /// Data from the answer section of a non-authoritative answer.
      47                 :            :     RRSET_TRUST_ANSWER_NONAA,
      48                 :            :     /// Glue from a primary zone, or glue from a zone transfer.
      49                 :            :     RRSET_TRUST_PRIM_GLUE,
      50                 :            :     /// Data from the authority section of an authoritative answer.
      51                 :            :     RRSET_TRUST_AUTHORITY_AA,
      52                 :            :     /// Authoritative data included in the answer section of
      53                 :            :     /// an authoritative reply.
      54                 :            :     RRSET_TRUST_ANSWER_AA,
      55                 :            :     /// Data from a primary zone file, other than glue data.
      56                 :            :     RRSET_TRUST_PRIM_ZONE_NONGLUE
      57                 :            : };
      58                 :            : 
      59                 :            : /// \brief RRset Entry
      60                 :            : /// The object of RRsetEntry represents one cached RRset.
      61                 :            : /// Each RRset entry may be refered using shared_ptr by several message
      62                 :            : /// entries.
      63                 :            : class RRsetEntry : public NsasEntry<RRsetEntry>
      64                 :            : {
      65                 :            :     ///
      66                 :            :     /// \name Constructors and Destructor
      67                 :            :     ///
      68                 :            :     /// Note: The copy constructor and the assignment operator are intentionally
      69                 :            :     /// defined as private to make it uncopyable
      70                 :            :     //@{
      71                 :            : private:
      72                 :            :     RRsetEntry(const RRsetEntry&);
      73                 :            :     RRsetEntry& operator=(const RRsetEntry&);
      74                 :            : public:
      75                 :            :     /// \brief Constructor
      76                 :            :     /// \param rrset The RRset used to initialize the RRset entry.
      77                 :            :     /// \param level trustworthiness of the RRset.
      78                 :            :     RRsetEntry(const isc::dns::AbstractRRset& rrset,
      79                 :            :                const RRsetTrustLevel& level);
      80                 :            : 
      81                 :            :     /// The destructor.
      82                 :        508 :     ~RRsetEntry() {}
      83                 :            :     //@}
      84                 :            : 
      85                 :            :     /// \brief Return a pointer to a generated RRset
      86                 :            :     ///
      87                 :            :     /// \return Pointer to the generated RRset
      88                 :            :     isc::dns::RRsetPtr getRRset();
      89                 :            : 
      90                 :            :     /// \brief Get the expiration time of the RRset.
      91                 :            :     ///
      92                 :            :     /// \return The expiration time of the RRset
      93                 :            :     ///
      94                 :            :     /// \todo RRsig expiration processing
      95                 :            :     time_t getExpireTime() const;
      96                 :            : 
      97                 :            :     /// \brief Get the ttl of the RRset.
      98                 :            :     ///
      99                 :            :     /// \return The TTL of the RRset
     100                 :        161 :     uint32_t getTTL() {
     101                 :        161 :         updateTTL();
     102                 :        161 :         return (rrset_->getTTL().getValue());
     103                 :            :     }
     104                 :            : 
     105                 :            :     /// \brief Get the hash key
     106                 :            :     ///
     107                 :            :     /// \return return hash key
     108                 :        597 :     HashKey hashKey() const {
     109                 :        597 :         return (hash_key_);
     110                 :            :     }
     111                 :            : 
     112                 :            :     /// \brief get RRset trustworthiness
     113                 :            :     ///
     114                 :            :     /// \return return the trust level
     115                 :          0 :     RRsetTrustLevel getTrustLevel() const {
     116                 :          0 :         return (trust_level_);
     117                 :            :     }
     118                 :            : private:
     119                 :            :     /// \brief Update TTL according to expiration time
     120                 :            :     void updateTTL();
     121                 :            : 
     122                 :            : private:
     123                 :            :     std::string entry_name_; // The entry name for this rrset entry.
     124                 :            :     time_t expire_time_;     // Expiration time of rrset.
     125                 :            :     RRsetTrustLevel trust_level_; // RRset trustworthiness.
     126                 :            :     boost::shared_ptr<isc::dns::RRset> rrset_;
     127                 :            :     HashKey hash_key_;       // RRsetEntry hash key
     128                 :            : };
     129                 :            : 
     130                 :            : typedef boost::shared_ptr<RRsetEntry> RRsetEntryPtr;
     131                 :            : 
     132                 :            : } // namespace cache
     133                 :            : } // namespace isc
     134                 :            : 
     135                 :            : #endif // __RRSET_ENTRY_H
     136                 :            : 

Generated by: LCOV version 1.9