test_datasrc.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. // $Id$
  15. #ifndef __TEST_DATA_SOURCE_H
  16. #define __TEST_DATA_SOURCE_H
  17. #include <gtest/gtest.h>
  18. #include <datasrc/data_source.h>
  19. namespace isc {
  20. namespace dns {
  21. class Name;
  22. class RRClass;
  23. class RRType;
  24. class RRsetList;
  25. }
  26. namespace datasrc {
  27. class Query;
  28. class TestDataSrc : public DataSrc {
  29. ///
  30. /// \name Constructors, Assignment Operator and Destructor.
  31. ///
  32. /// Note: The copy constructor and the assignment operator are intentionally
  33. /// defined as private.
  34. //@{
  35. private:
  36. TestDataSrc(const TestDataSrc& source);
  37. TestDataSrc operator=(const TestDataSrc& source);
  38. public:
  39. TestDataSrc() : initialized(false) {}
  40. ~TestDataSrc() {}
  41. //@}
  42. void findClosestEnclosure(DataSrcMatch& match) const;
  43. Result findRRset(const isc::dns::Name& qname,
  44. const isc::dns::RRClass& qclass,
  45. const isc::dns::RRType& qtype,
  46. isc::dns::RRsetList& target,
  47. uint32_t& flags,
  48. const isc::dns::Name* zonename) const;
  49. Result findExactRRset(const isc::dns::Name& qname,
  50. const isc::dns::RRClass& qclass,
  51. const isc::dns::RRType& qtype,
  52. isc::dns::RRsetList& target,
  53. uint32_t& flags,
  54. const isc::dns::Name* zonename) const;
  55. Result findAddrs(const isc::dns::Name& qname,
  56. const isc::dns::RRClass& qclass,
  57. isc::dns::RRsetList& target,
  58. uint32_t& flags,
  59. const isc::dns::Name* zonename) const;
  60. Result findReferral(const isc::dns::Name& qname,
  61. const isc::dns::RRClass& qclass,
  62. isc::dns::RRsetList& target,
  63. uint32_t& flags,
  64. const isc::dns::Name* zonename) const;
  65. Result findPreviousName(const isc::dns::Name& qname,
  66. isc::dns::Name& target,
  67. const isc::dns::Name* zonename) const;
  68. Result findCoveringNSEC3(const isc::dns::Name& zonename,
  69. std::string& hash,
  70. isc::dns::RRsetList& target) const;
  71. Result init();
  72. Result init(const isc::data::ElementPtr config);
  73. Result close() { return (SUCCESS); }
  74. private:
  75. bool initialized;
  76. enum Mode {
  77. NORMAL,
  78. ADDRESS,
  79. DELEGATION
  80. };
  81. class RRsetMatch;
  82. void findRecords(const isc::dns::Name& name, const isc::dns::RRType& rdtype,
  83. isc::dns::RRsetList& target,
  84. const isc::dns::Name* zonename, const Mode mode,
  85. uint32_t& flags) const;
  86. };
  87. }
  88. }
  89. #endif
  90. // Local Variables:
  91. // mode: c++
  92. // End: