]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Allow lease "ends" vaule to be updated by OMAPI. [rt17033]
authorEvan Hunt <each@isc.org>
Fri, 18 Jan 2008 02:05:09 +0000 (02:05 +0000)
committerEvan Hunt <each@isc.org>
Fri, 18 Jan 2008 02:05:09 +0000 (02:05 +0000)
RELNOTES
server/omapi.c

index 16cbc510b9bc663d7dcb5aeca56ecc5ceac1e51f..3133d4b6f102352000459dc77a83b6329739db05 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -55,6 +55,10 @@ suggested fixes to <dhcp-users@isc.org>.
 
                        Changes since 4.0.0
 
+- It's now possible to update the "ends" field of a lease with OMAPI.
+  This is useful if you want not only to release a lease, but also make
+  it available for reuse right away.  Hat tip to Christof Chen.
+
 - Fixed "--version" flag in dhcrelay
 
 - The warning logged when an address range doesn't fit in the subnets
index 77ade035a1f6a26d03e82c0d1abec0b3c6ad85c9..b459571fd72c2628c7959e4d30a15fd395c58376 100644 (file)
@@ -259,7 +259,20 @@ isc_result_t dhcp_lease_set_value  (omapi_object_t *h,
        } else if (!omapi_ds_strcmp (name, "starts")) {
            return ISC_R_NOPERM;
        } else if (!omapi_ds_strcmp (name, "ends")) {
-           return ISC_R_NOPERM;
+           unsigned long lease_end, old_lease_end;
+           status = omapi_get_int_value (&lease_end, value);
+           if (status != ISC_R_SUCCESS)
+               return status;
+           old_lease_end = lease->ends;
+           lease->ends = lease_end;
+           if (supersede_lease (lease, 0, 1, 1, 1)) {
+               log_info ("lease %s end changed from %lu to %lu",
+                         piaddr(lease->ip_addr), old_lease_end, lease_end);
+               return ISC_R_SUCCESS;
+           }
+           log_info ("lease %s end change from %lu to %lu failed",
+                     piaddr(lease->ip_addr), old_lease_end, lease_end);
+           return ISC_R_IOERROR;
        } else if (!omapi_ds_strcmp(name, "flags")) {
            u_int8_t oldflags;