2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-29 05:17:57 +00:00

sync with branch

This commit is contained in:
Ted Lemon 2001-08-10 10:50:50 +00:00
parent eaf0b3020b
commit a609e69bba
16 changed files with 107 additions and 77 deletions

View File

@ -41,7 +41,7 @@
#ifndef lint
static char ocopyright[] =
"$Id: dhclient.c,v 1.130 2001/06/27 00:29:29 mellon Exp $ Copyright (c) 1995-2001 Internet Software Consortium. All rights reserved.\n";
"$Id: dhclient.c,v 1.131 2001/08/10 10:47:33 mellon Exp $ Copyright (c) 1995-2001 Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@ -2654,6 +2654,7 @@ void go_daemon ()
{
static int state = 0;
int pid;
int i;
/* Don't become a daemon if the user requested otherwise. */
if (no_daemon) {
@ -2682,6 +2683,16 @@ void go_daemon ()
close(1);
close(2);
/* Reopen them on /dev/null. */
i = open ("/dev/null", O_RDWR);
if (i == 0)
i = open ("/dev/null", O_RDWR);
if (i == 1) {
i = open ("/dev/null", O_RDWR);
log_perror = 0; /* No sense logging to /dev/null. */
} else if (i != -1)
close (i);
write_client_pid_file ();
}

View File

@ -90,7 +90,7 @@ if [ x$reason = xPREINIT ]; then
# Add route to make broadcast work. Do not omit netmask.
route add default dev $interface netmask 0.0.0.0
else
ifconfig $interface up
ifconfig $interface 0 up
fi
# We need to give the kernel some time to get the interface up.
@ -122,7 +122,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
# IP address changed. Bringing down the interface will delete all routes,
# and clear the ARP cache.
ifconfig $interface inet down
ifconfig $interface inet 0 down
fi
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
@ -157,7 +157,7 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
fi
if [ x$old_ip_address != x ]; then
# Shut down interface, which will delete routes and clear arp cache.
ifconfig $interface inet down
ifconfig $interface inet 0 down
fi
if [ x$alias_ip_address != x ]; then
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
@ -190,7 +190,7 @@ if [ x$reason = xTIMEOUT ]; then
make_resolv_conf
exit_with_hooks 0
fi
ifconfig $interface inet down
ifconfig $interface inet 0 down
exit_with_hooks 1
fi

View File

@ -409,33 +409,6 @@ Rebind - DHCP client is in the REBINDING state - it has an IP address,
and is trying to contact any server to renew it. The next message to
be sent will be a DHCPREQUEST, which will be broadcast.
.RE
.SH
FUNCTIONS
Functions may be defined with the \fBdefine\fR statement. A function
definition may occur anywhere that regular statement may appear.
Functions occupy the same namespace as variables, and obey the same
scoping rules.
.PP
.nf
define set-hostname(prefix) {
option host-name
concat (prefix, binary-to-ascii (16, 32, "", leased-address));
}
.fi
.PP
A function may return a value when used in an expression with the
\fBreturn\fR statement. A function with no return statement has a
value of null.
.PP
.nf
define make-hostname(prefix) {
return concat (prefix, binary-to-ascii (16, 32, "", leased-address));
}
option host-name make-hostname("dyn-");
.fi
.PP
.RE
.SH REFERENCE: LOGGING
Logging statements may be used to send information to the standard logging
channels. A logging statement includes an optional priority (\fBfatal\fR,

View File

@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
"$Id: execute.c,v 1.45 2001/06/27 00:29:48 mellon Exp $ Copyright (c) 1998-2000 The Internet Software Consortium. All rights reserved.\n";
"$Id: execute.c,v 1.46 2001/08/10 10:48:58 mellon Exp $ Copyright (c) 1998-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@ -999,10 +999,10 @@ int executable_statement_foreach (struct executable_statement *stmt,
case null_statement:
break;
case if_statement:
if (executable_statement_foreach (stmt -> data.ie.tc,
if (executable_statement_foreach (foo -> data.ie.tc,
callback, vp, 1))
ok = 1;
if (executable_statement_foreach (stmt -> data.ie.fc,
if (executable_statement_foreach (foo -> data.ie.fc,
callback, vp, 1))
ok = 1;
break;
@ -1024,17 +1024,17 @@ int executable_statement_foreach (struct executable_statement *stmt,
break;
case statements_statement:
if ((executable_statement_foreach
(stmt -> data.statements, callback, vp, condp)))
(foo -> data.statements, callback, vp, condp)))
ok = 1;
break;
case on_statement:
if ((executable_statement_foreach
(stmt -> data.on.statements, callback, vp, 1)))
(foo -> data.on.statements, callback, vp, 1)))
ok = 1;
break;
case switch_statement:
if ((executable_statement_foreach
(stmt -> data.s_switch.statements, callback, vp, 1)))
(foo -> data.s_switch.statements, callback, vp, 1)))
ok = 1;
break;
case case_statement:
@ -1047,7 +1047,7 @@ int executable_statement_foreach (struct executable_statement *stmt,
break;
case let_statement:
if ((executable_statement_foreach
(stmt -> data.let.statements, callback, vp, 0)))
(foo -> data.let.statements, callback, vp, 0)))
ok = 1;
break;
case define_statement:

