From: Shawn Routhier Date: Tue, 10 Nov 2009 21:12:23 +0000 (+0000) Subject: Ticket 19830 - enhancment to allow use of host-identifier syntax for DHCPv4 X-Git-Tag: v4_2_0a1~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bd0b98c170e569bdf5eb9835169f81f29c2e3207;p=thirdparty%2Fdhcp.git Ticket 19830 - enhancment to allow use of host-identifier syntax for DHCPv4 as well as for DHCPv6 --- diff --git a/server/dhcp.c b/server/dhcp.c index f60c13773..b8ea5de6f 100644 --- a/server/dhcp.c +++ b/server/dhcp.c @@ -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. */