diff --git a/src/lib/dhcpsrv/lease.cc b/src/lib/dhcpsrv/lease.cc index e9a2c3d11b84bbaa7b1b5c7fa1ea02d838330862..d14c53b273dc60bfa70105f98f365cfe891712b6 100644 --- a/src/lib/dhcpsrv/lease.cc +++ b/src/lib/dhcpsrv/lease.cc @@ -343,7 +343,7 @@ Lease4::statesToText(const uint32_t state) { const std::vector& Lease4::getClientIdVector() const { - if(!client_id_) { + if (!client_id_) { static std::vector empty_vec; return (empty_vec); } diff --git a/src/lib/dhcpsrv/lease.h b/src/lib/dhcpsrv/lease.h index b603ebeee21f3f674ad9e9230d642ccf2a93942c..0c2c7919038c4d276a2b10deb07683fbd9c5d00a 100644 --- a/src/lib/dhcpsrv/lease.h +++ b/src/lib/dhcpsrv/lease.h @@ -660,7 +660,6 @@ typedef boost::shared_ptr ConstLease6Ptr; /// @brief A collection of IPv6 leases. typedef std::vector Lease6Collection; - /// @brief A shared pointer to the collection of IPv6 leases. typedef boost::shared_ptr Lease6CollectionPtr; diff --git a/src/lib/dhcpsrv/memfile_lease_storage.h b/src/lib/dhcpsrv/memfile_lease_storage.h index 0fe2a705465118c842aa666338d07bcf3bd5f353..33380b0a6dc60e8d0053f648ecc04b32400d5176 100644 --- a/src/lib/dhcpsrv/memfile_lease_storage.h +++ b/src/lib/dhcpsrv/memfile_lease_storage.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -279,6 +280,221 @@ typedef Lease4Storage::index::type Lease4StorageSubnetIdIndex; typedef Lease4Storage::index::type Lease4StorageHostnameIndex; //@} + +/// @name Multi index containers holding DHCPv6 lease extended informations +/// for Bulk Lease Query. +//@{ + +/// @brief Lease6 extended informations for Bulk Lease Query. +class Lease6ExtendedInfo { +public: + /// @brief Constructor. + /// + /// @param lease_addr Lease address. + /// @param link_addr Link address. + /// @param id Identifier. + Lease6ExtendedInfo(const isc::asiolink::IOAddress& lease_addr, + const isc::asiolink::IOAddress& link_addr, + const std::vector& id) + : lease_addr_(lease_addr), link_addr_(link_addr), id_(id) { + } + + /// @brief Lease address. + isc::asiolink::IOAddress lease_addr_; + + /// @brief Link address. + isc::asiolink::IOAddress link_addr_; + + /// @brief Remote or relay opaque identifier. + std::vector id_; +}; + +/// @brief Pointer to a Lease6ExtendedInfo object. +typedef boost::shared_ptr Lease6ExtendedInfoPtr; + +/// @brief Tag for indexes by lease address. +struct LeaseAddressIndexTag { }; + +/// @brief Tag for indexes by relay id and link address. +struct RelayIdLinkAddressIndexTag { }; + +/// @brief Tag for index using relay id. +struct RelayIdIndexTag { }; + +/// @brief Tag for indexes by remote id and link address. +struct RemoteIdLinkAddressIndexTag { }; + +/// @brief Tag for index using remote id. +struct RemoteIdIndexTag { }; + +/// @brief A multi index container holding lease6 extended info for by relay id. +/// +/// The lease6 extended info may be accessed using different indexes: +/// - using a composite index: relay id and link address. +/// - using relay id. +/// - using lease address. +/// +/// The choice of binary trees was governed by the fact a large number of +/// clients can be behind a relay. +/// +/// Indexes can be accessed using the index number (from 0 to 5) or a +/// name tag. It is recommended to use the tags to access indexes as +/// they do not depend on the order of indexes in the container. +typedef boost::multi_index_container< + // It holds pointers to lease6 extended info. + Lease6ExtendedInfoPtr, + boost::multi_index::indexed_by< + // First index is by relay id and link address. + boost::multi_index::ordered_non_unique< + boost::multi_index::tag, + boost::multi_index::composite_key< + Lease6ExtendedInfo, + boost::multi_index::member, + &Lease6ExtendedInfo::id_>, + boost::multi_index::member + > + >, + + // Second index is by relay id. + boost::multi_index::ordered_non_unique< + boost::multi_index::tag, + boost::multi_index::member, + &Lease6ExtendedInfo::id_> + >, + + // Last index is by lease address. + boost::multi_index::hashed_non_unique< + boost::multi_index::tag, + boost::multi_index::member + > + > +> Lease6ExtendedInfoRelayIdTable; + +/// @brief A multi index container holding lease6 extended info for by remote id. +/// +/// The lease6 extended info may be accessed using different indexes: +/// - using a composite index: remote id and link address. +/// - using remote id. +/// - using lease address. +/// +/// The internal layout of remote id is not used. The choice of hash tables +/// was governed by the fact a small number of clients should share the same +/// remote id. +/// +/// Indexes can be accessed using the index number (from 0 to 5) or a +/// name tag. It is recommended to use the tags to access indexes as +/// they do not depend on the order of indexes in the container. +typedef boost::multi_index_container< + // It holds pointers to lease6 extended info. + Lease6ExtendedInfoPtr, + boost::multi_index::indexed_by< + // First index is by remote id and link address. + boost::multi_index::hashed_non_unique< + boost::multi_index::tag, + boost::multi_index::composite_key< + Lease6ExtendedInfo, + boost::multi_index::member, + &Lease6ExtendedInfo::id_>, + boost::multi_index::member + > + >, + + // Second index is by remote id. + boost::multi_index::hashed_non_unique< + boost::multi_index::tag, + boost::multi_index::member, + &Lease6ExtendedInfo::id_> + >, + + // Last index is by lease address. + boost::multi_index::hashed_non_unique< + boost::multi_index::tag, + boost::multi_index::member + > + > +> Lease6ExtendedInfoRemoteIdTable; + +/// @brief Lease6 extended informations for Bulk Lease Query, +/// simpler version (2 fields vs 3) for by link address table. +class Lease6SimpleExtendedInfo { +public: + /// @brief Constructor. + /// + /// @param lease_addr Lease address. + /// @param link_addr Link address. + Lease6SimpleExtendedInfo(const isc::asiolink::IOAddress& lease_addr, + const isc::asiolink::IOAddress& link_addr) + : lease_addr_(lease_addr), link_addr_(link_addr) { + } + + /// @brief Lease address. + isc::asiolink::IOAddress lease_addr_; + + /// @brief Link address. + isc::asiolink::IOAddress link_addr_; +}; + +/// @brief Pointer to a Lease6SimpleExtendedInfo object. +typedef boost::shared_ptr Lease6SimpleExtendedInfoPtr; + +/// @brief Tag for indexes by link address. +struct LinkAddressIndexTag { }; + +/// @brief A multi index container holding lease6 extended info +/// for by link address. +/// +/// The lease6 extended info may be accessed using different indexes: +/// - using a composite index: link and lease addresses. +/// - using lease address. +/// +/// The choice of a binary tree was governed by the fact no hypothesis can +/// be done on the number of clients. +/// +/// Indexes can be accessed using the index number (from 0 to 5) or a +/// name tag. It is recommended to use the tags to access indexes as +/// they do not depend on the order of indexes in the container. +typedef boost::multi_index_container< + // It holds pointers to lease6 extended info. + Lease6SimpleExtendedInfoPtr, + boost::multi_index::indexed_by< + // First index is by link and lease addresses. + boost::multi_index::ordered_non_unique< + boost::multi_index::tag, + boost::multi_index::composite_key< + Lease6SimpleExtendedInfo, + boost::multi_index::member, + boost::multi_index::member + > + >, + + // Last index is by lease address. + boost::multi_index::hashed_non_unique< + boost::multi_index::tag, + boost::multi_index::member + > + > +> Lease6SimpleExtendedInfoLinkAddrTable; + +//@} + } // end of isc::dhcp namespace } // end of isc namespace