View File

@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
"$Id: options.c,v 1.86 2001/06/27 00:29:54 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
"$Id: options.c,v 1.87 2001/08/10 10:49:00 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#define DHCP_OPTION_DATA
@ -82,13 +82,34 @@ int parse_options (packet)
&packet -> raw -> options [4],
(packet -> packet_length -
DHCP_FIXED_NON_UDP - 4),
&dhcp_universe))
return 0;
&dhcp_universe)) {
/* STSN servers have a bug where they send a mangled
domain-name option, and whatever is beyond that in
the packet is junk. Microsoft clients accept this,
which is probably why whoever implemented the STSN
server isn't aware of the problem yet. To work around
this, we will accept corrupt packets from the server if
they contain a valid DHCP_MESSAGE_TYPE option, but
will not accept any corrupt client packets (the ISC DHCP
server is sufficiently widely used that it is probably
beneficial for it to be picky) and will not accept
packets whose type can't be determined. */
if ((op = lookup_option (&dhcp_universe, packet -> options,
DHO_DHCP_MESSAGE_TYPE))) {
if (!op -> data.data ||
(op -> data.data [0] != DHCPOFFER &&
op -> data.data [0] != DHCPACK &&
op -> data.data [0] != DHCPNAK))
return 0;
} else
return 0;
}
/* If we parsed a DHCP Option Overload option, parse more
options out of the buffer(s) containing them. */
if (packet -> options_valid &&
(op = lookup_option (&dhcp_universe, packet -> options,
if ((op = lookup_option (&dhcp_universe, packet -> options,
DHO_DHCP_OPTION_OVERLOAD))) {
if (op -> data.data [0] & 1) {
if (!parse_option_buffer

View File

@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
"$Id: print.c,v 1.54 2001/06/27 00:29:57 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
"$Id: print.c,v 1.55 2001/08/10 10:49:01 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@ -1292,7 +1292,10 @@ void print_dns_status (int status, ns_updque *uq)
strcpy (s, "empty update");
s += strlen (s);
}
errorp = 1;
if (status == NOERROR)
errorp = 0;
else
errorp = 1;
en = isc_result_totext (status);
#if 0
switch (status) {

View File

@ -592,9 +592,9 @@ struct collection {
/* XXX classes must be reference-counted. */
struct class {
OMAPI_OBJECT_PREAMBLE;
struct class *nic; /* Next in collection. */
struct class *nic; /* Next in collection. */
struct class *superclass; /* Set for spawned classes only. */
char *name; /* Not set for spawned classes. */
char *name; /* Not set for spawned classes. */
/* A class may be configured to permit a limited number of leases. */
int lease_limit;

View File

@ -314,6 +314,8 @@ typedef struct _dhcp_failover_state {
failover_message_t *toack_queue_tail;
int pending_acks; /* Number of messages in the toack
queue. */
int pool_count; /* Number of pools referencing this
failover state object. */
} dhcp_failover_state_t;
#define DHCP_FAILOVER_VERSION 1

View File

@ -1,3 +1,3 @@
/* Current version of ISC DHCP Distribution. */
#define DHCP_VERSION "V3.0rc8pl2"
#define DHCP_VERSION "V3.1-pre"

View File

@ -3,7 +3,7 @@
Routines for manipulating hash tables... */
/*
* Copyright (c) 1995-2001 Internet Software Consortium.
* Copyright (c) 1995-2000 Internet Software Consortium.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
"$Id: hash.c,v 1.3 2001/06/27 00:30:48 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
"$Id: hash.c,v 1.4 2001/08/10 10:50:22 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include <omapip/omapip_p.h>

View File

@ -401,23 +401,27 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h,
}
/* If we get a disconnect, dump memory usage. */
if (!strcmp (name, "disconnect")
#if defined (DEBUG_MEMORY_LEAKAGE)
&& connect_outstanding != 0xBEADCAFE
#endif
) {
if (!strcmp (name, "disconnect")) {
#if defined (DEBUG_MEMORY_LEAKAGE)
if (connect_outstanding != 0xBEADCAFE) {
log_info ("generation %ld: %ld new, %ld outstanding, %ld%s",
dmalloc_generation,
dmalloc_outstanding - previous_outstanding,
dmalloc_outstanding, dmalloc_longterm, " long-term");
}
#endif
#if defined (DEBUG_MEMORY_LEAKAGE)
dmalloc_dump_outstanding ();
dmalloc_dump_outstanding ();
#endif
#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
dump_rc_history (0);
dump_rc_history ();
#endif
for (m = omapi_registered_messages; m; m = m -> next) {
if (m -> protocol_object == p) {
if (m -> object)
omapi_signal (m -> object, "disconnect");
}
}
}
/* Not a signal we recognize? */

View File

@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
"$Id: confpars.c,v 1.146 2001/07/10 20:36:02 brister Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
"$Id: confpars.c,v 1.147 2001/08/10 10:50:44 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@ -1286,6 +1286,8 @@ void parse_pool_statement (cfile, group, type)
parse_warn (cfile,
"failover peer %s: %s", val,
isc_result_totext (status));
else
pool -> failover_peer -> pool_count++;
parse_semi (cfile);
break;
#endif
@ -1851,7 +1853,7 @@ int parse_class_declaration (cp, cfile, group, type)
}
/* Save the name, if there is one. */
class -> name = (char *)name;
class -> name = name;
}
if (type == 0 || type == 1 || type == 3)
@ -2764,6 +2766,7 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
break;
case OPTION:
case SUPERSEDE:
noequal = 0;
seenbit = 0;
oc = (struct option_cache *)0;

View File

@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
"$Id: dhcp.c,v 1.194 2001/06/27 00:31:07 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
"$Id: dhcp.c,v 1.195 2001/08/10 10:50:45 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@ -2919,6 +2919,7 @@ int find_lease (struct lease **lp,
be two "free" leases for the same uid, but only one of
them that's available for this failover peer to allocate. */
if (uid_lease -> binding_state != FTS_ACTIVE &&
uid_lease -> binding_state != FTS_BOOTP &&
!lease_mine_to_reallocate (uid_lease)) {
#if defined (DEBUG_FIND_LEASE)
log_info ("not mine to allocate: %s",
@ -2982,6 +2983,7 @@ int find_lease (struct lease **lp,
be two "free" leases for the same uid, but only one of
them that's available for this failover peer to allocate. */
if (hw_lease -> binding_state != FTS_ACTIVE &&
hw_lease -> binding_state != FTS_BOOTP &&
!lease_mine_to_reallocate (hw_lease)) {
#if defined (DEBUG_FIND_LEASE)
log_info ("not mine to allocate: %s",
@ -3114,6 +3116,7 @@ int find_lease (struct lease **lp,
is not active, and is not ours to reallocate, forget about it. */
if (ip_lease && (uid_lease || hw_lease) &&
ip_lease -> binding_state != FTS_ACTIVE &&
ip_lease -> binding_state != FTS_BOOTP &&
!lease_mine_to_reallocate (ip_lease) &&
packet -> packet_type == DHCPDISCOVER) {
#if defined (DEBUG_FIND_LEASE)
@ -3126,14 +3129,16 @@ int find_lease (struct lease **lp,
on the subnet that matches its uid, pick the one that
it asked for and (if we can) free the other. */
if (ip_lease &&
ip_lease -> binding_state == FTS_ACTIVE &&
(ip_lease -> binding_state == FTS_ACTIVE ||
ip_lease -> binding_state == FTS_BOOTP) &&
ip_lease -> uid && ip_lease != uid_lease) {
if (have_client_identifier &&
(ip_lease -> uid_len == client_identifier.len) &&
!memcmp (client_identifier.data,
ip_lease -> uid, ip_lease -> uid_len)) {
if (uid_lease) {
if (uid_lease -> binding_state == FTS_ACTIVE) {
if (uid_lease -> binding_state == FTS_ACTIVE ||
uid_lease -> binding_state == FTS_BOOTP) {
log_error ("client %s has duplicate%s on %s",
(print_hw_addr
(packet -> raw -> htype,
@ -3147,7 +3152,10 @@ int find_lease (struct lease **lp,
it shouldn't still be using the old
one, so we can free it for allocation. */
if (uid_lease &&
uid_lease -> binding_state == FTS_ACTIVE &&
(uid_lease -> binding_state == FTS_ACTIVE
||
uid_lease -> binding_state == FTS_BOOTP)
&&
!packet -> raw -> ciaddr.s_addr &&
(share ==
uid_lease -> subnet -> shared_network) &&
@ -3302,7 +3310,8 @@ int find_lease (struct lease **lp,
if (lease) {
if (!packet -> raw -> ciaddr.s_addr &&
packet -> packet_type == DHCPREQUEST &&
uid_lease -> binding_state == FTS_ACTIVE)
(uid_lease -> binding_state == FTS_ACTIVE ||
uid_lease -> binding_state == FTS_BOOTP))
dissociate_lease (uid_lease);
#if defined (DEBUG_FIND_LEASE)
log_info ("not choosing uid lease.");

View File

@ -956,7 +956,7 @@ client sends a DHCPDISCOVER message, then the server sends a
DHCPOFFER, then the client sends a DHCPREQUEST, then the server sends
a DHCPACK. In the current version of the server, the server will do
a DNS update after it has received the DHCPREQUEST, and before it has
sent the DHCPOFFER. It only sends the DNS update if it has not sent
sent the DHCPACK. It only sends the DNS update if it has not sent
one for the client's address before, in order to minimize the impact
on the DHCP server.
.PP

View File

@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
"$Id: failover.c,v 1.56 2001/06/29 18:34:57 mellon Exp $ Copyright (c) 1999-2001 The Internet Software Consortium. All rights reserved.\n";
"$Id: failover.c,v 1.57 2001/08/10 10:50:49 mellon Exp $ Copyright (c) 1999-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@ -72,6 +72,15 @@ void dhcp_failover_startup ()
for (state = failover_states; state; state = state -> next) {
dhcp_failover_state_transition (state, "startup");
if (state -> pool_count == 0) {
log_error ("failover peer declaration with no %s",
"referring pools.");
log_error ("In order to use failover, you MUST %s",
"refer to your main failover declaration");
log_error ("in each pool declaration. You MUST %s",
"NOT use range declarations outside");
log_fatal ("of pool declarations.");
}
/* In case the peer is already running, immediately try
to establish a connection with it. */
status = dhcp_failover_link_initiate ((omapi_object_t *)state);
@ -243,7 +252,7 @@ isc_result_t dhcp_failover_link_initiate (omapi_object_t *h)
local_addr.addrtype = AF_INET;
local_addr.addrlen = sizeof (struct in_addr);
if (!state -> server_identifier.len) {
log_fatal ("failover peer %s: no identifier.",
log_fatal ("failover peer %s: no local address.",
state -> name);
}
} else {
@ -4981,14 +4990,9 @@ normal_binding_state_transition_check (struct lease *lease,
switch (binding_state) {
case FTS_FREE:
case FTS_BACKUP:
/* Can't set a lease to free or backup until the
peer agrees that it's expired. */
if (tsfp > cur_time) {
new_state = lease -> binding_state;
goto out;
}
return binding_state;
/* These are invalid state transitions - should we
prevent them? */
case FTS_RESERVED:
case FTS_BOOTP:
case FTS_EXPIRED:

View File

@ -50,7 +50,7 @@
#ifndef lint
static char copyright[] =
"$Id: omapi.c,v 1.50 2001/07/10 20:36:06 brister Exp $ Copyright (c) 1999-2001 The Internet Software Consortium. All rights reserved.\n";
"$Id: omapi.c,v 1.51 2001/08/10 10:50:50 mellon Exp $ Copyright (c) 1999-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@ -1868,7 +1868,7 @@ isc_result_t dhcp_class_destroy (omapi_object_t *h, const char *file, int line)
isc_result_t status;
int i;
if (h -> type != dhcp_type_class || h -> type != dhcp_type_subclass)
if (h -> type != dhcp_type_class && h -> type != dhcp_type_subclass)
return ISC_R_INVALIDARG;
class = (struct class *)h;