]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2586] Reported v4 code from #2584
authorFrancis Dupont <fdupont@isc.org>
Tue, 4 Oct 2022 14:37:03 +0000 (16:37 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 26 Jan 2023 13:49:49 +0000 (14:49 +0100)
src/lib/dhcpsrv/lease.cc
src/lib/dhcpsrv/lease.h
src/lib/dhcpsrv/memfile_lease_storage.h

index 0d529cdd20b1de1e7c85ac378122ed6cdb4d1dcd..17bb555101787a4802cac8f98b4ea1d1142d1e20 100644 (file)
@@ -334,7 +334,7 @@ Lease4::Lease4(const isc::asiolink::IOAddress& address,
 
     : Lease(address, valid_lifetime, subnet_id, cltt, fqdn_fwd,
             fqdn_rev, hostname, hw_address),
-      client_id_(client_id) {
+      client_id_(client_id), remote_id_(), relay_id_() {
 }
 
 std::string
index 73a913e8d449220de75422841467d89d800de2af..9ff45d0cd402768bb8f9c89f38b303840e9d62dc 100644 (file)
@@ -502,6 +502,12 @@ struct Lease4 : public Lease {
     static Lease4Ptr fromElement(const data::ConstElementPtr& element);
 
     /// @todo: Add DHCPv4 failover related fields here
+
+    /// @brief Remote identifier for Bulk Lease Query
+    std::vector<uint8_t> remote_id_;
+
+    /// @brief Relay identifier for Bulk Lease Query
+    std::vector<uint8_t> relay_id_;
 };
 
 /// @brief A collection of IPv4 leases.
index 693bccf278bdc445f2b2c5ad4d9f6fa866f8b068..0ec2dd3b1f280addf3c576ca19cf3bf076403d1a 100644 (file)
@@ -49,6 +49,12 @@ struct DuidIndexTag { };
 /// @brief Tag for index using hostname.
 struct HostnameIndexTag { };
 
+/// @brief Tag for index using remote-id.
+struct RemoteIdIndexTag { };
+
+/// @brief Tag for index using relay-id.
+struct RelayIdIndexTag { };
+
 /// @name Multi index containers holding DHCPv4 and DHCPv6 leases.
 ///
 //@{
@@ -60,6 +66,8 @@ struct HostnameIndexTag { };
 /// - using a composite index: DUID, IAID and lease type.
 /// - using a composite index: boolean flag indicating if the state is
 ///   "expired-reclaimed" and expiration time.
+/// - using subnet ID.
+/// - using hostname.
 ///
 /// 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
@@ -141,11 +149,15 @@ typedef boost::multi_index_container<
 /// @brief A multi index container holding DHCPv4 leases.
 ///
 /// The leases in the container may be accessed using different indexes:
-/// - IPv6 address,
-/// - composite index: HW address and subnet id,
+/// - IPv4 address,
+/// - composite index: hardware address and subnet id,
 /// - composite index: client id and subnet id,
 /// - using a composite index: boolean flag indicating if the state is
 ///   "expired-reclaimed" and expiration time.
+/// - using subnet id.
+/// - using hostname.
+/// - using remote id.
+/// - using a composite index:
 ///
 /// 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
@@ -227,11 +239,39 @@ typedef boost::multi_index_container<
             boost::multi_index::member<Lease, isc::dhcp::SubnetID, &Lease::subnet_id_>
         >,
 
-        // Specification of the seventh index starts here
+        // Specification of the sixth index starts here.
         // This index is used to retrieve leases for matching hostname.
         boost::multi_index::ordered_non_unique<
             boost::multi_index::tag<HostnameIndexTag>,
             boost::multi_index::member<Lease, std::string, &Lease::hostname_>
+        >,
+
+        // Specification of the seventh index starts here.
+        // This index is used to retrieve leases for matching remote id
+        // for Bulk Lease Query.
+        boost::multi_index::hashed_non_unique<
+            boost::multi_index::tag<RemoteIdIndexTag>,
+            boost::multi_index::member<Lease4,
+                                       std::vector<uint8_t>,
+                                       &Lease4::remote_id_>
+        >,
+
+        // Specification of the eighth index starts here.
+        // This index is used to retrieve leases for matching relay id
+        // for Bulk Lease Query.
+        boost::multi_index::ordered_non_unique<
+            boost::multi_index::tag<RelayIdIndexTag>,
+            boost::multi_index::composite_key<
+                Lease4,
+                // Relay id.
+                boost::multi_index::member<Lease4,
+                                           std::vector<uint8_t>,
+                                           &Lease4::relay_id_>,
+                // Address.
+                boost::multi_index::member<Lease,
+                                           isc::asiolink::IOAddress,
+                                           &Lease::addr_>
+            >
         >
     >
 > Lease4Storage; // Specify the type name for this container.
@@ -280,6 +320,12 @@ typedef Lease4Storage::index<SubnetIdIndexTag>::type Lease4StorageSubnetIdIndex;
 /// @brief DHCPv4 lease storage index by hostname.
 typedef Lease4Storage::index<HostnameIndexTag>::type Lease4StorageHostnameIndex;
 
+/// @brief DHCPv4 lease storage index by remote identifier.
+typedef Lease4Storage::index<RemoteIdIndexTag>::type Lease4StorageRemoteIdInde;
+
+/// @brief DHCPv4 lease storage index by relay identifier.
+typedef Lease4Storage::index<RelayIdIndexTag>::type Lease4StorageRelayIdIndex;
+
 //@}
 
 /// @name Multi index containers holding DHCPv6 lease extended informations