#ifndef lint
static char copyright[] =
-"$Id: dhcp.c,v 1.155 2000/06/30 00:48:55 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhcp.c,v 1.156 2000/07/06 10:16:54 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
packet -> options, DHO_DHCP_SERVER_IDENTIFIER))
state -> got_server_identifier = 1;
- /* Replace the old lease hostname with the new one, if it's changed. */
- oc = lookup_option (&dhcp_universe, packet -> options, DHO_HOST_NAME);
- memset (&d1, 0, sizeof d1);
- if (oc)
- s1 = evaluate_option_cache (&d1, packet, (struct lease *)0,
- packet -> options,
- (struct option_state *)0,
- &global_scope, oc, MDL);
- if (oc && s1 &&
- lease -> client_hostname &&
- strlen (lease -> client_hostname) == d1.len &&
- !memcmp (lease -> client_hostname, d1.data, d1.len)) {
- /* Hasn't changed. */
- data_string_forget (&d1, MDL);
- } else if (oc && s1) {
- if (lease -> client_hostname)
- dfree (lease -> client_hostname, MDL);
- lease -> client_hostname =
- dmalloc (d1.len + 1, MDL);
- if (!lease -> client_hostname)
- log_error ("no memory for client hostname.");
- else {
- memcpy (lease -> client_hostname, d1.data, d1.len);
- lease -> client_hostname [d1.len] = 0;
- }
- data_string_forget (&d1, MDL);
- } else if (lease -> client_hostname) {
- dfree (lease -> client_hostname, MDL);
- lease -> client_hostname = 0;
- }
-
/* Steal the agent options from the packet. */
if (packet -> options -> universes [agent_universe.index]) {
state -> options -> universes [agent_universe.index] =
/* Make sure this packet satisfies the configured minimum
number of seconds. */
+ memset (&d1, 0, sizeof d1);
if (offer == DHCPOFFER &&
(oc = lookup_option (&server_universe, state -> options,
SV_MIN_SECS))) {
lt -> scope.bindings = lease -> scope.bindings;
lease -> scope.bindings = (struct binding *)0;
+ /* Replace the old lease hostname with the new one, if it's changed. */
+ oc = lookup_option (&dhcp_universe, packet -> options, DHO_HOST_NAME);
+ if (oc)
+ s1 = evaluate_option_cache (&d1, packet, (struct lease *)0,
+ packet -> options,
+ (struct option_state *)0,
+ &global_scope, oc, MDL);
+ if (oc && s1 &&
+ lease -> client_hostname &&
+ strlen (lease -> client_hostname) == d1.len &&
+ !memcmp (lease -> client_hostname, d1.data, d1.len)) {
+ /* Hasn't changed. */
+ data_string_forget (&d1, MDL);
+ lt -> client_hostname = lease -> client_hostname;
+ lease -> client_hostname = (char *)0;
+ } else if (oc && s1) {
+ lt -> client_hostname = dmalloc (d1.len + 1, MDL);
+ if (!lt -> client_hostname)
+ log_error ("no memory for client hostname.");
+ else {
+ memcpy (lt -> client_hostname, d1.data, d1.len);
+ lt -> client_hostname [d1.len] = 0;
+ }
+ data_string_forget (&d1, MDL);
+ }
+
/* Don't call supersede_lease on a mocked-up lease. */
if (lease -> flags & STATIC_LEASE) {
/* Copy the hardware address into the static lease