zone.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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 __ZONE_H
  15. #define __ZONE_H 1
  16. #include <dns/rrset.h>
  17. #include <dns/rrsetlist.h>
  18. #include <datasrc/result.h>
  19. namespace isc {
  20. namespace datasrc {
  21. /// \brief The base class to search a zone for RRsets
  22. ///
  23. /// The \c ZoneFinder class is an abstract base class for representing
  24. /// an object that performs DNS lookups in a specific zone accessible via
  25. /// a data source. In general, different types of data sources (in-memory,
  26. /// database-based, etc) define their own derived classes of \c ZoneFinder,
  27. /// implementing ways to retrieve the required data through the common
  28. /// interfaces declared in the base class. Each concrete \c ZoneFinder
  29. /// object is therefore (conceptually) associated with a specific zone
  30. /// of one specific data source instance.
  31. ///
  32. /// The origin name and the RR class of the associated zone are available
  33. /// via the \c getOrigin() and \c getClass() methods, respectively.
  34. ///
  35. /// The most important method of this class is \c find(), which performs
  36. /// the lookup for a given domain and type. See the description of the
  37. /// method for details.
  38. ///
  39. /// \note It's not clear whether we should request that a zone finder form a
  40. /// "transaction", that is, whether to ensure the finder is not susceptible
  41. /// to changes made by someone else than the creator of the finder. If we
  42. /// don't request that, for example, two different lookup results for the
  43. /// same name and type can be different if other threads or programs make
  44. /// updates to the zone between the lookups. We should revisit this point
  45. /// as we gain more experiences.
  46. class ZoneFinder {
  47. public:
  48. /// Result codes of the \c find() method.
  49. ///
  50. /// Note: the codes are tentative. We may need more, or we may find
  51. /// some of them unnecessary as we implement more details.
  52. ///
  53. /// Some are synonyms of others in terms of RCODE returned to user.
  54. /// But they help the logic to decide if it should ask for a NSEC
  55. /// that covers something or not (for example, in case of NXRRSET,
  56. /// the directly returned NSEC is sufficient, but with wildcard one,
  57. /// we need to add one proving there's no exact match and this is
  58. /// actually the best wildcard we have). Data sources that don't
  59. /// support DNSSEC don't need to distinguish them.
  60. ///
  61. /// In case of CNAME, if the CNAME is a wildcard (i.e., its owner name
  62. /// starts with the label "*"), WILDCARD_CNAME will be returned instead
  63. /// of CNAME.
  64. ///
  65. /// In case of NXDOMAIN, the returned NSEC covers the queried domain
  66. /// that proves that the query name does not exist in the zone. Note that
  67. /// this does not necessarily prove it doesn't even match a wildcard
  68. /// (even if the result of NXDOMAIN can only happen when there's no
  69. /// matching wildcard either). It is caller's responsibility to provide
  70. /// a proof that there is no matching wildcard if that proof is necessary.
  71. ///
  72. /// Various variants of "no data" cases are complicated, when involves
  73. /// DNSSEC and wildcard processing. Referring to Section 3.1.3 of
  74. /// RFC4035, we need to consider the following cases:
  75. /// -# (Normal) no data: there is a matching non-wildcard name with a
  76. /// different RR type. This is the "No Data" case of the RFC.
  77. /// -# (Normal) empty non terminal: there is no matching (exact or
  78. /// wildcard) name, but there is a subdomain with an RR of the query
  79. /// name. This is one case of "Name Error" of the RFC.
  80. /// -# Wildcard empty non terminal: similar to 2a, but the empty name
  81. /// is a wildcard, and matches the query name by wildcard expansion.
  82. /// This is a special case of "Name Error" of the RFC.
  83. /// -# Wildcard no data: there is no exact match name, but there is a
  84. /// wildcard name that matches the query name with a different type
  85. /// of RR. This is the "Wildcard No Data" case of the RFC.
  86. ///
  87. /// In any case, \c find() will result in \c NXRRSET with no RRset
  88. /// unless the \c FIND_DNSSEC option is specified. The rest of the
  89. /// discussion only applies to the case where this option is specified.
  90. ///
  91. /// In case 1, \c find() will result in NXRRSET, and return NSEC of the
  92. /// matching name.
  93. ///
  94. /// In case 2, \c find() will result in NXRRSET, and return NSEC for the
  95. /// interval where the empty nonterminal lives. The end of the interval
  96. /// is the subdomain causing existence of the empty nonterminal (if
  97. /// there's sub.x.example.com, and no record in x.example.com, then
  98. /// x.example.com exists implicitly - is the empty nonterminal and
  99. /// sub.x.example.com is the subdomain causing it). Note that this NSEC
  100. /// proves not only the existence of empty non terminal name but also
  101. /// the non existence of possibly matching wildcard name, because
  102. /// there can be no better wildcard match than the exact matching empty
  103. /// name.
  104. ///
  105. /// In case 3, \c find() will result in WILDCARD_NXRRSET, and return NSEC
  106. /// for the interval where the wildcard empty nonterminal lives.
  107. /// Cases 2 and 3 are especially complicated and confusing. See the
  108. /// examples below.
  109. ///
  110. /// In case 4, \c find() will result in WILDCARD_NXRRSET, and return
  111. /// NSEC of the matching wildcard name.
  112. ///
  113. /// Examples: if zone "example.com" has the following record:
  114. /// \code
  115. /// a.example.com. NSEC a.b.example.com.
  116. /// \endcode
  117. /// a call to \c find() for "b.example.com." with the FIND_DNSSEC option
  118. /// will result in NXRRSET, and this NSEC will be returned.
  119. /// Likewise, if zone "example.org" has the following record,
  120. /// \code
  121. /// a.example.org. NSEC x.*.b.example.org.
  122. /// \endcode
  123. /// a call to \c find() for "y.b.example.org" with FIND_DNSSEC will
  124. /// result in NXRRSET_NXRRSET, and this NSEC will be returned.
  125. enum Result {
  126. SUCCESS, ///< An exact match is found.
  127. DELEGATION, ///< The search encounters a zone cut.
  128. NXDOMAIN, ///< There is no domain name that matches the search name
  129. NXRRSET, ///< There is a matching name but no RRset of the search type
  130. CNAME, ///< The search encounters and returns a CNAME RR
  131. DNAME, ///< The search encounters and returns a DNAME RR
  132. WILDCARD, ///< Succes by wildcard match, for DNSSEC
  133. WILDCARD_CNAME, ///< CNAME on wildcard, search returns CNAME, for DNSSEC
  134. WILDCARD_NXRRSET ///< NXRRSET on wildcard, for DNSSEC
  135. };
  136. /// A helper structure to represent the search result of \c find().
  137. ///
  138. /// This is a straightforward tuple of the result code and a pointer
  139. /// to the found RRset to represent the result of \c find()
  140. /// (there will be more members in the future - see the class
  141. /// description).
  142. /// We use this in order to avoid overloading the return value for both
  143. /// the result code ("success" or "not found") and the found object,
  144. /// i.e., avoid using \c NULL to mean "not found", etc.
  145. ///
  146. /// This is a simple value class whose internal state never changes,
  147. /// so for convenience we allow the applications to refer to the members
  148. /// directly.
  149. ///
  150. /// Note: we should eventually include a notion of "zone node", which
  151. /// corresponds to a particular domain name of the zone, so that we can
  152. /// find RRsets of a different RR type for that name (e.g. for type ANY
  153. /// query or to include DS RRs with delegation).
  154. ///
  155. /// Note: we may also want to include the closest enclosure "node" to
  156. /// optimize including the NSEC for no-wildcard proof (FWIW NSD does that).
  157. struct FindResult {
  158. FindResult(Result param_code,
  159. const isc::dns::ConstRRsetPtr param_rrset) :
  160. code(param_code), rrset(param_rrset)
  161. {}
  162. const Result code;
  163. const isc::dns::ConstRRsetPtr rrset;
  164. };
  165. /// Find options.
  166. ///
  167. /// The option values are used as a parameter for \c find().
  168. /// These are values of a bitmask type. Bitwise operations can be
  169. /// performed on these values to express compound options.
  170. enum FindOptions {
  171. FIND_DEFAULT = 0, ///< The default options
  172. FIND_GLUE_OK = 1, ///< Allow search under a zone cut
  173. FIND_DNSSEC = 2, ///< Require DNSSEC data in the answer
  174. ///< (RRSIG, NSEC, etc.). The implementation
  175. ///< is allowed to include it even if it is
  176. ///< not set.
  177. NO_WILDCARD = 4 ///< Do not try wildcard matching.
  178. };
  179. ///
  180. /// \name Constructors and Destructor.
  181. ///
  182. //@{
  183. protected:
  184. /// The default constructor.
  185. ///
  186. /// This is intentionally defined as \c protected as this base class should
  187. /// never be instantiated (except as part of a derived class).
  188. ZoneFinder() {}
  189. public:
  190. /// The destructor.
  191. virtual ~ZoneFinder() {}
  192. //@}
  193. ///
  194. /// \name Getter Methods
  195. ///
  196. /// These methods should never throw an exception.
  197. //@{
  198. /// Return the origin name of the zone.
  199. virtual isc::dns::Name getOrigin() const = 0;
  200. /// Return the RR class of the zone.
  201. virtual isc::dns::RRClass getClass() const = 0;
  202. //@}
  203. ///
  204. /// \name Search Methods
  205. ///
  206. //@{
  207. /// Search the zone for a given pair of domain name and RR type.
  208. ///
  209. /// Each derived version of this method searches the underlying backend
  210. /// for the data that best matches the given name and type.
  211. /// This method is expected to be "intelligent", and identifies the
  212. /// best possible answer for the search key. Specifically,
  213. ///
  214. /// - If the search name belongs under a zone cut, it returns the code
  215. /// of \c DELEGATION and the NS RRset at the zone cut.
  216. /// - If there is no matching name, it returns the code of \c NXDOMAIN,
  217. /// and, if DNSSEC is requested, the NSEC RRset that proves the
  218. /// non-existence.
  219. /// - If there is a matching name but no RRset of the search type, it
  220. /// returns the code of \c NXRRSET, and, if DNSSEC is required,
  221. /// the NSEC RRset for that name.
  222. /// - If there is a CNAME RR of the searched name but there is no
  223. /// RR of the searched type of the name (so this type is different from
  224. /// CNAME), it returns the code of \c CNAME and that CNAME RR.
  225. /// Note that if the searched RR type is CNAME, it is considered
  226. /// a successful match, and the code of \c SUCCESS will be returned.
  227. /// - If the search name matches a delegation point of DNAME, it returns
  228. /// the code of \c DNAME and that DNAME RR.
  229. /// - If the target isn't NULL, all RRsets under the domain are inserted
  230. /// there and SUCCESS (or NXDOMAIN, in case of empty domain) is returned
  231. /// instead of normall processing. This is intended to handle ANY query.
  232. ///
  233. /// \note This behavior is controversial as we discussed in
  234. /// https://lists.isc.org/pipermail/bind10-dev/2011-January/001918.html
  235. /// We should revisit the interface before we heavily rely on it.
  236. ///
  237. /// The \c options parameter specifies customized behavior of the search.
  238. /// Their semantics is as follows (they are or bit-field):
  239. ///
  240. /// - \c FIND_GLUE_OK Allow search under a zone cut. By default the search
  241. /// will stop once it encounters a zone cut. If this option is specified
  242. /// it remembers information about the highest zone cut and continues
  243. /// the search until it finds an exact match for the given name or it
  244. /// detects there is no exact match. If an exact match is found,
  245. /// RRsets for that name are searched just like the normal case;
  246. /// otherwise, if the search has encountered a zone cut, \c DELEGATION
  247. /// with the information of the highest zone cut will be returned.
  248. /// - \c FIND_DNSSEC Request that DNSSEC data (like NSEC, RRSIGs) are
  249. /// returned with the answer. It is allowed for the data source to
  250. /// include them even when not requested.
  251. /// - \c NO_WILDCARD Do not try wildcard matching. This option is of no
  252. /// use for normal lookups; it's intended to be used to get a DNSSEC
  253. /// proof of the non existence of any matching wildcard or non existence
  254. /// of an exact match when a wildcard match is found.
  255. ///
  256. /// A derived version of this method may involve internal resource
  257. /// allocation, especially for constructing the resulting RRset, and may
  258. /// throw an exception if it fails.
  259. /// It throws DuplicateRRset exception if there are duplicate rrsets under
  260. /// the same domain.
  261. /// It should not throw other types of exceptions.
  262. ///
  263. /// \param name The domain name to be searched for.
  264. /// \param type The RR type to be searched for.
  265. /// \param target If target is not NULL, insert all RRs under the domain
  266. /// into it.
  267. /// \param options The search options.
  268. /// \return A \c FindResult object enclosing the search result (see above).
  269. virtual FindResult find(const isc::dns::Name& name,
  270. const isc::dns::RRType& type,
  271. isc::dns::RRsetList* target = NULL,
  272. const FindOptions options
  273. = FIND_DEFAULT) = 0;
  274. /// \brief Get previous name in the zone
  275. ///
  276. /// Gets the previous name in the DNSSEC order. This can be used
  277. /// to find the correct NSEC records for proving nonexistence
  278. /// of domains.
  279. ///
  280. /// The concrete implementation might throw anything it thinks appropriate,
  281. /// however it is recommended to stick to the ones listed here. The user
  282. /// of this method should be able to handle any exceptions.
  283. ///
  284. /// This method does not include under-zone-cut data (glue data).
  285. ///
  286. /// \param query The name for which one we look for a previous one. The
  287. /// queried name doesn't have to exist in the zone.
  288. /// \return The preceding name
  289. ///
  290. /// \throw NotImplemented in case the data source backend doesn't support
  291. /// DNSSEC or there is no previous in the zone (NSEC records might be
  292. /// missing in the DB, the queried name is less or equal to the apex).
  293. /// \throw DataSourceError for low-level or internal datasource errors
  294. /// (like broken connection to database, wrong data living there).
  295. /// \throw std::bad_alloc For allocation errors.
  296. virtual isc::dns::Name findPreviousName(const isc::dns::Name& query)
  297. const = 0;
  298. //@}
  299. };
  300. /// \brief Operator to combine FindOptions
  301. ///
  302. /// We would need to manually static-cast the options if we put or
  303. /// between them, which is undesired with bit-flag options. Therefore
  304. /// we hide the cast here, which is the simplest solution and it still
  305. /// provides reasonable level of type safety.
  306. inline ZoneFinder::FindOptions operator |(ZoneFinder::FindOptions a,
  307. ZoneFinder::FindOptions b)
  308. {
  309. return (static_cast<ZoneFinder::FindOptions>(static_cast<unsigned>(a) |
  310. static_cast<unsigned>(b)));
  311. }
  312. /// \brief A pointer-like type pointing to a \c ZoneFinder object.
  313. typedef boost::shared_ptr<ZoneFinder> ZoneFinderPtr;
  314. /// \brief A pointer-like type pointing to a \c ZoneFinder object.
  315. typedef boost::shared_ptr<const ZoneFinder> ConstZoneFinderPtr;
  316. /// The base class to make updates to a single zone.
  317. ///
  318. /// On construction, each derived class object will start a "transaction"
  319. /// for making updates to a specific zone (this means a constructor of
  320. /// a derived class would normally take parameters to identify the zone
  321. /// to be updated). The underlying realization of a "transaction" will differ
  322. /// for different derived classes; if it uses a general purpose database
  323. /// as a backend, it will involve performing some form of "begin transaction"
  324. /// statement for the database.
  325. ///
  326. /// Updates (adding or deleting RRs) are made via \c addRRset() and
  327. /// \c deleteRRset() methods. Until the \c commit() method is called the
  328. /// changes are local to the updater object. For example, they won't be
  329. /// visible via a \c ZoneFinder object except the one returned by the
  330. /// updater's own \c getFinder() method. The \c commit() completes the
  331. /// transaction and makes the changes visible to others.
  332. ///
  333. /// This class does not provide an explicit "rollback" interface. If
  334. /// something wrong or unexpected happens during the updates and the
  335. /// caller wants to cancel the intermediate updates, the caller should
  336. /// simply destruct the updater object without calling \c commit().
  337. /// The destructor is supposed to perform the "rollback" operation,
  338. /// depending on the internal details of the derived class.
  339. ///
  340. /// \note This initial implementation provides a quite simple interface of
  341. /// adding and deleting RRs (see the description of the related methods).
  342. /// It may be revisited as we gain more experiences.
  343. class ZoneUpdater {
  344. protected:
  345. /// The default constructor.
  346. ///
  347. /// This is intentionally defined as protected to ensure that this base
  348. /// class is never instantiated directly.
  349. ZoneUpdater() {}
  350. public:
  351. /// The destructor
  352. ///
  353. /// Each derived class implementation must ensure that if \c commit()
  354. /// has not been performed by the time of the call to it, then it
  355. /// "rollbacks" the updates made via the updater so far.
  356. virtual ~ZoneUpdater() {}
  357. /// Return a finder for the zone being updated.
  358. ///
  359. /// The returned finder provides the functionalities of \c ZoneFinder
  360. /// for the zone as updates are made via the updater. That is, before
  361. /// making any update, the finder will be able to find all RRsets that
  362. /// exist in the zone at the time the updater is created. If RRsets
  363. /// are added or deleted via \c addRRset() or \c deleteRRset(),
  364. /// this finder will find the added ones or miss the deleted ones
  365. /// respectively.
  366. ///
  367. /// The finder returned by this method is effective only while the updates
  368. /// are performed, i.e., from the construction of the corresponding
  369. /// updater until \c commit() is performed or the updater is destructed
  370. /// without commit. The result of a subsequent call to this method (or
  371. /// the use of the result) after that is undefined.
  372. ///
  373. /// \return A reference to a \c ZoneFinder for the updated zone
  374. virtual ZoneFinder& getFinder() = 0;
  375. /// Add an RRset to a zone via the updater
  376. ///
  377. /// This may be revisited in a future version, but right now the intended
  378. /// behavior of this method is simple: It "naively" adds the specified
  379. /// RRset to the zone specified on creation of the updater.
  380. /// It performs minimum level of validation on the specified RRset:
  381. /// - Whether the RR class is identical to that for the zone to be updated
  382. /// - Whether the RRset is not empty, i.e., it has at least one RDATA
  383. /// - Whether the RRset is not associated with an RRSIG, i.e.,
  384. /// whether \c getRRsig() on the RRset returns a NULL pointer.
  385. ///
  386. /// and otherwise does not check any oddity. For example, it doesn't
  387. /// check whether the owner name of the specified RRset is a subdomain
  388. /// of the zone's origin; it doesn't care whether or not there is already
  389. /// an RRset of the same name and RR type in the zone, and if there is,
  390. /// whether any of the existing RRs have duplicate RDATA with the added
  391. /// ones. If these conditions matter the calling application must examine
  392. /// the existing data beforehand using the \c ZoneFinder returned by
  393. /// \c getFinder().
  394. ///
  395. /// The validation requirement on the associated RRSIG is temporary.
  396. /// If we find it more reasonable and useful to allow adding a pair of
  397. /// RRset and its RRSIG RRset as we gain experiences with the interface,
  398. /// we may remove this restriction. Until then we explicitly check it
  399. /// to prevent accidental misuse.
  400. ///
  401. /// Conceptually, on successful call to this method, the zone will have
  402. /// the specified RRset, and if there is already an RRset of the same
  403. /// name and RR type, these two sets will be "merged". "Merged" means
  404. /// that a subsequent call to \c ZoneFinder::find() for the name and type
  405. /// will result in success and the returned RRset will contain all
  406. /// previously existing and newly added RDATAs with the TTL being the
  407. /// minimum of the two RRsets. The underlying representation of the
  408. /// "merged" RRsets may vary depending on the characteristic of the
  409. /// underlying data source. For example, if it uses a general purpose
  410. /// database that stores each RR of the same RRset separately, it may
  411. /// simply be a larger sets of RRs based on both the existing and added
  412. /// RRsets; the TTLs of the RRs may be different within the database, and
  413. /// there may even be duplicate RRs in different database rows. As long
  414. /// as the RRset returned via \c ZoneFinder::find() conforms to the
  415. /// concept of "merge", the actual internal representation is up to the
  416. /// implementation.
  417. ///
  418. /// This method must not be called once commit() is performed. If it
  419. /// calls after \c commit() the implementation must throw a
  420. /// \c DataSourceError exception.
  421. ///
  422. /// If journaling was requested when getting this updater, it might reject
  423. /// to add the RRset if the squence doesn't look like and IXFR. In such
  424. /// case isc::BadValue is thrown.
  425. ///
  426. /// \todo As noted above we may have to revisit the design details as we
  427. /// gain experiences:
  428. ///
  429. /// - we may want to check (and maybe reject) if there is already a
  430. /// duplicate RR (that has the same RDATA).
  431. /// - we may want to check (and maybe reject) if there is already an
  432. /// RRset of the same name and RR type with different TTL
  433. /// - we may even want to check if there is already any RRset of the
  434. /// same name and RR type.
  435. /// - we may want to add an "options" parameter that can control the
  436. /// above points
  437. /// - we may want to have this method return a value containing the
  438. /// information on whether there's a duplicate, etc.
  439. ///
  440. /// \exception DataSourceError Called after \c commit(), RRset is invalid
  441. /// (see above), internal data source error
  442. /// \exception isc::BadValue Journaling is enabled and the current RRset
  443. /// doesn't fit into the IXFR sequence (see above).
  444. /// \exception std::bad_alloc Resource allocation failure
  445. ///
  446. /// \param rrset The RRset to be added
  447. virtual void addRRset(const isc::dns::RRset& rrset) = 0;
  448. /// Delete an RRset from a zone via the updater
  449. ///
  450. /// Like \c addRRset(), the detailed semantics and behavior of this method
  451. /// may have to be revisited in a future version. The following are
  452. /// based on the initial implementation decisions.
  453. ///
  454. /// On successful completion of this method, it will remove from the zone
  455. /// the RRs of the specified owner name and RR type that match one of
  456. /// the RDATAs of the specified RRset. There are several points to be
  457. /// noted:
  458. /// - Existing RRs that don't match any of the specified RDATAs will
  459. /// remain in the zone.
  460. /// - Any RRs of the specified RRset that doesn't exist in the zone will
  461. /// simply be ignored; the implementation of this method is not supposed
  462. /// to check that condition.
  463. /// - The TTL of the RRset is ignored; matching is only performed by
  464. /// the owner name, RR type and RDATA
  465. ///
  466. /// Ignoring the TTL may not look sensible, but it's based on the
  467. /// observation that it will result in more intuitive result, especially
  468. /// when the underlying data source is a general purpose database.
  469. /// See also \c DatabaseAccessor::deleteRecordInZone() on this point.
  470. /// It also matches the dynamic update protocol (RFC2136), where TTLs
  471. /// are ignored when deleting RRs.
  472. ///
  473. /// \note Since the TTL is ignored, this method could take the RRset
  474. /// to be deleted as a tuple of name, RR type, and a list of RDATAs.
  475. /// But in practice, it's quite likely that the caller has the RRset
  476. /// in the form of the \c RRset object (e.g., extracted from a dynamic
  477. /// update request message), so this interface would rather be more
  478. /// convenient. If it turns out not to be true we can change or extend
  479. /// the method signature.
  480. ///
  481. /// This method performs minimum level of validation on the specified
  482. /// RRset:
  483. /// - Whether the RR class is identical to that for the zone to be updated
  484. /// - Whether the RRset is not empty, i.e., it has at least one RDATA
  485. /// - Whether the RRset is not associated with an RRSIG, i.e.,
  486. /// whether \c getRRsig() on the RRset returns a NULL pointer.
  487. ///
  488. /// This method must not be called once commit() is performed. If it
  489. /// calls after \c commit() the implementation must throw a
  490. /// \c DataSourceError exception.
  491. ///
  492. /// If journaling was requested when getting this updater, it might reject
  493. /// to add the RRset if the squence doesn't look like and IXFR. In such
  494. /// case isc::BadValue is thrown.
  495. ///
  496. /// \todo As noted above we may have to revisit the design details as we
  497. /// gain experiences:
  498. ///
  499. /// - we may want to check (and maybe reject) if some or all of the RRs
  500. /// for the specified RRset don't exist in the zone
  501. /// - we may want to allow an option to "delete everything" for specified
  502. /// name and/or specified name + RR type.
  503. /// - as mentioned above, we may want to include the TTL in matching the
  504. /// deleted RRs
  505. /// - we may want to add an "options" parameter that can control the
  506. /// above points
  507. /// - we may want to have this method return a value containing the
  508. /// information on whether there's any RRs that are specified but don't
  509. /// exit, the number of actually deleted RRs, etc.
  510. ///
  511. /// \exception DataSourceError Called after \c commit(), RRset is invalid
  512. /// (see above), internal data source error
  513. /// \exception isc::BadValue Journaling is enabled and the current RRset
  514. /// doesn't fit into the IXFR sequence (see above).
  515. /// \exception std::bad_alloc Resource allocation failure
  516. ///
  517. /// \param rrset The RRset to be deleted
  518. virtual void deleteRRset(const isc::dns::RRset& rrset) = 0;
  519. /// Commit the updates made in the updater to the zone
  520. ///
  521. /// This method completes the "transaction" started at the creation
  522. /// of the updater. After successful completion of this method, the
  523. /// updates will be visible outside the scope of the updater.
  524. /// The actual internal behavior will defer for different derived classes.
  525. /// For a derived class with a general purpose database as a backend,
  526. /// for example, this method would perform a "commit" statement for the
  527. /// database.
  528. ///
  529. /// This operation can only be performed at most once. A duplicate call
  530. /// must result in a DatasourceError exception.
  531. ///
  532. /// \exception DataSourceError Duplicate call of the method,
  533. /// internal data source error
  534. /// \exception isc::BadValue Journaling is enabled and the update is not
  535. /// complete IXFR sequence.
  536. virtual void commit() = 0;
  537. };
  538. /// \brief A pointer-like type pointing to a \c ZoneUpdater object.
  539. typedef boost::shared_ptr<ZoneUpdater> ZoneUpdaterPtr;
  540. } // end of datasrc
  541. } // end of isc
  542. #endif // __ZONE_H
  543. // Local Variables:
  544. // mode: c++
  545. // End: