]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Ticket 19830 - enhancment to allow use of host-identifier syntax for DHCPv4
authorShawn Routhier <sar@isc.org>
Tue, 10 Nov 2009 21:12:23 +0000 (21:12 +0000)
committerShawn Routhier <sar@isc.org>
Tue, 10 Nov 2009 21:12:23 +0000 (21:12 +0000)
as well as for DHCPv6

server/dhcp.c

index f60c13773e15ec660de9adb5965456359b21f128..b8ea5de6f63da9d6158f2499a589e8a3daf11fdd 100644 (file)
@@ -1748,6 +1748,17 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
                        if (hp != NULL)
                                host_dereference(&hp, MDL);
                }
+               if (!host) {
+                       find_hosts_by_option(&hp, packet, packet->options, MDL);
+                       for (h = hp; h; h = h -> n_ipaddr) {
+                               if (!h -> fixed_addr)
+                                       break;
+                       }
+                       if (h)
+                               host_reference (&host, h, MDL);
+                       if (hp != NULL)
+                               host_dereference(&hp, MDL);
+               }
        }
 
        /* If we have a host_decl structure, run the options associated
@@ -3279,6 +3290,25 @@ int find_lease (struct lease **lp,
                }
        }
 
+       /* Finally, if we haven't found anything yet try again with the
+        * host-identifier option ... */
+       if (!fixed_lease && !host) {
+               if (find_hosts_by_option(&hp, packet,
+                                        packet->options, MDL) == 1) {
+                       packet->known = 1;
+                       if (host)
+                               host_dereference(&host, MDL);
+                       host_reference(&host, hp, MDL);
+                       host_dereference(&hp, MDL);
+                       mockup_lease (&fixed_lease, packet, share, host);
+#if defined (DEBUG_FIND_LEASE)
+                       if (fixed_lease) {
+                               log_info ("Found host via host-identifier");
+                       }
+#endif
+               }
+       }
+
        /* If fixed_lease is present but does not match the requested
           IP address, and this is a DHCPREQUEST, then we can't return
           any other lease, so we might as well return now. */