alloc_engine.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. // Copyright (C) 2012-2014 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 ALLOC_ENGINE_H
  15. #define ALLOC_ENGINE_H
  16. #include <asiolink/io_address.h>
  17. #include <dhcp/duid.h>
  18. #include <dhcp/hwaddr.h>
  19. #include <dhcpsrv/subnet.h>
  20. #include <dhcpsrv/lease_mgr.h>
  21. #include <hooks/callout_handle.h>
  22. #include <boost/shared_ptr.hpp>
  23. #include <boost/noncopyable.hpp>
  24. #include <map>
  25. namespace isc {
  26. namespace dhcp {
  27. /// An exception that is thrown when allocation module fails (e.g. due to
  28. /// lack of available addresses)
  29. class AllocFailed : public isc::Exception {
  30. public:
  31. /// @brief constructor
  32. ///
  33. /// @param file name of the file, where exception occurred
  34. /// @param line line of the file, where exception occurred
  35. /// @param what text description of the issue that caused exception
  36. AllocFailed(const char* file, size_t line, const char* what)
  37. : isc::Exception(file, line, what) {}
  38. };
  39. /// @brief DHCPv4 and DHCPv6 allocation engine
  40. ///
  41. /// This class represents DHCP allocation engine. It is responsible
  42. /// for picking subnets, choosing and allocating a lease, extending,
  43. /// renewing, releasing and possibly expiring leases.
  44. ///
  45. /// @todo: Does not handle out of leases well
  46. /// @todo: Does not handle out of allocation attempts well
  47. class AllocEngine : public boost::noncopyable {
  48. protected:
  49. /// @brief base class for all address/prefix allocation algorithms
  50. ///
  51. /// This is an abstract class that should not be used directly, but rather
  52. /// specialized implementations should be used instead.
  53. class Allocator {
  54. public:
  55. /// @brief picks one address out of available pools in a given subnet
  56. ///
  57. /// This method returns one address from the available pools in the
  58. /// specified subnet. It should not check if the address is used or
  59. /// reserved - AllocEngine will check that and will call pickAddress
  60. /// again if necessary. The number of times this method is called will
  61. /// increase as the number of available leases will decrease.
  62. ///
  63. /// This method can also be used to pick a prefix. We should not rename
  64. /// it to pickLease(), because at this early stage there is no concept
  65. /// of a lease yet. Here it is a matter of selecting one address or
  66. /// prefix from the defined pool, without going into details who it is
  67. /// for or who uses it. I thought that pickAddress() is less confusing
  68. /// than pickResource(), because nobody would immediately know what the
  69. /// resource means in this context.
  70. ///
  71. /// @param subnet next address will be returned from pool of that subnet
  72. /// @param duid Client's DUID
  73. /// @param hint client's hint
  74. ///
  75. /// @return the next address
  76. virtual isc::asiolink::IOAddress
  77. pickAddress(const SubnetPtr& subnet, const DuidPtr& duid,
  78. const isc::asiolink::IOAddress& hint) = 0;
  79. /// @brief Default constructor.
  80. ///
  81. /// Specifies which type of leases this allocator will assign
  82. /// @param pool_type specifies pool type (addresses, temp. addr or prefixes)
  83. Allocator(Lease::Type pool_type)
  84. :pool_type_(pool_type) {
  85. }
  86. /// @brief virtual destructor
  87. virtual ~Allocator() {
  88. }
  89. protected:
  90. /// @brief defines pool type allocation
  91. Lease::Type pool_type_;
  92. };
  93. /// defines a pointer to allocator
  94. typedef boost::shared_ptr<Allocator> AllocatorPtr;
  95. /// @brief Address/prefix allocator that iterates over all addresses
  96. ///
  97. /// This class implements iterative algorithm that returns all addresses in
  98. /// a pool iteratively, one after another. Once the last address is reached,
  99. /// it starts allocating from the beginning of the first pool (i.e. it loops
  100. /// over).
  101. class IterativeAllocator : public Allocator {
  102. public:
  103. /// @brief default constructor
  104. ///
  105. /// Does not do anything
  106. /// @param type - specifies allocation type
  107. IterativeAllocator(Lease::Type type);
  108. /// @brief returns the next address from pools in a subnet
  109. ///
  110. /// @param subnet next address will be returned from pool of that subnet
  111. /// @param duid Client's DUID (ignored)
  112. /// @param hint client's hint (ignored)
  113. /// @return the next address
  114. virtual isc::asiolink::IOAddress
  115. pickAddress(const SubnetPtr& subnet,
  116. const DuidPtr& duid,
  117. const isc::asiolink::IOAddress& hint);
  118. protected:
  119. /// @brief Returns an address increased by one
  120. ///
  121. /// This method works for both IPv4 and IPv6 addresses. For example,
  122. /// increase 192.0.2.255 will become 192.0.3.0.
  123. ///
  124. /// @param addr address to be increased
  125. /// @return address increased by one
  126. static isc::asiolink::IOAddress
  127. increaseAddress(const isc::asiolink::IOAddress& addr);
  128. /// @brief Returns the next prefix
  129. ///
  130. /// This method works for IPv6 addresses only. It increases
  131. /// specified prefix by a given prefix_len. For example, 2001:db8::
  132. /// increased by prefix length /32 will become 2001:db9::. This method
  133. /// is used to iterate over IPv6 prefix pools
  134. ///
  135. /// @param prefix prefix to be increased
  136. /// @param prefix_len length of the prefix to be increased
  137. /// @return result prefix
  138. static isc::asiolink::IOAddress
  139. increasePrefix(const isc::asiolink::IOAddress& prefix,
  140. const uint8_t prefix_len);
  141. };
  142. /// @brief Address/prefix allocator that gets an address based on a hash
  143. ///
  144. /// @todo: This is a skeleton class for now and is missing implementation.
  145. class HashedAllocator : public Allocator {
  146. public:
  147. /// @brief default constructor (does nothing)
  148. /// @param type - specifies allocation type
  149. HashedAllocator(Lease::Type type);
  150. /// @brief returns an address based on hash calculated from client's DUID.
  151. ///
  152. /// @todo: Implement this method
  153. ///
  154. /// @param subnet an address will be picked from pool of that subnet
  155. /// @param duid Client's DUID
  156. /// @param hint a hint (last address that was picked)
  157. /// @return selected address
  158. virtual isc::asiolink::IOAddress pickAddress(const SubnetPtr& subnet,
  159. const DuidPtr& duid,
  160. const isc::asiolink::IOAddress& hint);
  161. };
  162. /// @brief Random allocator that picks address randomly
  163. ///
  164. /// @todo: This is a skeleton class for now and is missing implementation.
  165. class RandomAllocator : public Allocator {
  166. public:
  167. /// @brief default constructor (does nothing)
  168. /// @param type - specifies allocation type
  169. RandomAllocator(Lease::Type type);
  170. /// @brief returns an random address from pool of specified subnet
  171. ///
  172. /// @todo: Implement this method
  173. ///
  174. /// @param subnet an address will be picked from pool of that subnet
  175. /// @param duid Client's DUID (ignored)
  176. /// @param hint the last address that was picked (ignored)
  177. /// @return a random address from the pool
  178. virtual isc::asiolink::IOAddress
  179. pickAddress(const SubnetPtr& subnet, const DuidPtr& duid,
  180. const isc::asiolink::IOAddress& hint);
  181. };
  182. public:
  183. /// @brief specifies allocation type
  184. typedef enum {
  185. ALLOC_ITERATIVE, // iterative - one address after another
  186. ALLOC_HASHED, // hashed - client's DUID/client-id is hashed
  187. ALLOC_RANDOM // random - an address is randomly selected
  188. } AllocType;
  189. /// @brief Default constructor.
  190. ///
  191. /// Instantiates necessary services, required to run DHCPv6 server.
  192. /// In particular, creates IfaceMgr that will be responsible for
  193. /// network interaction. Will instantiate lease manager, and load
  194. /// old or create new DUID.
  195. ///
  196. /// @param engine_type selects allocation algorithm
  197. /// @param attempts number of attempts for each lease allocation before
  198. /// we give up (0 means unlimited)
  199. /// @param ipv6 specifies if the engine should work for IPv4 or IPv6
  200. AllocEngine(AllocType engine_type, unsigned int attempts, bool ipv6 = true);
  201. /// @brief Returns IPv4 lease.
  202. ///
  203. /// This method finds the appropriate lease for the client using the
  204. /// following algorithm:
  205. /// - If lease exists for the combination of the HW address, client id and
  206. /// subnet, try to renew a lease and return it.
  207. /// - If lease exists for the combination of the client id and subnet, try
  208. /// to renew the lease and return it.
  209. /// - If client supplied an address hint and this address is available,
  210. /// allocate the new lease with this address.
  211. /// - If client supplied an address hint and the lease for this address
  212. /// exists in the database, return this lease if it is expired.
  213. /// - Pick new address from the pool and try to allocate it for the client,
  214. /// if expired lease exists for the picked address, try to reuse this lease.
  215. ///
  216. /// When a server should do DNS updates, it is required that allocation
  217. /// returns the information how the lease was obtained by the allocation
  218. /// engine. In particular, the DHCP server should be able to check whether
  219. /// existing lease was returned, or new lease was allocated. When existing
  220. /// lease was returned, server should check whether the FQDN has changed
  221. /// between the allocation of the old and new lease. If so, server should
  222. /// perform appropriate DNS update. If not, server may choose to not
  223. /// perform the update. The information about the old lease is returned via
  224. /// @c old_lease parameter. If NULL value is returned, it is an indication
  225. /// that new lease was allocated for the client. If non-NULL value is
  226. /// returned, it is an indication that allocation engine reused/renewed an
  227. /// existing lease.
  228. ///
  229. /// @param subnet subnet the allocation should come from
  230. /// @param clientid Client identifier
  231. /// @param hwaddr Client's hardware address info
  232. /// @param hint A hint that the client provided
  233. /// @param fwd_dns_update Indicates whether forward DNS update will be
  234. /// performed for the client (true) or not (false).
  235. /// @param rev_dns_update Indicates whether reverse DNS update will be
  236. /// performed for the client (true) or not (false).
  237. /// @param hostname A string carrying hostname to be used for DNS updates.
  238. /// @param fake_allocation Is this real i.e. REQUEST (false) or just picking
  239. /// an address for DISCOVER that is not really allocated (true)
  240. /// @param callout_handle A callout handle (used in hooks). A lease callouts
  241. /// will be executed if this parameter is passed.
  242. /// @param [out] old_lease Holds the pointer to a previous instance of a
  243. /// lease. The NULL pointer indicates that lease didn't exist prior
  244. /// to calling this function (e.g. new lease has been allocated).
  245. ///
  246. /// @return Allocated IPv4 lease (or NULL if allocation failed)
  247. Lease4Ptr
  248. allocateLease4(const SubnetPtr& subnet, const ClientIdPtr& clientid,
  249. const HWAddrPtr& hwaddr,
  250. const isc::asiolink::IOAddress& hint,
  251. const bool fwd_dns_update, const bool rev_dns_update,
  252. const std::string& hostname, bool fake_allocation,
  253. const isc::hooks::CalloutHandlePtr& callout_handle,
  254. Lease4Ptr& old_lease);
  255. /// @brief Renews a IPv4 lease
  256. ///
  257. /// Since both request and renew are implemented in DHCPv4 as the sending of
  258. /// a REQUEST packet, it is difficult to easily distinguish between those
  259. /// cases. Therefore renew for DHCPv4 is done in the allocation engine.
  260. /// This method is also used when client crashed/rebooted and tries
  261. /// to get a new lease. It thinks that it gets a new lease, but in fact
  262. /// we are only renewing the still valid lease for that client.
  263. ///
  264. /// @param subnet A subnet the client is attached to
  265. /// @param clientid Client identifier
  266. /// @param hwaddr Client's hardware address
  267. /// @param fwd_dns_update Indicates whether forward DNS update will be
  268. /// performed for the client (true) or not (false).
  269. /// @param rev_dns_update Indicates whether reverse DNS update will be
  270. /// performed for the client (true) or not (false).
  271. /// @param hostname A string carrying hostname to be used for DNS updates.
  272. /// @param lease A lease to be renewed
  273. /// @param callout_handle a callout handle (used in hooks). A lease callouts
  274. /// will be executed if this parameter is passed.
  275. /// @param fake_allocation Is this real i.e. REQUEST (false) or just picking
  276. /// an address for DISCOVER that is not really allocated (true)
  277. Lease4Ptr
  278. renewLease4(const SubnetPtr& subnet,
  279. const ClientIdPtr& clientid,
  280. const HWAddrPtr& hwaddr,
  281. const bool fwd_dns_update,
  282. const bool rev_dns_update,
  283. const std::string& hostname,
  284. const Lease4Ptr& lease,
  285. const isc::hooks::CalloutHandlePtr& callout_handle,
  286. bool fake_allocation /* = false */);
  287. /// @brief Allocates an IPv6 lease
  288. ///
  289. /// This method uses currently selected allocator to pick an address from
  290. /// specified subnet, creates a lease for that address and then inserts
  291. /// it into LeaseMgr (if this allocation is not fake).
  292. ///
  293. /// @param subnet subnet the allocation should come from
  294. /// @param duid Client's DUID
  295. /// @param iaid iaid field from the IA_NA container that client sent
  296. /// @param hint a hint that the client provided
  297. /// @param type lease type (IA, TA or PD)
  298. /// @param fwd_dns_update A boolean value which indicates that server takes
  299. /// responsibility for the forward DNS Update for this lease
  300. /// (if true).
  301. /// @param rev_dns_update A boolean value which indicates that server takes
  302. /// responsibility for the reverse DNS Update for this lease
  303. /// (if true).
  304. /// @param hostname A fully qualified domain-name of the client.
  305. /// @param fake_allocation is this real i.e. REQUEST (false) or just picking
  306. /// an address for SOLICIT that is not really allocated (true)
  307. /// @param callout_handle a callout handle (used in hooks). A lease callouts
  308. /// will be executed if this parameter is passed.
  309. /// @param [out] old_leases Collection to which this function will append
  310. /// old leases. Leases are stored in the same order as in the
  311. /// collection of new leases, being returned. For newly allocated
  312. /// leases (not renewed) the NULL pointers are stored in this
  313. /// collection as old leases.
  314. ///
  315. /// @return Allocated IPv6 leases (may be empty if allocation failed)
  316. Lease6Collection
  317. allocateLeases6(const Subnet6Ptr& subnet, const DuidPtr& duid,
  318. const uint32_t iaid,
  319. const isc::asiolink::IOAddress& hint, Lease::Type type,
  320. const bool fwd_dns_update, const bool rev_dns_update,
  321. const std::string& hostname, bool fake_allocation,
  322. const isc::hooks::CalloutHandlePtr& callout_handle,
  323. Lease6Collection& old_leases);
  324. /// @brief returns allocator for a given pool type
  325. /// @param type type of pool (V4, IA, TA or PD)
  326. /// @throw BadValue if allocator for a given type is missing
  327. /// @return pointer to allocator handing a given resource types
  328. AllocatorPtr getAllocator(Lease::Type type);
  329. /// @brief Destructor. Used during DHCPv6 service shutdown.
  330. virtual ~AllocEngine();
  331. private:
  332. /// @brief Creates a lease and inserts it in LeaseMgr if necessary
  333. ///
  334. /// Creates a lease based on specified parameters and tries to insert it
  335. /// into the database. That may fail in some cases, e.g. when there is another
  336. /// allocation process and we lost a race to a specific lease.
  337. ///
  338. /// @param subnet Subnet the lease is allocated from
  339. /// @param clientid Client identifier
  340. /// @param hwaddr Client's hardware address
  341. /// @param addr An address that was selected and is confirmed to be available
  342. /// @param fwd_dns_update Indicates whether forward DNS update will be
  343. /// performed for the client (true) or not (false).
  344. /// @param rev_dns_update Indicates whether reverse DNS update will be
  345. /// performed for the client (true) or not (false).
  346. /// @param hostname A string carrying hostname to be used for DNS updates.
  347. /// @param callout_handle a callout handle (used in hooks). A lease callouts
  348. /// will be executed if this parameter is passed (and there are callouts
  349. /// registered)
  350. /// @param fake_allocation Is this real i.e. REQUEST (false) or just picking
  351. /// an address for DISCOVER that is not really allocated (true)
  352. /// @return allocated lease (or NULL in the unlikely case of the lease just
  353. /// becomed unavailable)
  354. Lease4Ptr createLease4(const SubnetPtr& subnet, const DuidPtr& clientid,
  355. const HWAddrPtr& hwaddr,
  356. const isc::asiolink::IOAddress& addr,
  357. const bool fwd_dns_update,
  358. const bool rev_dns_update,
  359. const std::string& hostname,
  360. const isc::hooks::CalloutHandlePtr& callout_handle,
  361. bool fake_allocation = false);
  362. /// @brief creates a lease and inserts it in LeaseMgr if necessary
  363. ///
  364. /// Creates a lease based on specified parameters and tries to insert it
  365. /// into the database. That may fail in some cases, i.e. when there is another
  366. /// allocation process and we lost a race to a specific lease.
  367. ///
  368. /// @param subnet subnet the lease is allocated from
  369. /// @param duid client's DUID
  370. /// @param iaid IAID from the IA_NA container the client sent to us
  371. /// @param addr an address that was selected and is confirmed to be
  372. /// available
  373. /// @param prefix_len length of the prefix (for PD only)
  374. /// should be 128 for other lease types
  375. /// @param type lease type (IA, TA or PD)
  376. /// @param fwd_dns_update A boolean value which indicates that server takes
  377. /// responsibility for the forward DNS Update for this lease
  378. /// (if true).
  379. /// @param rev_dns_update A boolean value which indicates that server takes
  380. /// responsibility for the reverse DNS Update for this lease
  381. /// (if true).
  382. /// @param hostname A fully qualified domain-name of the client.
  383. /// @param callout_handle a callout handle (used in hooks). A lease callouts
  384. /// will be executed if this parameter is passed (and there are callouts
  385. /// registered)
  386. /// @param fake_allocation is this real i.e. REQUEST (false) or just picking
  387. /// an address for SOLICIT that is not really allocated (true)
  388. /// @return allocated lease (or NULL in the unlikely case of the lease just
  389. /// became unavailable)
  390. Lease6Ptr createLease6(const Subnet6Ptr& subnet, const DuidPtr& duid,
  391. const uint32_t iaid, const isc::asiolink::IOAddress& addr,
  392. const uint8_t prefix_len, const Lease::Type type,
  393. const bool fwd_dns_update, const bool rev_dns_update,
  394. const std::string& hostname,
  395. const isc::hooks::CalloutHandlePtr& callout_handle,
  396. bool fake_allocation = false);
  397. /// @brief Reuses expired IPv4 lease
  398. ///
  399. /// Updates existing expired lease with new information. Lease database
  400. /// is updated if this is real (i.e. REQUEST, fake_allocation = false), not
  401. /// dummy allocation request (i.e. DISCOVER, fake_allocation = true).
  402. ///
  403. /// @param expired Old, expired lease
  404. /// @param subnet Subnet the lease is allocated from
  405. /// @param clientid Client identifier
  406. /// @param hwaddr Client's hardware address
  407. /// @param fwd_dns_update Indicates whether forward DNS update will be
  408. /// performed for the client (true) or not (false).
  409. /// @param rev_dns_update Indicates whether reverse DNS update will be
  410. /// performed for the client (true) or not (false).
  411. /// @param hostname A string carrying hostname to be used for DNS updates.
  412. /// @param callout_handle A callout handle (used in hooks). A lease callouts
  413. /// will be executed if this parameter is passed.
  414. /// @param fake_allocation Is this real i.e. REQUEST (false) or just picking
  415. /// an address for DISCOVER that is not really allocated (true)
  416. /// @return refreshed lease
  417. /// @throw BadValue if trying to recycle lease that is still valid
  418. Lease4Ptr reuseExpiredLease(Lease4Ptr& expired,
  419. const SubnetPtr& subnet,
  420. const ClientIdPtr& clientid,
  421. const HWAddrPtr& hwaddr,
  422. const bool fwd_dns_update,
  423. const bool rev_dns_update,
  424. const std::string& hostname,
  425. const isc::hooks::CalloutHandlePtr& callout_handle,
  426. bool fake_allocation = false);
  427. /// @brief Reuses expired IPv6 lease
  428. ///
  429. /// Updates existing expired lease with new information. Lease database
  430. /// is updated if this is real (i.e. REQUEST, fake_allocation = false), not
  431. /// dummy allocation request (i.e. SOLICIT, fake_allocation = true).
  432. ///
  433. /// @param expired old, expired lease
  434. /// @param subnet subnet the lease is allocated from
  435. /// @param duid client's DUID
  436. /// @param iaid IAID from the IA_NA container the client sent to us
  437. /// @param prefix_len prefix length (for PD leases)
  438. /// Should be 128 for other lease types
  439. /// @param fwd_dns_update A boolean value which indicates that server takes
  440. /// responsibility for the forward DNS Update for this lease
  441. /// (if true).
  442. /// @param rev_dns_update A boolean value which indicates that server takes
  443. /// responsibility for the reverse DNS Update for this lease
  444. /// (if true).
  445. /// @param hostname A fully qualified domain-name of the client.
  446. /// @param callout_handle a callout handle (used in hooks). A lease callouts
  447. /// will be executed if this parameter is passed.
  448. /// @param fake_allocation is this real i.e. REQUEST (false) or just picking
  449. /// an address for SOLICIT that is not really allocated (true)
  450. /// @return refreshed lease
  451. /// @throw BadValue if trying to recycle lease that is still valid
  452. Lease6Ptr reuseExpiredLease(Lease6Ptr& expired, const Subnet6Ptr& subnet,
  453. const DuidPtr& duid, const uint32_t iaid,
  454. uint8_t prefix_len,
  455. const bool fwd_dns_update,
  456. const bool rev_dns_update,
  457. const std::string& hostname,
  458. const isc::hooks::CalloutHandlePtr& callout_handle,
  459. bool fake_allocation = false);
  460. /// @brief Updates FQDN data for a collection of leases.
  461. ///
  462. /// @param leases Collection of leases for which FQDN data should be
  463. /// updated.
  464. /// @param fwd_dns_update Boolean value which indicates whether forward FQDN
  465. /// update was performed for each lease (true) or not (false).
  466. /// @param rev_dns_update Boolean value which indicates whether reverse FQDN
  467. /// update was performed for each lease (true) or not (false).
  468. /// @param hostname Client hostname associated with a lease.
  469. /// @param fake_allocation Boolean value which indicates that it is a real
  470. /// lease allocation, e.g. Request message is processed (false), or address
  471. /// is just being picked as a result of processing Solicit (true). In the
  472. /// latter case, the FQDN data should not be updated in the lease database.
  473. ///
  474. /// @return Collection of leases with updated FQDN data. Note that returned
  475. /// collection holds updated FQDN data even for fake allocation.
  476. Lease6Collection updateFqdnData(const Lease6Collection& leases,
  477. const bool fwd_dns_update,
  478. const bool rev_dns_update,
  479. const std::string& hostname,
  480. const bool fake_allocation);
  481. /// @brief a pointer to currently used allocator
  482. ///
  483. /// For IPv4, there will be only one allocator: TYPE_V4
  484. /// For IPv6, there will be 3 allocators: TYPE_NA, TYPE_TA, TYPE_PD
  485. std::map<Lease::Type, AllocatorPtr> allocators_;
  486. /// @brief number of attempts before we give up lease allocation (0=unlimited)
  487. unsigned int attempts_;
  488. // hook name indexes (used in hooks callouts)
  489. int hook_index_lease4_select_; ///< index for lease4_select hook
  490. int hook_index_lease6_select_; ///< index for lease6_select hook
  491. };
  492. }; // namespace isc::dhcp
  493. }; // namespace isc
  494. #endif // ALLOC_ENGINE_H