zone_data.h 25 KB

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