#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"
{
static int state = 0;
int pid;
+ int i;
/* Don't become a daemon if the user requested otherwise. */
if (no_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 ();
}
# 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.
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 ] || \
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
make_resolv_conf
exit_with_hooks 0
fi
- ifconfig $interface inet down
+ ifconfig $interface inet 0 down
exit_with_hooks 1
fi
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,
#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"
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;
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:
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:
#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
&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
#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"
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) {
/* 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;
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
/* Current version of ISC DHCP Distribution. */
-#define DHCP_VERSION "V3.0rc8pl2"
+#define DHCP_VERSION "V3.1-pre"
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
#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>
}
/* 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? */
#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"
parse_warn (cfile,
"failover peer %s: %s", val,
isc_result_totext (status));
+ else
+ pool -> failover_peer -> pool_count++;
parse_semi (cfile);
break;
#endif
}
/* Save the name, if there is one. */
- class -> name = (char *)name;
+ class -> name = name;
}
if (type == 0 || type == 1 || type == 3)
break;
case OPTION:
+ case SUPERSEDE:
noequal = 0;
seenbit = 0;
oc = (struct option_cache *)0;
#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"
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",
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",
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)
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,
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) &&
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.");
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
#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"
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);
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 {
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:
#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"
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;