]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3038] set arguments for lease4_offer callout
authorPiotrek Zadroga <piotrek@isc.org>
Wed, 6 Sep 2023 07:53:18 +0000 (09:53 +0200)
committerPiotrek Zadroga <piotrek@isc.org>
Mon, 18 Sep 2023 17:19:45 +0000 (19:19 +0200)
src/bin/dhcp4/dhcp4_srv.cc

index 4d02661bbc9b3e465f64164b9978e3bcd97cc4ae..0e888c4222b53ff02d8ff04c6b8850502ac7dc72 100644 (file)
@@ -1411,6 +1411,8 @@ Dhcpv4Srv::processDhcp4Query(Pkt4Ptr& query, Pkt4Ptr& rsp,
 
     CalloutHandlePtr callout_handle = getCalloutHandle(query);
     if (ctx) {
+        // leases4_committed and lease4_offer callouts are treated in the same way,
+        // so prepare correct set of variables basing on the packet context.
         int hook_idx = Hooks.hook_index_leases4_committed_;
         std::string hook_label = "leases4_committed";
         MessageID pkt_park_msg = DHCP4_HOOK_LEASES4_COMMITTED_PARK;
@@ -1471,6 +1473,12 @@ Dhcpv4Srv::processDhcp4Query(Pkt4Ptr& query, Pkt4Ptr& rsp,
             }
             callout_handle->setArgument("deleted_leases4", deleted_leases);
 
+            if (ctx->fake_allocation_) {
+                // Arguments required only for lease4_offer callout.
+                callout_handle->setArgument("offer_lifetime", ctx->offer_lft_);
+                callout_handle->setArgument("old_lease", ctx->old_lease_);
+            }
+
             if (allow_packet_park) {
                 // Get the parking limit. Parsing should ensure the value is present.
                 uint32_t parked_packet_limit = 0;