]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Support one-lease-per-client.
authorTed Lemon <source@isc.org>
Fri, 2 Jul 1999 17:10:51 +0000 (17:10 +0000)
committerTed Lemon <source@isc.org>
Fri, 2 Jul 1999 17:10:51 +0000 (17:10 +0000)
server/dhcp.c

index ac12cd99a32fefba88d7a5e18696b6095cd3fdc8..97207cc367bb55d837c699d7fd4a7764d787377e 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcp.c,v 1.95 1999/07/01 20:02:57 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhcp.c,v 1.96 1999/07/02 17:10:51 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -876,6 +876,45 @@ void ack_lease (packet, lease, offer, when, msg)
                                              ? lease -> pool -> group
                                              : lease -> subnet -> group));
 
+       /* See if the client is only supposed to have one lease at a time,
+          and if so, find its other leases and release them.    We can only
+          do this on DHCPREQUEST.    It's a little weird to do this before
+          looking at permissions, because the client might not actually
+          _get_ a lease after we've done the permission check, but the
+          assumption for this option is that the client has exactly one
+          network interface, and will only ever remember one lease.   So
+          if it sends a DHCPREQUEST, and doesn't get the lease, it's already
+          forgotten about its old lease, so we can too. */
+       if (offer == DHCPREQUEST &&
+           (oc = lookup_option (&server_universe, state -> options,
+                                SV_ONE_LEASE_PER_CLIENT)) &&
+           evaluate_boolean_option_cache (packet, packet -> options, oc)) {
+               struct lease *seek;
+               if (lease -> uid_len) {
+                       do {
+                               seek = find_lease_by_uid (lease -> uid,
+                                                         lease -> uid_len);
+                               if (seek == lease)
+                                       seek = lease -> n_uid;
+                               if (seek) {
+                                       release_lease (seek);
+                               }
+                       } while (seek);
+               } else {
+                       do {
+                               seek = (find_lease_by_hw_addr
+                                       (lease -> hardware_addr.haddr,
+                                        lease -> hardware_addr.hlen));
+                               if (seek == lease)
+                                       seek = lease -> n_hw;
+                               if (seek) {
+                                       release_lease (seek);
+                               }
+                       } while (seek);
+               }
+       }
+       
+
        /* Make sure this packet satisfies the configured minimum
           number of seconds. */
        if (offer == DHCPOFFER &&