7 #ifndef FREE_LEASE_QUEUE_H 8 #define FREE_LEASE_QUEUE_H 14 #include <boost/multi_index_container.hpp> 15 #include <boost/multi_index/hashed_index.hpp> 16 #include <boost/multi_index/identity.hpp> 17 #include <boost/multi_index/indexed_by.hpp> 18 #include <boost/multi_index/member.hpp> 19 #include <boost/multi_index/ordered_index.hpp> 20 #include <boost/multi_index/random_access_index.hpp> 21 #include <boost/multi_index/sequenced_index.hpp> 22 #include <boost/shared_ptr.hpp> 124 const uint8_t delegated_length);
133 template<
typename RangeType>
135 return (ranges_.get<1>().erase(range.start_) > 0);
237 template<
typename RangeType>
239 return (popNextInternal(range,
true));
252 template<
typename RangeType>
254 return (popNextInternal(range,
false));
267 template<
typename RangeType>
269 auto cont = ranges_.get<1>().find(range.start_);
270 if (cont == ranges_.get<1>().end()) {
272 <<
":" << range.end_ <<
" does not exist");
274 return (std::distance(ranges_.get<2>().begin(), ranges_.project<2>(cont)));
285 typedef boost::multi_index_container<
287 boost::multi_index::indexed_by<
288 boost::multi_index::ordered_unique<
289 boost::multi_index::identity<asiolink::IOAddress>
291 boost::multi_index::sequenced<>
296 typedef boost::shared_ptr<Leases> LeasesPtr;
300 struct RangeDescriptor {
306 uint8_t delegated_length_;
317 typedef boost::multi_index_container<
319 boost::multi_index::indexed_by<
320 boost::multi_index::ordered_unique<
322 &RangeDescriptor::range_start_>
324 boost::multi_index::hashed_unique<
325 boost::multi_index::member<RangeDescriptor, asiolink::IOAddress,
326 &RangeDescriptor::range_start_>
328 boost::multi_index::random_access<>
341 template<
typename RangeType>
342 void checkRangeBoundaries(
const RangeType& range,
const asiolink::IOAddress& ip,
343 const bool prefix =
false)
const;
351 void checkRangeOverlaps(
const asiolink::IOAddress& start,
352 const asiolink::IOAddress& end)
const;
366 LeasesPtr getLeases(
const PrefixRange& range)
const;
377 RangeDescriptor getRangeDescriptor(
const uint64_t range_index)
const;
388 template<
typename RangeType>
389 asiolink::IOAddress popNextInternal(
const RangeType& range,
const bool push) {
390 auto cont = getLeases(range);
395 auto& idx = cont->template get<1>();
396 auto next = idx.front();
412 #endif // FREE_LEASE_QUEUE_H Structure representing delegated prefix range.
asiolink::IOAddress pop(const RangeType &range)
Pops and returns next free address or delegated prefix in the range.
asiolink::IOAddress next(const RangeType &range)
Returns next free address or delegated prefix in the range.
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
void addRange(const AddressRange &range)
Adds new address range to the queue.
bool use(const AddressRange &range, const asiolink::IOAddress &address)
Removes the specified address from the free addresses.
uint64_t getRangeIndex(const RangeType &range) const
Returns range index.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
FreeLeaseQueue()
Constructor.
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
Defines the logger used by the top-level component of kea-lfc.
bool append(const asiolink::IOAddress &address)
Appends an address to the end of the queue for a range.
Structure representing IP address range.
bool removeRange(const RangeType &range)
Removes the range from the queue.
The IOAddress class represents an IP addresses (version agnostic)
Queue holding free leases for various address and prefix ranges.