local_zone_data.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #ifndef _LOCAL_ZONE_DATA
  15. #define _LOCAL_ZONE_DATA
  16. #include <map>
  17. #include <string>
  18. #include <boost/shared_ptr.hpp>
  19. #include <dns/rrset.h>
  20. namespace isc {
  21. namespace cache {
  22. /// \brief Local Zone Data
  23. /// The object of LocalZoneData represents the data of one
  24. /// local zone. It provides the interface for lookup the rrsets
  25. /// in the zone.
  26. class LocalZoneData {
  27. public:
  28. LocalZoneData(uint16_t rrset_class) : class_(rrset_class)
  29. {}
  30. /// \brief Look up one rrset.
  31. ///
  32. /// \param qname The query name to look up
  33. /// \param qtype The query type to look up
  34. /// \return return the shared_ptr of rrset if it is
  35. /// found in the local zone, or else, return NULL.
  36. isc::dns::RRsetPtr lookup(const isc::dns::Name& qname,
  37. const isc::dns::RRType& qtype);
  38. /// \brief Update the rrset in the local zone.
  39. ///
  40. /// If the rrset doesn't exist, it will be added.
  41. /// Otherwise, the existed one will be overwritten.
  42. ///
  43. /// \param rrset The rrset to update
  44. void update(const isc::dns::AbstractRRset& rrset);
  45. private:
  46. std::map<std::string, isc::dns::RRsetPtr> rrsets_map_; // RRsets of the zone
  47. uint16_t class_; // The class of the zone
  48. };
  49. typedef boost::shared_ptr<LocalZoneData> LocalZoneDataPtr;
  50. typedef boost::shared_ptr<const LocalZoneData> ConstLocalZoneDataPtr;
  51. } // namespace cache
  52. } // namespace isc
  53. #endif // _LOCAL_ZONE_DATA