zone_data.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. // Copyright (C) 2012 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 DATASRC_MEMORY_ZONE_DATA_H
  15. #define DATASRC_MEMORY_ZONE_DATA_H 1
  16. #include <util/memory_segment.h>
  17. #include <dns/name.h>
  18. #include <dns/rrclass.h>
  19. #include <datasrc/memory/domaintree.h>
  20. #include <datasrc/memory/rdataset.h>
  21. #include <boost/interprocess/offset_ptr.hpp>
  22. #include <boost/noncopyable.hpp>
  23. #include <vector>
  24. namespace isc {
  25. namespace dns {
  26. namespace rdata {
  27. namespace generic {
  28. class NSEC3PARAM;
  29. class NSEC3;
  30. }
  31. }
  32. }
  33. namespace datasrc {
  34. namespace memory {
  35. typedef DomainTree<RdataSet> ZoneTree;
  36. typedef DomainTreeNode<RdataSet> ZoneNode;
  37. typedef DomainTreeNodeChain<RdataSet> ZoneChain;
  38. /// \brief NSEC3 data for a DNS zone.
  39. ///
  40. /// This class encapsulates a set of NSEC3 related data for a zone
  41. /// that is signed with NSEC3 RRs. Specifically, it contains hash
  42. /// parameters as given in an NSEC3PARAM RDATA and all NSEC3 RRs of the zone.
  43. ///
  44. /// The main concept of the class is generally the same as that of
  45. /// \c ZoneData (see its description for details), but the related data
  46. //// are encapsulated in a more straightforward way in this class.
  47. ///
  48. /// The NSEC3 RRs (which should normally have RRSIGs) are stored in a
  49. /// \c DomainTree object whose data type is (a list of) \c RdataSet.
  50. /// This tree is expected to store NSEC3 RRs only, so the RR type of
  51. /// \c RdataSet should be NSEC3. But this class itself doesn't guarantee
  52. /// this condition. It's the caller's responsibility.
  53. ///
  54. /// Read-only access to the tree is possible via the \c getNSEC3Tree() method.
  55. /// Modifying the tree must be done by a specific method (in the initial
  56. /// implementation, it's \c insertName(). There may be some more as we
  57. /// see the need); the application cannot directly change the content of the
  58. /// tree in an arbitrary way. This class does not have a strong reason to be
  59. /// that strict, but is defined this way mainly to be consistent with the
  60. /// \c ZoneData class.
  61. ///
  62. /// Most of the hash parameters are maintained in the form of straightforward
  63. /// member variables, which can be directly referenced by the application.
  64. /// The exception is the salt, which is encapsulated as opaque data
  65. /// immediately following the main class object, and should be accessible
  66. /// via the \c getSaltLen() and \c getSaltData() method.
  67. ///
  68. /// \note The fact that the this class couples one set of hash parameters
  69. /// and the set of NSEC3 RRs implicitly means a zone is assumed to have
  70. /// only one set of NSEC3 parameters. When we support multiple sets of
  71. /// parameters the design should be revised accordingly.
  72. class NSEC3Data : boost::noncopyable {
  73. public:
  74. /// \brief Allocate and construct \c NSEC3Data from NSEC3PARAM Rdata.
  75. ///
  76. /// The NSEC3 parameters are extracted and stored within the created
  77. /// \c NSEC3Data object.
  78. ///
  79. /// \throw std::bad_alloc Memory allocation fails.
  80. ///
  81. /// \param mem_sgmt A \c MemorySegment from which memory for the new
  82. /// \c NSEC3Data is allocated.
  83. /// \param rdata An NSEC3PARAM RDATA that specifies the NSEC3 parameters
  84. /// to be stored.
  85. static NSEC3Data* create(util::MemorySegment& mem_sgmt,
  86. const dns::rdata::generic::NSEC3PARAM& rdata);
  87. /// \brief Allocate and construct \c NSEC3Data from NSEC3 Rdata.
  88. ///
  89. /// The NSEC3 hash parameters are extracted and stored within the created
  90. /// \c NSEC3Data object.
  91. ///
  92. /// \throw std::bad_alloc Memory allocation fails.
  93. ///
  94. /// \param mem_sgmt A \c MemorySegment from which memory for the new
  95. /// \c NSEC3Data is allocated.
  96. /// \param rdata An NSEC3 RDATA that specifies the NSEC3 parameters
  97. /// to be stored.
  98. static NSEC3Data* create(util::MemorySegment& mem_sgmt,
  99. const dns::rdata::generic::NSEC3& rdata);
  100. /// \brief Destruct and deallocate \c NSEC3Data.
  101. ///
  102. /// It releases all resources allocated for the internal NSEC3 name space
  103. /// including NSEC3 RdataSet. It assumes \c RdataSets objects stored
  104. /// in the space were allocated using the same memory segment as
  105. /// \c mem_sgmt. The caller must ensure this assumption.
  106. ///
  107. /// Note that an \c RRClass object must be passed to this method.
  108. /// It's necessary to destroy the stored \c RdataSet objects
  109. /// (see its class description). This class doesn't hold this information;
  110. /// it's the caller's responsibility to associate an \c NSEC3Data
  111. /// class object with its expected RR class, and pass it to
  112. /// \c destroy(). (In practice, it will be passed via
  113. /// \c ZoneData::destroy().)
  114. ///
  115. /// \throw none
  116. ///
  117. /// \param mem_sgmt The \c MemorySegment that allocated memory for
  118. /// \c data.
  119. /// \param data A non-NULL pointer to a valid NSEC3Data object
  120. /// that was originally created by the \c create() method (the behavior
  121. /// is undefined if this condition isn't met).
  122. /// \param nsec3_class The RR class of the \c RdataSet stored in the NSEC3
  123. /// name space to be destroyed.
  124. static void destroy(util::MemorySegment& mem_sgmt, NSEC3Data* data,
  125. dns::RRClass nsec3_class);
  126. private:
  127. // Domain tree for the Internal NSEC3 name space. Access to it is
  128. // limited only via public methods.
  129. const boost::interprocess::offset_ptr<ZoneTree> nsec3_tree_;
  130. public:
  131. const uint8_t hashalg; ///< Hash algorithm
  132. const uint8_t flags; ///< NSEC3 parameter flags
  133. const uint16_t iterations; ///< Hash iterations
  134. // For 64-bit machines there'll be padding space here, but since
  135. // only at most one instance (or a few in very rare cases) will be
  136. // created per zone, the overhead should be acceptable.
  137. /// \brief Return \c ZoneTree for the NSEC3 name space.
  138. ///
  139. /// \throw none
  140. const ZoneTree& getNSEC3Tree() const { return (*nsec3_tree_); }
  141. /// \brief Return the size of NSEC3 salt.
  142. ///
  143. /// \throw none
  144. ///
  145. /// The return value must be in the range between 0 and 255 (inclusive).
  146. size_t getSaltLen() const { return (*getSaltBuf()); }
  147. /// \brief Return a pointer to the salt data.
  148. ///
  149. /// \throw none
  150. ///
  151. /// The valid range is up to the \c getSaltLen() bytes from the
  152. /// returned value. If \c getSaltLen() returns 0, the return value
  153. /// of this method is invalid and must not be used.
  154. const uint8_t* getSaltData() const { return (getSaltBuf() + 1); }
  155. /// \brief Insert a name to the NSEC3 name space.
  156. ///
  157. /// It allocates resource for the given name in the internal NSEC3 name
  158. /// space, and returns an access point to it in the form of \c ZoneNode
  159. /// pointer via the given \c node variable. If the name already exists
  160. /// in the name space, it returns a pointer to the existing node.
  161. ///
  162. /// This method does not perform any semantics check on the given name
  163. /// (e.g., whether the first label is a valid encoded string for an NSEC3
  164. /// owner name).
  165. ///
  166. /// \throw std::bad_alloc Memory allocation fails
  167. ///
  168. /// \param mem_sgmt Memory segment in which resource for the new memory
  169. /// is to be allocated.
  170. /// \param name The name to be inserted.
  171. /// \param node A pointer to \c ZoneNode pointer in which the created or
  172. /// found node for the name is stored. Must not be NULL (the method does
  173. /// not check that condition).
  174. void insertName(util::MemorySegment& mem_sgmt, const dns::Name& name,
  175. ZoneNode** node);
  176. private:
  177. // Common subroutine for the public versions of create().
  178. static NSEC3Data* create(util::MemorySegment& mem_sgmt, uint8_t hashalg,
  179. uint8_t flags, uint16_t iterations,
  180. const std::vector<uint8_t>& salt);
  181. /// \brief The constructor.
  182. ///
  183. /// An object of this class is always expected to be created by the
  184. /// allocator (\c create()), so the constructor is hidden as private.
  185. ///
  186. /// It never throws an exception.
  187. NSEC3Data(ZoneTree* nsec3_tree_param, uint8_t hashalg_param,
  188. uint8_t flags_param, uint16_t iterations_param) :
  189. nsec3_tree_(nsec3_tree_param), hashalg(hashalg_param),
  190. flags(flags_param), iterations(iterations_param)
  191. {}
  192. const uint8_t* getSaltBuf() const {
  193. return (reinterpret_cast<const uint8_t*>(this + 1));
  194. }
  195. uint8_t* getSaltBuf() {
  196. return (reinterpret_cast<uint8_t*>(this + 1));
  197. }
  198. };
  199. /// \brief DNS zone data.
  200. ///
  201. /// This class encapsulates the content of a DNS zone (which is essentially a
  202. /// set of RRs) in a memory efficient way and provides accessor interfaces
  203. /// to it.
  204. ///
  205. /// The primary goal of this class is to provide a packed structure of the
  206. /// data for memory efficiency. Basically, this class should be considered
  207. /// a private part of some other classes within this module and should not
  208. /// be used directly from normal applications. So it's not intended to hide
  209. /// much of the underlying implementation details; rather, it tries
  210. /// to keep the representation simple.
  211. ///
  212. /// The RRs are stored in a \c DomainTree object whose data type is
  213. /// (a list of) \c RdataSet. The tree nodes correspond to owner names,
  214. /// and the \c RdataSet objects (forming a linked list) set in the node
  215. /// represent the rest of the RR parameters except the RR class: type,
  216. /// TTL, and RDATA. This class does not have any knowledge of the RR class
  217. /// of the zone; since it's quite likely that the application maintains
  218. /// a set of zones of the same RR class, and the number of such zones can be
  219. /// huge, it makes more sense to have the application maintain the class value
  220. /// in a unified way to minimize memory footprint.
  221. ///
  222. /// The \c DomainTree object in this class is not expected to hold NSEC3
  223. /// RRs when the zone is signed with NSEC3; they should be maintained
  224. /// in an associated \c NSEC3Data object. But this class does not prevent
  225. /// the unexpected usage of adding an NSEC3 RdataSet directly in the tree.
  226. /// It's the caller's responsibility to ensure this assumption.
  227. ///
  228. /// This class maintains some other meta data and additional zone related
  229. /// content. First, it automatically creates a \c DomainTree node for the
  230. /// zone's origin name on initialization and keeps a reference to it
  231. /// throughout its lifetime. This is the case even if the zone doesn't have
  232. /// any RRs (such as in the case before initial loading). Any valid zone
  233. /// to be served should have an RR at the origin node (at least SOA, for
  234. /// example), so this assumption should be reasonable. But the application
  235. /// must ensure that any \c ZoneData object in actual use should have an
  236. /// RR at the origin; otherwise the inconsistency between the internal state
  237. /// and the actual zone content could lead to unexpected disruption.
  238. /// In particular, it must be careful when it supports dynamic updates
  239. /// to an existing zone so an update attempt doesn't result in deleting
  240. /// the origin node.
  241. ///
  242. /// To ensure integrity regarding the reference to the origin, write
  243. /// access to the tree node can be done only by public methods; the member
  244. /// variable for the tree is hidden as private. On the other hand, read-only
  245. /// access to the tree is allowed via the const version of \c getZoneTree()
  246. /// method for the convenience of the application. So, it's intentional
  247. /// that there's no non-const version of this method. Do not add one
  248. /// when this class is to be extended.
  249. ///
  250. /// Another type of meta data is parameters and records of NSEC3 RRs
  251. /// when the zone is signed with NSEC3. It's represented in the form of
  252. /// an \c NSEC3Data object, and a \c ZoneData object may be associated with
  253. /// 0 or 1 \c NSEC3Data objects using the \c setNSEC3Data() method, which
  254. /// can be retrieved by the \c getNSEC3Data() method. If the \c ZoneData
  255. /// object is not associated with an \c NSEC3Data object, it's considered not
  256. /// signed with NSEC3 RRs; otherwise it's considered to be signed with
  257. /// NSEC3 RRs and with the parameters stored in the \c NSEC3Data object.
  258. ///
  259. /// \note This interpretation may change in the future when we support migration
  260. /// from NSEC to NSEC3 or vice versa, support incremental signing, or support
  261. /// multiple sets of NSEC3 parameters.
  262. ///
  263. /// One last type of meta data is the status of the zone in terms of DNSSEC
  264. /// signing. This class supports the following concepts:
  265. /// - Whether the zone is signed or not, either with NSEC records or NSEC3
  266. /// records.
  267. /// - Whether the zone has a complete set of NSEC3 records.
  268. ///
  269. /// The former status can be accessed via the \c isSigned() and \c setSigned()
  270. /// methods; the latter can be retrieved via the \c isNSEC3Signed() method.
  271. ///
  272. /// This class does not actually relate the status of signed-or-not to
  273. /// any of its other attributes; it's up to the application how to set or
  274. /// use this status and maintain it in a reasonable way. One possible
  275. /// definition is to set this status if and only if the zone has a
  276. /// DNSKEY RR at the zone origin (which is BIND 9's definition of signed
  277. /// zone). When the application adopts this definition, it's the
  278. /// application's responsibility to keep the status consistent with the
  279. /// actual existence or non-existence of a DNSKEY RR.
  280. ///
  281. /// In the current implementation, a zone is considered to have a complete
  282. /// set of NSEC3 records if and only if it's associated with an \c NSEC3Data
  283. /// object (as noted above, these concepts may be separated in future).
  284. /// For this reason there is no "set" method for the latter; setting
  285. /// an \c NSEC3Data effectively enables the latter status. \c isNSEC3Signed()
  286. /// method is still provided (even though it's a kind of trivial wrapper to
  287. /// \c getNSEC3Data()) partly for a more intuitive shortcut, and partly
  288. /// because we won't have to change the application code when we implement
  289. /// the future separation.
  290. ///
  291. /// The intended usage of these two status concepts is to implement the
  292. /// \c ZoneFinder::Context::isNSECSigned() and
  293. /// \c ZoneFinder::Context::isNSEC3Signed() methods. A possible implementation
  294. /// is as follows:
  295. /// - \c ZoneFinder::Context::isNSECSigned() returns true iff \c isSigned()
  296. /// is true and \c isNSEC3Signed() is false.
  297. /// - \c ZoneFinder::Context::isNSEC3Signed() returns true iff \c isSigned()
  298. /// is true and \c isNSEC3Signed() is true.
  299. ///
  300. /// Note that even though \c isNSEC3Signed() being true should indicate
  301. /// \c isSigned() is true too in practice, the interfaces do not
  302. /// automatically ensure that, so we'd need to check both conditions
  303. /// explicitly. And, in fact, if we adopt the above definition of
  304. /// \c isSigned(), it's possible that a zone has a complete set of NSEC3
  305. /// RRs but no DNSKEY (although it's effectively a broken zone unless we
  306. /// support incremental signing).
  307. ///
  308. /// This class is designed so an instance can be stored in a shared
  309. /// memory region. So the pointer member variables (the initial
  310. /// implementation only contains pointer member variables) are defined
  311. /// as offset pointers. When this class is extended these properties must
  312. /// be preserved, and must also meet other requirements so it can be stored
  313. /// in a shared memory region (see, for example, \c RdataSet description).
  314. /// Future extensions must also be conscious of placing the member variables
  315. /// so that they will not accidentally cause padding and increase memory
  316. /// footprint.
  317. class ZoneData : boost::noncopyable {
  318. private:
  319. /// \brief The constructor.
  320. ///
  321. /// An object of this class is always expected to be created by the
  322. /// allocator (\c create()), so the constructor is hidden as private.
  323. ///
  324. /// It never throws an exception.
  325. ZoneData(ZoneTree* zone_tree, ZoneNode* origin_node) :
  326. zone_tree_(zone_tree), origin_node_(origin_node)
  327. {}
  328. // Zone node flags.
  329. private:
  330. // Set in the origin node (which always exists at the same address)
  331. // to indicate whether the zone is signed or not. Internal use,
  332. // so defined as private.
  333. static const ZoneNode::Flags DNSSEC_SIGNED = ZoneNode::FLAG_USER1;
  334. public:
  335. /// \brief Node flag indicating it is at a "wildcard level"
  336. ///
  337. /// This means one of the node's immediate children is a wildcard.
  338. static const ZoneNode::Flags WILDCARD_NODE = ZoneNode::FLAG_USER2;
  339. public:
  340. /// \brief Allocate and construct \c ZoneData.
  341. ///
  342. /// \throw std::bad_alloc Memory allocation fails.
  343. ///
  344. /// \param mem_sgmt A \c MemorySegment from which memory for the new
  345. /// \c ZoneData is allocated.
  346. /// \param name The zone name.
  347. static ZoneData* create(util::MemorySegment& mem_sgmt,
  348. const dns::Name& zone_name);
  349. /// \brief Destruct and deallocate \c ZoneData.
  350. ///
  351. /// It releases all resource allocated in the internal storage NSEC3 for
  352. /// zone names and RdataSet objects, and if associated, the \c NSEC3Data.
  353. /// It assumes \c RdataSets objects stored in the space and the
  354. /// associated \c NSEC3Data object were allocated using the same memory
  355. /// segment as \c mem_sgmt. The caller must ensure this assumption.
  356. ///
  357. /// Note that an \c RRClass object must be passed to this method.
  358. /// It's used to destroy the stored \c RdataSet objects
  359. /// (see its class description). This class doesn't hold this information;
  360. /// it's the caller's responsibility to associate a \c ZoneData class
  361. /// object with its expected RR class, and pass it to \c destroy().
  362. ///
  363. /// \throw none
  364. ///
  365. /// \param mem_sgmt The \c MemorySegment that allocated memory for
  366. /// \c zone_data.
  367. /// \param zone_data A non-NULL pointer to a valid ZoneData object
  368. /// that was originally created by the \c create() method (the behavior
  369. /// is undefined if this condition isn't met).
  370. /// \param zone_class The RR class of the \c RdataSet stored in the
  371. /// internal tree.
  372. static void destroy(util::MemorySegment& mem_sgmt, ZoneData* zone_data,
  373. dns::RRClass zone_class);
  374. ///
  375. /// \name Getter methods
  376. ///
  377. //@{
  378. /// \brief Return zone's origin node.
  379. ///
  380. /// This is a convenience and efficient short cut to get access to the
  381. /// zone origin in the form of \c ZoneNode object.
  382. ///
  383. /// The class encapsulation ensures that the origin node always exists at
  384. /// the same address, so this method always returns a non-NULL valid
  385. /// valid pointer.
  386. ///
  387. /// \throw none
  388. const ZoneNode* getOriginNode() const {
  389. return (origin_node_.get());
  390. }
  391. /// \brief Return the zone's name space in the form of \c ZoneTree
  392. ///
  393. /// \note It's intentional that non-const version of this method
  394. /// isn't provided. See the class description.
  395. ///
  396. /// \throw none
  397. const ZoneTree& getZoneTree() const { return (*zone_tree_); }
  398. /// \brief Return whether or not the zone is signed in terms of DNSSEC.
  399. ///
  400. /// Note that this class does not care about what "signed" means.
  401. /// This method simply returns the last value set by \c setSigned()
  402. /// (or the default, which is \c false). The caller is expected to
  403. /// use this method and \c setSigned() in a reasonable, consistent way.
  404. ///
  405. /// \throw none
  406. bool isSigned() const { return (origin_node_->getFlag(DNSSEC_SIGNED)); }
  407. /// \brief Return whether or not the zone is signed with NSEC3 RRs.
  408. ///
  409. /// In the current implementation, the zone is considered signed with
  410. /// NSEC3 if and only if it has non-NULL NSEC3 data.
  411. ///
  412. /// This also means it's not considered NSEC3 signed by default.
  413. ///
  414. /// \throw none
  415. bool isNSEC3Signed() const { return (nsec3_data_); }
  416. /// \brief Return NSEC3Data of the zone.
  417. ///
  418. /// This method returns non-NULL valid pointer to \c NSEC3Data object
  419. /// associated to the \c ZoneData if it was set by \c setNSEC3Data();
  420. /// otherwise it returns NULL.
  421. ///
  422. /// \throw none
  423. const NSEC3Data* getNSEC3Data() const { return (nsec3_data_.get()); }
  424. //@}
  425. ///
  426. /// \name Methods for modifying the tree
  427. ///
  428. //@{
  429. /// \brief Insert a name to the zone.
  430. ///
  431. /// It allocates resource for the given name in the internal storage
  432. /// for zone data, and returns an access point to it in the form of
  433. /// \c ZoneNode pointer via the given \c node variable. If the name
  434. /// already exists in the name space, it returns a pointer to the existing
  435. /// node.
  436. ///
  437. /// The name to be inserted by this method is expected to belong to
  438. /// zone's "normal" (i.e., non-NSEÇ3) name space. If it's a name for
  439. /// an NSEC3 RR, it must be set in the corresponding \c NSEC3Data for
  440. /// this zone data (if it doesn't exist it must be created and set
  441. /// by \c setNSEC3Data()).
  442. ///
  443. /// The name is also expected to be a subdomain of, or equal to the
  444. /// zone's origin name (specified on creation in \c create()), but
  445. /// this method does not check that condition. The caller is responsible
  446. /// for ensuring this assumption.
  447. ///
  448. /// Since this method doesn't perform any semantics check, it always
  449. /// succeeds (except for the rare case where memory allocation
  450. /// fails) and \c node will be set to a valid pointer.
  451. ///
  452. /// \note We may want to differentiate between the case where the name is
  453. /// newly created and the case where it already existed. Right now it's
  454. /// unclear, so it doesn't return this information. If we see the need
  455. /// for it, this method can be extended that way.
  456. ///
  457. /// \throw std::bad_alloc Memory allocation fails
  458. ///
  459. /// \param mem_sgmt Memory segment in which resource for the new memory
  460. /// is to be allocated.
  461. /// \param name The name to be inserted.
  462. /// \param node A pointer to \c ZoneNode pointer in which the created or
  463. /// found node for the name is stored. Must not be NULL (the method does
  464. /// not check that condition).
  465. void insertName(util::MemorySegment& mem_sgmt, const dns::Name& name,
  466. ZoneNode** node);
  467. /// \brief Specify whether or not the zone is signed in terms of DNSSEC.
  468. ///
  469. /// The zone will be considered "signed" (in that subsequent calls to
  470. /// \c isSigned() will return \c true) iff the parameter \c on is \c true.
  471. ///
  472. /// This class does not care what "signed" actually means; it does not
  473. /// check any zone RRs to verify if the given state makes sense (e.g.
  474. /// whether the zone has a DNSKEY RR at the origin). The caller is
  475. /// expected to use this method and \c isSigned() in a reasonable,
  476. /// consistent way.
  477. ///
  478. /// \throw none
  479. void setSigned(bool on) {
  480. origin_node_->setFlag(DNSSEC_SIGNED, on);
  481. }
  482. /// \brief Return NSEC3Data of the zone, non-const version.
  483. ///
  484. /// This is similar to the const version, but return a non-const pointer
  485. /// so the caller can modify the content.
  486. ///
  487. /// \throw none
  488. NSEC3Data* getNSEC3Data() { return (nsec3_data_.get()); }
  489. /// \brief Associate \c NSEC3Data to the zone.
  490. ///
  491. /// This method associates the given \c NSEC3Data object with the zone
  492. /// data. If there was already associated \c NSEC3Data object, it will
  493. /// be returned. If no \c NSEC3Data object was associated before,
  494. /// a NULL pointer will be returned. \c nsec3_data can be NULL, in which
  495. /// case the zone will be disassociated with a \c NSEC3Data.
  496. ///
  497. /// In general, if a non-NULL pointer is passed, it's assumed that
  498. /// the \c NSEC3Data object was allocated in the same \c MemorySegment
  499. /// as that for the zone data, so the \c destroy() method can destroy
  500. /// both with the same memory segment. If this condition is not met,
  501. /// the caller must extract the associated \c NSEC3Data by calling
  502. /// this method with NULL and release any resource for it by itself
  503. /// before destroying this zone data.
  504. ///
  505. /// \throw none
  506. ///
  507. /// \param nsec3_data A pointer to \c NSEC3Data object to be associated
  508. /// with the zone. Can be NULL.
  509. /// \return Previously associated \c NSEC3Data object in the zone. This
  510. /// can be NULL.
  511. NSEC3Data* setNSEC3Data(NSEC3Data* nsec3_data) {
  512. NSEC3Data* old = nsec3_data_.get();
  513. nsec3_data_ = nsec3_data;
  514. return (old);
  515. }
  516. //@}
  517. private:
  518. const boost::interprocess::offset_ptr<ZoneTree> zone_tree_;
  519. const boost::interprocess::offset_ptr<ZoneNode> origin_node_;
  520. boost::interprocess::offset_ptr<NSEC3Data> nsec3_data_;
  521. };
  522. } // namespace memory
  523. } // namespace datasrc
  524. } // namespace isc
  525. #endif // DATASRC_MEMORY_ZONE_DATA_H
  526. // Local Variables:
  527. // mode: c++
  528. // End: