memfile_lease_mgr.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. // Copyright (C) 2012-2015 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 MEMFILE_LEASE_MGR_H
  15. #define MEMFILE_LEASE_MGR_H
  16. #include <asiolink/interval_timer.h>
  17. #include <dhcp/hwaddr.h>
  18. #include <dhcpsrv/csv_lease_file4.h>
  19. #include <dhcpsrv/csv_lease_file6.h>
  20. #include <dhcpsrv/memfile_lease_storage.h>
  21. #include <dhcpsrv/lease_mgr.h>
  22. #include <util/process_spawn.h>
  23. #include <boost/scoped_ptr.hpp>
  24. #include <boost/shared_ptr.hpp>
  25. namespace isc {
  26. namespace dhcp {
  27. class LFCSetup;
  28. /// @brief Concrete implementation of a lease database backend using flat file.
  29. ///
  30. /// This class implements a lease database backend using CSV files to store
  31. /// DHCPv4 and DHCPv6 leases on disk. The format of the files is determined
  32. /// by the @c CSVLeaseFile4 and @c CSVLeaseFile6 classes.
  33. ///
  34. /// In order to obtain good performance, the backend stores leases
  35. /// incrementally, i.e. updates to leases are appended at the end of the lease
  36. /// file. To record the deletion of a lease, the lease record is appended to
  37. /// the lease file with the valid lifetime set to 0. However, this may result
  38. /// in a significant growth of the lease file size over time, because the lease
  39. /// file will contain many entries for each lease. In order to mitigate this
  40. /// problem, the backend implements the Lease File Cleanup mechanism which is
  41. /// described on the Kea wiki: http://kea.isc.org/wiki/LFCDesign.
  42. ///
  43. /// The backend installs an @c asiolink::IntervalTimer to periodically execute
  44. /// the @c Memfile_LeaseMgr::lfcCallback. This callback function controls
  45. /// the startup of the background process which removes redundant information
  46. /// from the lease file(s). Note that the @c asiolink::IntervalTimer uses
  47. /// @c asiolink::IOService to execute the callback. The @c LeaseMgr class
  48. /// creates this object, which can be obtained by the caller using the
  49. /// @c LeaseMgr::getIOService. The caller should later call an appropriate
  50. /// method, @c asio::io_service::poll_one to execute the callback when
  51. /// the timer is ready.
  52. ///
  53. /// When the backend is starting up, it reads leases from the lease file (one
  54. /// by one) and adds them to the in-memory container as follows:
  55. /// - if the lease record being parsed identifies a lease which is not present
  56. /// in the container, and the lease has valid lifetime greater than 0,
  57. /// the lease is added to the container,
  58. /// - if the lease record being parsed identifies a lease which is present in
  59. /// the container, and the valid lifetime of the lease record being parsed is
  60. /// greater than 0, the lease in the container is updated
  61. /// - if the lease record being parsed has valid lifetime equal to 0, and the
  62. /// corresponding lease exists in the container, the lease is removed from
  63. /// the container.
  64. ///
  65. /// After the container holding leases is initialized, each subsequent update,
  66. /// removal or addition of the lease is appended to the lease file
  67. /// synchronously.
  68. ///
  69. /// Originally, the Memfile backend didn't write leases to disk. This was
  70. /// particularly useful for testing server performance in non-disk bound
  71. /// conditions. In order to preserve this capability, the new parameter
  72. /// "persist=true|false" has been introduced in the database access string.
  73. /// For example, database access string: "type=memfile persist=true"
  74. /// enables writes of leases to a disk.
  75. ///
  76. /// The lease file locations can be specified with the "name=[path]"
  77. /// parameter in the database access string. The [path] is the
  78. /// absolute path to the file (including file name). If this parameter
  79. /// is not specified, the default location in the installation
  80. /// directory is used: var/kea/kea-leases4.csv and
  81. /// var/kea/kea-leases6.csv.
  82. class Memfile_LeaseMgr : public LeaseMgr {
  83. public:
  84. /// @defgroup versions Specified memfile backend version.
  85. ///
  86. /// @brief Defines major version of the memfile backend.
  87. ///
  88. /// Version history:
  89. /// 1.0 - initial version (released in Kea 0.9)
  90. /// 2.0 - hwaddr column added (to be released in Kea 0.9.1)
  91. ///
  92. /// @{
  93. static const int MAJOR_VERSION = 2;
  94. /// Defines minor version of the memfile backend.
  95. static const int MINOR_VERSION = 0;
  96. /// @}
  97. /// @brief Specifies universe (V4, V6)
  98. ///
  99. /// This enumeration is used by various functions in Memfile %Lease Manager,
  100. /// to identify the lease type referred to. In particular, it is used by
  101. /// functions operating on the lease files to distinguish between lease
  102. /// files for DHCPv4 and DHCPv6.
  103. enum Universe {
  104. V4,
  105. V6
  106. };
  107. /// @name Methods implementing the API of the lease database backend.
  108. /// The following methods are implementing the API of the
  109. /// @c LeaseMgr to manage leases.
  110. //@{
  111. /// @brief The sole lease manager constructor
  112. ///
  113. /// dbconfig is a generic way of passing parameters. Parameters
  114. /// are passed in the "name=value" format, separated by spaces.
  115. /// Values may be enclosed in double quotes, if needed.
  116. ///
  117. /// @param parameters A data structure relating keywords and values
  118. /// concerned with the database.
  119. Memfile_LeaseMgr(const ParameterMap& parameters);
  120. /// @brief Destructor (closes file)
  121. virtual ~Memfile_LeaseMgr();
  122. /// @brief Adds an IPv4 lease.
  123. ///
  124. /// @param lease lease to be added
  125. virtual bool addLease(const Lease4Ptr& lease);
  126. /// @brief Adds an IPv6 lease.
  127. ///
  128. /// @param lease lease to be added
  129. virtual bool addLease(const Lease6Ptr& lease);
  130. /// @brief Returns existing IPv4 lease for specified IPv4 address.
  131. ///
  132. /// This function returns a copy of the lease. The modification in the
  133. /// return lease does not affect the instance held in the lease storage.
  134. ///
  135. /// @param addr An address of the searched lease.
  136. ///
  137. /// @return a collection of leases
  138. virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress& addr) const;
  139. /// @brief Returns existing IPv4 leases for specified hardware address.
  140. ///
  141. /// Although in the usual case there will be only one lease, for mobile
  142. /// clients or clients with multiple static/fixed/reserved leases there
  143. /// can be more than one. Thus return type is a container, not a single
  144. /// pointer.
  145. ///
  146. /// @param hwaddr hardware address of the client
  147. ///
  148. /// @return lease collection
  149. virtual Lease4Collection getLease4(const isc::dhcp::HWAddr& hwaddr) const;
  150. /// @brief Returns existing IPv4 lease for specified hardware address
  151. /// and a subnet
  152. ///
  153. /// This function returns a copy of the lease. The modification in the
  154. /// return lease does not affect the instance held in the lease storage.
  155. ///
  156. /// There can be at most one lease for a given HW address in a single
  157. /// pool, so this method with either return a single lease or NULL.
  158. ///
  159. /// @param hwaddr hardware address of the client
  160. /// @param subnet_id identifier of the subnet that lease must belong to
  161. ///
  162. /// @return a pointer to the lease (or NULL if a lease is not found)
  163. virtual Lease4Ptr getLease4(const HWAddr& hwaddr,
  164. SubnetID subnet_id) const;
  165. /// @brief Returns existing IPv4 lease for specified client-id
  166. ///
  167. /// @param client_id client identifier
  168. virtual Lease4Collection getLease4(const ClientId& client_id) const;
  169. /// @brief Returns IPv4 lease for specified client-id/hwaddr/subnet-id tuple
  170. ///
  171. /// There can be at most one lease for a given client-id/hwaddr tuple
  172. /// in a single pool, so this method with either return a single lease
  173. /// or NULL.
  174. ///
  175. /// @param clientid client identifier
  176. /// @param hwaddr hardware address of the client
  177. /// @param subnet_id identifier of the subnet that lease must belong to
  178. ///
  179. /// @return a pointer to the lease (or NULL if a lease is not found)
  180. virtual Lease4Ptr getLease4(const ClientId& clientid,
  181. const HWAddr& hwaddr,
  182. SubnetID subnet_id) const;
  183. /// @brief Returns existing IPv4 lease for specified client-id
  184. ///
  185. /// This function returns a copy of the lease. The modification in the
  186. /// return lease does not affect the instance held in the lease storage.
  187. ///
  188. /// There can be at most one lease for a given HW address in a single
  189. /// pool, so this method with either return a single lease or NULL.
  190. ///
  191. /// @param clientid client identifier
  192. /// @param subnet_id identifier of the subnet that lease must belong to
  193. ///
  194. /// @return a pointer to the lease (or NULL if a lease is not found)
  195. virtual Lease4Ptr getLease4(const ClientId& clientid,
  196. SubnetID subnet_id) const;
  197. /// @brief Returns existing IPv6 lease for a given IPv6 address.
  198. ///
  199. /// This function returns a copy of the lease. The modification in the
  200. /// return lease does not affect the instance held in the lease storage.
  201. ///
  202. /// @param type specifies lease type: (NA, TA or PD)
  203. /// @param addr An address of the searched lease.
  204. ///
  205. /// @return smart pointer to the lease (or NULL if a lease is not found)
  206. virtual Lease6Ptr getLease6(Lease::Type type,
  207. const isc::asiolink::IOAddress& addr) const;
  208. /// @brief Returns existing IPv6 lease for a given DUID + IA + lease type
  209. /// combination
  210. ///
  211. /// @param type specifies lease type: (NA, TA or PD)
  212. /// @param duid client DUID
  213. /// @param iaid IA identifier
  214. ///
  215. /// @return collection of IPv6 leases
  216. virtual Lease6Collection getLeases6(Lease::Type type,
  217. const DUID& duid, uint32_t iaid) const;
  218. /// @brief Returns existing IPv6 lease for a given DUID + IA + subnet-id +
  219. /// lease type combination.
  220. ///
  221. /// This function returns a copy of the lease. The modification in the
  222. /// return lease does not affect the instance held in the lease storage.
  223. ///
  224. /// @param type specifies lease type: (NA, TA or PD)
  225. /// @param duid client DUID
  226. /// @param iaid IA identifier
  227. /// @param subnet_id identifier of the subnet the lease must belong to
  228. ///
  229. /// @return lease collection (may be empty if no lease is found)
  230. virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
  231. uint32_t iaid,
  232. SubnetID subnet_id) const;
  233. /// @brief Updates IPv4 lease.
  234. ///
  235. /// @warning This function does not validate the pointer to the lease.
  236. /// It is caller's responsibility to pass the valid pointer.
  237. ///
  238. /// @param lease4 The lease to be updated.
  239. ///
  240. /// If no such lease is present, an exception will be thrown.
  241. virtual void updateLease4(const Lease4Ptr& lease4);
  242. /// @brief Updates IPv6 lease.
  243. ///
  244. /// @warning This function does not validate the pointer to the lease.
  245. /// It is caller's responsibility to pass the valid pointer.
  246. ///
  247. /// @param lease6 The lease to be updated.
  248. ///
  249. /// If no such lease is present, an exception will be thrown.
  250. virtual void updateLease6(const Lease6Ptr& lease6);
  251. /// @brief Deletes a lease.
  252. ///
  253. /// @param addr Address of the lease to be deleted. (This can be IPv4 or
  254. /// IPv6.)
  255. ///
  256. /// @return true if deletion was successful, false if no such lease exists
  257. virtual bool deleteLease(const isc::asiolink::IOAddress& addr);
  258. /// @brief Return backend type
  259. ///
  260. /// Returns the type of the backend.
  261. ///
  262. /// @return Type of the backend.
  263. virtual std::string getType() const {
  264. return (std::string("memfile"));
  265. }
  266. /// @brief Returns backend name.
  267. ///
  268. /// For now, memfile can only store data in memory.
  269. ///
  270. /// @return Name of the backend.
  271. virtual std::string getName() const {
  272. return ("memory");
  273. }
  274. /// @brief Returns description of the backend.
  275. ///
  276. /// This description may be multiline text that describes the backend.
  277. ///
  278. /// @return Description of the backend.
  279. virtual std::string getDescription() const;
  280. /// @brief Returns backend version.
  281. ///
  282. /// @return Version number as a pair of unsigned integers. "first" is the
  283. /// major version number, "second" the minor number.
  284. virtual std::pair<uint32_t, uint32_t> getVersion() const {
  285. return (std::make_pair(MAJOR_VERSION, MINOR_VERSION));
  286. }
  287. /// @brief Commit Transactions
  288. ///
  289. /// Commits all pending database operations. On databases that don't
  290. /// support transactions, this is a no-op.
  291. virtual void commit();
  292. /// @brief Rollback Transactions
  293. ///
  294. /// Rolls back all pending database operations. On databases that don't
  295. /// support transactions, this is a no-op.
  296. virtual void rollback();
  297. //@}
  298. /// @name Public type and method used to determine file names for LFC.
  299. //@{
  300. /// @brief Types of the lease files used by the %Lease File Cleanup.
  301. ///
  302. /// This enumeration is used by a method which appends the appropriate
  303. /// suffix to the lease file name.
  304. enum LFCFileType {
  305. FILE_CURRENT, ///< %Lease File
  306. FILE_INPUT, ///< %Lease File Copy
  307. FILE_PREVIOUS, ///< Previous %Lease File
  308. FILE_OUTPUT, ///< LFC Output File
  309. FILE_FINISH, ///< LFC Finish File
  310. FILE_PID ///< PID File
  311. };
  312. /// @brief Appends appropriate suffix to the file name.
  313. ///
  314. /// The suffix is selected using the LFC file type specified as a
  315. /// parameter. Each file type uses a unique suffix or no suffix:
  316. /// - Current File: no suffix
  317. /// - %Lease File Copy or Input File: ".1"
  318. /// - Previous File: ".2"
  319. /// - LFC Output File: ".output"
  320. /// - LFC Finish File: ".completed"
  321. /// - LFC PID File: ".pid"
  322. ///
  323. /// See http://kea.isc.org/wiki/LFCDesign for details.
  324. ///
  325. /// @param file_name A base file name to which suffix is appended.
  326. /// @param file_type An LFC file type.
  327. /// @return A lease file name with a suffix appended.
  328. static std::string appendSuffix(const std::string& file_name,
  329. const LFCFileType& file_type);
  330. //@}
  331. /// @name Miscellaneous public convenience methods.
  332. /// The following methods allow for retrieving useful information
  333. /// about the state of the backend.
  334. //@{
  335. /// @brief Returns the interval at which the @c IOService events should
  336. /// be released.
  337. ///
  338. /// The Memfile backend may install a timer to execute the %Lease File
  339. /// Cleanup periodically. If this timer is installed, the method returns
  340. /// the LFC interval in milliseconds.
  341. ///
  342. /// @return A maximum interval (in seconds) at which the @c IOService
  343. /// should be executed. A value of 0 means that no timers are installed
  344. /// and that there is no requirement for the @c IOService to be
  345. /// executed at any specific interval.
  346. virtual uint32_t getIOServiceExecInterval() const;
  347. /// @brief Returns default path to the lease file.
  348. ///
  349. /// @param u Universe (V4 or V6).
  350. std::string getDefaultLeaseFilePath(Universe u) const;
  351. /// @brief Returns an absolute path to the lease file.
  352. ///
  353. /// @param u Universe (V4 or V6).
  354. ///
  355. /// @return Absolute path to the lease file or empty string if no lease
  356. /// file is used.
  357. std::string getLeaseFilePath(Universe u) const;
  358. /// @brief Specifies whether or not leases are written to disk.
  359. ///
  360. /// It is possible that leases for DHCPv4 are written to disk whereas leases
  361. /// for DHCPv6 are not; or vice versa. The argument of the method specifies
  362. /// the type of lease in that respect.
  363. ///
  364. /// @param u Universe (V4 or V6).
  365. ///
  366. /// @return true if leases are written to lease file; if false is
  367. /// returned, leases will be held in memory and will be lost upon
  368. /// server shut down.
  369. bool persistLeases(Universe u) const;
  370. //@}
  371. private:
  372. /// @brief Initialize the location of the lease file.
  373. ///
  374. /// This method uses the parameters passed as a map to the constructor to
  375. /// initialize the location of the lease file. If the lease file is not
  376. /// specified, the method will use the default location for the universe
  377. /// (v4 or v6) selected. If the location is specified in the map as empty
  378. /// or the "persist" parameter is set to "no" it will set the empty
  379. /// location, which implies that leases belonging to the specified universe
  380. /// will not be written to disk.
  381. ///
  382. /// @param u Universe (v4 or v6)
  383. ///
  384. /// @return The location of the lease file that should be assigned to the
  385. /// lease_file4_ or lease_file6_, depending on the universe specified as an
  386. /// argument to this function.
  387. std::string initLeaseFilePath(Universe u);
  388. /// @brief Load leases from the persistent storage.
  389. ///
  390. /// This method loads DHCPv4 or DHCPv6 leases from lease files in the
  391. /// following order:
  392. /// - If the <filename>.completed doesn't exist:
  393. /// - leases from the <filename>.2
  394. /// - leases from the <filename>.1
  395. /// - leases from the <filename>
  396. /// - else
  397. /// - leases from the <filename>.completed
  398. /// - leases from the <filename>
  399. ///
  400. /// If any of the files doesn't exist the method proceeds to reading
  401. /// leases from the subsequent file. If the <filename> doesn't exist
  402. /// it is created.
  403. ///
  404. /// When the method successfully reads leases from the files, it leaves
  405. /// the file <filename> open and its internal pointer is set to the
  406. /// end of file. The server will append lease entries to this file as
  407. /// a result of processing new messages from the clients.
  408. ///
  409. /// The <filename>.2, <filename>.1 and <filename>.completed are the
  410. /// products of the lease file cleanups (LFC).
  411. /// See: http://kea.isc.org/wiki/LFCDesign for details.
  412. ///
  413. /// @note: When the server starts up or is reconfigured it will try to
  414. /// read leases from the lease files using this method. It is possible
  415. /// that the %Lease File Cleanup is performed upon the lease files to
  416. /// be read by this method. This may result in conflicts between the
  417. /// server process and the LFC. To prevent it, the method checks if the
  418. /// instance of the @c kea-lfc is running (using the PID file) before it
  419. /// tries to load leases from the lease files. If it finds that there
  420. /// is an LFC in progress, it throws an exception which will result
  421. /// in the server refuse to start or reconfigure. When the administrator
  422. /// retries starting up or reconfiguring the server it will most likely
  423. /// be successful as the LFC should be complete by that time.
  424. ///
  425. /// @todo Consider implementing delaying the lease files loading when
  426. /// the LFC is in progress by the specified amount of time.
  427. ///
  428. /// @param filename Name of the lease file.
  429. /// @param lease_file An object representing a lease file to which
  430. /// the server will store lease updates.
  431. /// @param storage A storage for leases read from the lease file.
  432. /// @tparam LeaseObjectType @c Lease4 or @c Lease6.
  433. /// @tparam LeaseFileType @c CSVLeaseFile4 or @c CSVLeaseFile6.
  434. /// @tparam StorageType @c Lease4Storage or @c Lease6Storage.
  435. ///
  436. /// @throw CSVFileError when parsing any of the lease files fails.
  437. /// @throw DbOpenError when it is found that the LFC is in progress.
  438. template<typename LeaseObjectType, typename LeaseFileType,
  439. typename StorageType>
  440. void loadLeasesFromFiles(const std::string& filename,
  441. boost::shared_ptr<LeaseFileType>& lease_file,
  442. StorageType& storage);
  443. /// @brief stores IPv4 leases
  444. Lease4Storage storage4_;
  445. /// @brief stores IPv6 leases
  446. Lease6Storage storage6_;
  447. /// @brief Holds the pointer to the DHCPv4 lease file IO.
  448. boost::shared_ptr<CSVLeaseFile4> lease_file4_;
  449. /// @brief Holds the pointer to the DHCPv6 lease file IO.
  450. boost::shared_ptr<CSVLeaseFile6> lease_file6_;
  451. public:
  452. /// @name Public methods to retrieve information about the LFC process state.
  453. /// These methods are meant to be used by unit tests to retrieve the
  454. /// state of the spawned LFC process before validating the result of
  455. /// the lease file cleanup.
  456. //@{
  457. /// @brief Checks if the process performing lease file cleanup is running.
  458. ///
  459. /// @return true if the process performing lease file cleanup is running.
  460. bool isLFCRunning() const;
  461. /// @brief Returns the status code returned by the last executed
  462. /// LFC process.
  463. int getLFCExitStatus() const;
  464. //@}
  465. /// @name Protected methods used for %Lease File Cleanup.
  466. /// The following methods are protected so as they can be accessed and
  467. /// tested by unit tests.
  468. //@{
  469. protected:
  470. /// @brief A callback function triggering %Lease File Cleanup (LFC).
  471. ///
  472. /// This method is executed periodically to start the lease file cleanup.
  473. /// It checks whether the file is a DHCPv4 lease file or DHCPv6 lease file
  474. /// and executes the @c Memfile_LeaseMgr::lfcExecute private method
  475. /// with the appropriate parameters.
  476. ///
  477. /// This method is virtual so as it can be overridden and customized in
  478. /// the unit tests. In particular, the unit test which checks that the
  479. /// callback function has been executed would override this function
  480. /// to increase the execution counter each time it is executed.
  481. virtual void lfcCallback();
  482. //@}
  483. /// @name Private methods and members used for %Lease File Cleanup.
  484. //@{
  485. private:
  486. /// @brief Setup the periodic %Lease File Cleanup.
  487. ///
  488. /// This method checks if the @c lfc-interval configuration parameter
  489. /// is set to a non-zero value and sets up the interval timer to
  490. /// perform the %Lease File Cleanup periodically. It also prepares the
  491. /// path and arguments for the @c kea-lfc application which will be
  492. /// executed to perform the cleanup. By default the backend will use
  493. /// the path to the kea-lfc in the Kea installation directory. If
  494. /// the unit tests need to override this path (with the path in the
  495. /// Kea build directory, the @c KEA_LFC_EXECUTABLE environmental
  496. /// variable should be set to hold an absolute path to the kea-lfc
  497. /// excutable.
  498. void lfcSetup();
  499. /// @brief Performs a lease file cleanup for DHCPv4 or DHCPv6.
  500. ///
  501. /// This method performs all the actions necessary to prepare for the
  502. /// execution of the LFC and if these actions are successful, it executes
  503. /// the @c kea-lfc application as a background process to process (cleanup)
  504. /// the lease files.
  505. ///
  506. /// For the design and the terminology used in this description refer to
  507. /// the http://kea.isc.org/wiki/LFCDesign.
  508. ///
  509. /// If the method finds that the %Lease File Copy exists it simply runs
  510. /// the @c kea-lfc application.
  511. ///
  512. /// If the %Lease File Copy doesn't exist it moves the Current %Lease File
  513. /// to Lease File Copy, and then recreates the Current Lease File without
  514. /// any lease entries. If the file has been successfully moved, it runs
  515. /// the @c kea-lfc application.
  516. ///
  517. /// @param lease_file A pointer to the object representing the Current
  518. /// %Lease File (DHCPv4 or DHCPv6 lease file).
  519. ///
  520. /// @tparam LeaseFileType One of @c CSVLeaseFile4 or @c CSVLeaseFile6.
  521. template<typename LeaseFileType>
  522. void lfcExecute(boost::shared_ptr<LeaseFileType>& lease_file);
  523. /// @brief A pointer to the Lease File Cleanup configuration.
  524. boost::scoped_ptr<LFCSetup> lfc_setup_;
  525. //@}
  526. };
  527. }; // end of isc::dhcp namespace
  528. }; // end of isc namespace
  529. #endif // MEMFILE_LEASE_MGR_H