mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-29 02:22:43 +00:00
Import ISC DHCP 3.0.1 RC8 client.
This commit is contained in:
parent
ce99b771f8
commit
33075c330b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/isc-dhcp/dist/; revision=93507
@ -215,7 +215,7 @@ MINORVERSION=MinorVersion
|
||||
#CF = cf/rhapsody.h
|
||||
#COPTS = -Ddarwin -Wall -Wno-unused -Wno-implicit -Wno-comment \
|
||||
# -Wno-uninitialized -Wno-switch -Werror -pipe $(BINDDEF) $(CC_OPTIONS)
|
||||
##SCRIPT=rhapsody
|
||||
#SCRIPT=freebsd
|
||||
##--darwin--
|
||||
|
||||
## NetBSD
|
||||
|
@ -1,7 +1,7 @@
|
||||
Internet Software Consortium DHCP Distribution
|
||||
Version 3.0.1
|
||||
Release Candidate 6
|
||||
January 17, 2002
|
||||
Release Candidate 8
|
||||
February 21, 2002
|
||||
|
||||
README FILE
|
||||
|
||||
@ -143,14 +143,14 @@ information. On Digital Unix, type ``man pfilt''.
|
||||
To build the DHCP Distribution, unpack the compressed tar file using
|
||||
the tar utility and the gzip command - type something like:
|
||||
|
||||
zcat dhcp-3.0.1rc6.tar.gz |tar xvf -
|
||||
zcat dhcp-3.0.1rc8.tar.gz |tar xvf -
|
||||
|
||||
On BSD/OS, you have to type gzcat, not zcat, and you may run into
|
||||
similar problems on other operating systems.
|
||||
|
||||
CONFIGURING IT
|
||||
|
||||
Now, cd to the dhcp-3.0.1rc6 subdirectory that you've just
|
||||
Now, cd to the dhcp-3.0.1rc8 subdirectory that you've just
|
||||
created and configure the source tree by typing:
|
||||
|
||||
./configure
|
||||
|
@ -1,7 +1,7 @@
|
||||
Internet Software Consortium DHCP Distribution
|
||||
Version 3.0.1
|
||||
Release Candidate 6
|
||||
January 17, 2002
|
||||
Release Candidate 8
|
||||
February 21, 2002
|
||||
|
||||
Release Notes
|
||||
|
||||
@ -46,6 +46,80 @@ Murrell at BC Tel Advanced Communications. I'd like to express my
|
||||
thanks to all of these good people here, both for working on the code
|
||||
and for prodding me into improving it.
|
||||
|
||||
Changes since 3.0.1rc7
|
||||
|
||||
- Fix two compiler warnings that are generated when compiling on Solaris
|
||||
with gcc. These stop the build, even though they weren't actually
|
||||
errors, because we prefer that our builds generate no warnings.
|
||||
|
||||
Changes since 3.0.1rc6
|
||||
|
||||
- Don't allow a lease that's in the EXPIRED, RELEASED or RESET state
|
||||
to be renewed.
|
||||
|
||||
- Implement lease stealing for cases where the primary has fewer leases
|
||||
than the secondary, as called for by the standard.
|
||||
|
||||
- Add a fudge factor to the lease expiry acceptance code, (suggested
|
||||
by Kevin Miller of CMU).
|
||||
|
||||
- Fix a bug in permit_list_match that made it much too willing to say
|
||||
that two permit lists matched.
|
||||
|
||||
- Unless DEBUG_DNS_UPDATES is defined, print more user-friendly (and
|
||||
also more compact) messages about DNS updates.
|
||||
|
||||
- Fix a bug in generating wire-format domain names for the FQDN option.
|
||||
|
||||
- Fix a bug where the FQDN option would not be returned if the client
|
||||
requested it, contrary to the standard.
|
||||
|
||||
- On Darwin, use the freebsd DHCP client script.
|
||||
|
||||
- On NetBSD/sparc, don't check for casting warnings.
|
||||
|
||||
- Add a flag in the DHCP client to disable updating the client's A
|
||||
record when sending an FQDN option indicating that the client is
|
||||
going to update its A record.
|
||||
|
||||
- In the client, don't attempt a DNS update until one second after
|
||||
configuring the new IP address, and if the update times out, keep
|
||||
trying until a response, positive or negative, is received from the
|
||||
DNS server.
|
||||
|
||||
- Fix an uninitialized memory bug in the DHCP client.
|
||||
|
||||
- Apply some FreeBSD-specific bug fixes suggested by Murray Stokely.
|
||||
|
||||
- Fix a bug in ns_parserr(), where it was returning the wrong sort
|
||||
of result code in some cases (suggested by Ben Harris of the
|
||||
NetBSD project).
|
||||
|
||||
- Fix a bug in is_identifier(), where it was checking against EOF
|
||||
instead of the END_OF_FILE token (also suggested by Ben Harris).
|
||||
|
||||
- Fix a bug where if an option universe contained no options, the
|
||||
DHCP server could dump core (Walter Steiner).
|
||||
|
||||
- Fix a bug in the handling of encapsulated options.
|
||||
|
||||
- Fix a bug that prevented NWIP suboptions from being processed.
|
||||
|
||||
- Delete the FTS_BOOTP and FTS_RESERVED states and implement them
|
||||
as modifier flags to the FTS_ACTIVE state, as called for in the
|
||||
failover protocol standard.
|
||||
|
||||
- Fix bugs in the pool merging code that resulted in references and
|
||||
dereferences of null pointers. This bug had no impact unless the
|
||||
POINTER_DEBUG flag was defined.
|
||||
|
||||
- In the server, added a do-forward-updates flag that can be used to
|
||||
disable forward updates in all cases, so that sites that want the
|
||||
clients to take sole responsibility for updating their A record can
|
||||
do so.
|
||||
|
||||
- Make it possible to disable optimization of PTR record updates.
|
||||
|
||||
Changes since 3.0.1rc5
|
||||
|
||||
- Include some new documentation and changes provided by Karl Auer.
|
||||
|
@ -3,7 +3,7 @@
|
||||
Parser for dhclient config and lease files... */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-2001 Internet Software Consortium.
|
||||
* Copyright (c) 1996-2002 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: clparse.c,v 1.62.2.1 2001/06/01 17:26:44 mellon Exp $ Copyright (c) 1996-2001 The Internet Software Consortium. All rights reserved.\n";
|
||||
"$Id: clparse.c,v 1.62.2.2 2002/02/09 03:13:17 mellon Exp $ Copyright (c) 1996-2001 The Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
@ -92,6 +92,7 @@ isc_result_t read_client_conf ()
|
||||
top_level_config.script_name = path_dhclient_script;
|
||||
top_level_config.requested_options = default_requested_options;
|
||||
top_level_config.omapi_port = -1;
|
||||
top_level_config.do_forward_update = 1;
|
||||
|
||||
group_allocate (&top_level_config.on_receipt, MDL);
|
||||
if (!top_level_config.on_receipt)
|
||||
@ -460,6 +461,23 @@ void parse_client_statement (cfile, ip, config)
|
||||
parse_semi (cfile);
|
||||
return;
|
||||
|
||||
case DO_FORWARD_UPDATE:
|
||||
token = next_token (&val, (unsigned *)0, cfile);
|
||||
token = next_token (&val, (unsigned *)0, cfile);
|
||||
if (!strcasecmp (val, "on") ||
|
||||
!strcasecmp (val, "true"))
|
||||
config -> do_forward_update = 1;
|
||||
else if (!strcasecmp (val, "off") ||
|
||||
!strcasecmp (val, "false"))
|
||||
config -> do_forward_update = 0;
|
||||
else {
|
||||
parse_warn (cfile, "expecting boolean value.");
|
||||
skip_to_semi (cfile);
|
||||
return;
|
||||
}
|
||||
parse_semi (cfile);
|
||||
return;
|
||||
|
||||
case REBOOT:
|
||||
token = next_token (&val, (unsigned *)0, cfile);
|
||||
parse_lease_time (cfile, &config -> reboot_timeout);
|
||||
|
@ -245,7 +245,7 @@ supplying the
|
||||
.B -nw
|
||||
flag.
|
||||
.SH CONFIGURATION
|
||||
The syntax of the dhclient.conf(8) file is discussed seperately.
|
||||
The syntax of the dhclient.conf(5) file is discussed seperately.
|
||||
.SH OMAPI
|
||||
The DHCP client provides some ability to control it while it is
|
||||
running, without stopping it. This capability is provided using OMAPI,
|
||||
|
@ -3,7 +3,7 @@
|
||||
DHCP Client. */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995-2001 Internet Software Consortium.
|
||||
* Copyright (c) 1995-2002 Internet Software Consortium.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -41,7 +41,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static char ocopyright[] =
|
||||
"$Id: dhclient.c,v 1.129.2.7 2001/08/08 14:46:14 mellon Exp $ Copyright (c) 1995-2001 Internet Software Consortium. All rights reserved.\n";
|
||||
"$Id: dhclient.c,v 1.129.2.9 2002/02/20 07:16:31 mellon Exp $ Copyright (c) 1995-2001 Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
@ -882,7 +882,11 @@ void bind_lease (client)
|
||||
client -> state = S_BOUND;
|
||||
reinitialize_interfaces ();
|
||||
go_daemon ();
|
||||
client_dns_update (client, 1);
|
||||
if (client -> config -> do_forward_update) {
|
||||
client -> dns_update_timeout = 1;
|
||||
add_timeout (cur_time + 1, client_dns_update_timeout,
|
||||
client, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* state_bound is called when we've successfully bound to a particular
|
||||
@ -1183,12 +1187,13 @@ struct client_lease *packet_to_lease (packet, client)
|
||||
memcpy (lease -> address.iabuf, &packet -> raw -> yiaddr,
|
||||
lease -> address.len);
|
||||
|
||||
memset (&data, 0, sizeof data);
|
||||
|
||||
if (client -> config -> vendor_space_name) {
|
||||
i = DHO_VENDOR_ENCAPSULATED_OPTIONS;
|
||||
|
||||
/* See if there was a vendor encapsulation option. */
|
||||
oc = lookup_option (&dhcp_universe, lease -> options, i);
|
||||
memset (&data, 0, sizeof data);
|
||||
if (oc &&
|
||||
client -> config -> vendor_space_name &&
|
||||
evaluate_option_cache (&data, packet,
|
||||
@ -2960,7 +2965,8 @@ isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
|
||||
case server_shutdown:
|
||||
if (client -> active &&
|
||||
client -> active -> expiry > cur_time) {
|
||||
client_dns_update (client, 0);
|
||||
if (client -> config -> do_forward_update)
|
||||
client_dns_update (client, 0, 0);
|
||||
do_release (client);
|
||||
}
|
||||
break;
|
||||
@ -2980,9 +2986,30 @@ isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
|
||||
return ISC_R_SUCCESS;
|
||||
}
|
||||
|
||||
/* Called after a timeout if the DNS update failed on the previous try.
|
||||
Retries the update, and if it times out, schedules a retry after
|
||||
ten times as long of a wait. */
|
||||
|
||||
void client_dns_update_timeout (void *cp)
|
||||
{
|
||||
struct client_state *client = cp;
|
||||
isc_result_t status;
|
||||
|
||||
if (client -> active) {
|
||||
status = client_dns_update (client, 1,
|
||||
(client -> active -> renewal -
|
||||
cur_time));
|
||||
if (status == ISC_R_TIMEDOUT) {
|
||||
client -> dns_update_timeout *= 10;
|
||||
add_timeout (cur_time + client -> dns_update_timeout,
|
||||
client_dns_update_timeout, client, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* See if we should do a DNS update, and if so, do it. */
|
||||
|
||||
void client_dns_update (struct client_state *client, int addp)
|
||||
isc_result_t client_dns_update (struct client_state *client, int addp, int ttl)
|
||||
{
|
||||
struct data_string ddns_fqdn, ddns_fwd_name,
|
||||
ddns_dhcid, client_identifier;
|
||||
@ -2994,11 +3021,11 @@ void client_dns_update (struct client_state *client, int addp)
|
||||
/* If we didn't send an FQDN option, we certainly aren't going to
|
||||
be doing an update. */
|
||||
if (!client -> sent_options)
|
||||
return;
|
||||
return ISC_R_SUCCESS;
|
||||
|
||||
/* If we don't have a lease, we can't do an update. */
|
||||
if (!client -> active)
|
||||
return;
|
||||
return ISC_R_SUCCESS;
|
||||
|
||||
/* If we set the no client update flag, don't do the update. */
|
||||
if ((oc = lookup_option (&fqdn_universe, client -> sent_options,
|
||||
@ -3008,7 +3035,7 @@ void client_dns_update (struct client_state *client, int addp)
|
||||
client -> sent_options,
|
||||
(struct option_state *)0,
|
||||
&global_scope, oc, MDL))
|
||||
return;
|
||||
return ISC_R_SUCCESS;
|
||||
|
||||
/* If we set the "server, please update" flag, or didn't set it
|
||||
to false, don't do the update. */
|
||||
@ -3019,7 +3046,7 @@ void client_dns_update (struct client_state *client, int addp)
|
||||
client -> sent_options,
|
||||
(struct option_state *)0,
|
||||
&global_scope, oc, MDL))
|
||||
return;
|
||||
return ISC_R_SUCCESS;
|
||||
|
||||
/* If no FQDN option was supplied, don't do the update. */
|
||||
memset (&ddns_fwd_name, 0, sizeof ddns_fwd_name);
|
||||
@ -3030,7 +3057,7 @@ void client_dns_update (struct client_state *client, int addp)
|
||||
client -> sent_options,
|
||||
(struct option_state *)0,
|
||||
&global_scope, oc, MDL))
|
||||
return;
|
||||
return ISC_R_SUCCESS;
|
||||
|
||||
/* Make a dhcid string out of either the client identifier,
|
||||
if we are sending one, or the interface's MAC address,
|
||||
@ -3056,7 +3083,7 @@ void client_dns_update (struct client_state *client, int addp)
|
||||
client -> interface -> hw_address.hlen);
|
||||
if (!result) {
|
||||
data_string_forget (&ddns_fwd_name, MDL);
|
||||
return;
|
||||
return ISC_R_SUCCESS;
|
||||
}
|
||||
|
||||
/* Start the resolver, if necessary. */
|
||||
@ -3074,7 +3101,7 @@ void client_dns_update (struct client_state *client, int addp)
|
||||
if (addp)
|
||||
rcode = ddns_update_a (&ddns_fwd_name,
|
||||
client -> active -> address,
|
||||
&ddns_dhcid, DEFAULT_DDNS_TTL,
|
||||
&ddns_dhcid, ttl,
|
||||
1);
|
||||
else
|
||||
rcode = ddns_remove_a (&ddns_fwd_name,
|
||||
@ -3084,4 +3111,5 @@ void client_dns_update (struct client_state *client, int addp)
|
||||
|
||||
data_string_forget (&ddns_fwd_name, MDL);
|
||||
data_string_forget (&ddns_dhcid, MDL);
|
||||
return rcode;
|
||||
}
|
||||
|
@ -247,6 +247,22 @@ The \fIfqdn.fqdn\fR option \fBMUST\fR be a fully-qualified domain
|
||||
name. You \fBMUST\fR define a zone statement for the zone to be
|
||||
updated. The \fIfqdn.encoded\fR option may need to be set to
|
||||
\fIon\fR or \fIoff\fR, depending on the DHCP server you are using.
|
||||
.PP
|
||||
.I The
|
||||
.B no-client-updates
|
||||
.I statement
|
||||
.PP
|
||||
\fBno-client-updates [ \fIflag\fR ] \fB;\fR
|
||||
.PP
|
||||
If you want to do DNS updates in the DHCP client
|
||||
script (see \fBdhclient-script(8)\fR) rather than having the
|
||||
DHCP client do the update directly (for example, if you want to
|
||||
use SIG(0) authentication, which is not supported directly by the
|
||||
DHCP client, you can instruct the client not to do the update using
|
||||
the \fBno-client-updates\fR statement. \fIFlag\fR should be \fBtrue\fR
|
||||
if you don't want the DHCP client to do the update, and \fBfalse\fR if
|
||||
you want the DHCP client to do the update. By default, the DHCP
|
||||
client will do the DNS update.
|
||||
.SH OPTION MODIFIERS
|
||||
In some cases, a client may receive option data from the server which
|
||||
is not really appropriate for that client, or may not receive
|
||||
@ -319,7 +335,7 @@ enforced - if you ignore it, the behaviour will be unpredictable.
|
||||
\fBlease {\fR \fIlease-declaration\fR [ ... \fIlease-declaration ] \fB}\fR
|
||||
.PP
|
||||
The DHCP client may decide after some period of time (see \fBPROTOCOL
|
||||
TIMING\fR) decide that it is not going to succeed in contacting a
|
||||
TIMING\fR) that it is not going to succeed in contacting a
|
||||
server. At that time, it consults its own database of old leases and
|
||||
tests each one that has not yet timed out by pinging the listed router
|
||||
for that lease to see if that lease could work. It is possible to
|
||||
@ -430,7 +446,7 @@ initializing the interface. On Unix and Unix-like systems, the
|
||||
argument is passed on the ifconfig command line when configuring te
|
||||
interface.
|
||||
.PP
|
||||
The dhcp client automatically declares this parameter if it used a
|
||||
The dhcp client automatically declares this parameter if it uses a
|
||||
media type (see the
|
||||
.B media
|
||||
statement) when configuring the interface in order to obtain a lease.
|
||||
@ -493,7 +509,9 @@ declaration.
|
||||
.SH OTHER DECLARATIONS
|
||||
\fBreject \fIip-address\fB;\fR
|
||||
.PP
|
||||
The reject statement causes the DHCP client to reject offers from
|
||||
The
|
||||
.B reject
|
||||
statement causes the DHCP client to reject offers from
|
||||
servers who use the specified address as a server identifier. This
|
||||
can be used to avoid being configured by rogue or misconfigured dhcp
|
||||
servers, although it should be a last resort - better to track down
|
||||
@ -554,7 +572,7 @@ succeeds in getting a request to the server and hearing the reply is
|
||||
probably right (no guarantees).
|
||||
.PP
|
||||
The media setup is only used for the initial phase of address
|
||||
acquisition (the DHCPDISCOVER and DHCPOFFER packtes). Once an
|
||||
acquisition (the DHCPDISCOVER and DHCPOFFER packets). Once an
|
||||
address has been acquired, the dhcp client will record it in its lease
|
||||
database and will record the media type used to acquire the address.
|
||||
Whenever the client tries to renew the lease, it will use that same
|
||||
@ -586,7 +604,7 @@ interface "ep0" {
|
||||
request subnet-mask, broadcast-address, time-offset, routers,
|
||||
domain-name, domain-name-servers, host-name;
|
||||
require subnet-mask, domain-name-servers;
|
||||
script "/etc/dhclient-script";
|
||||
script "CLIENTBINDIR/dhclient-script";
|
||||
media "media 10baseT/UTP", "media 10base2/BNC";
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
# $FreeBSD$
|
||||
|
||||
if [ -x /usr/bin/logger ]; then
|
||||
LOGGER="/usr/bin/logger -s -p user.notice -t dhclient"
|
||||
else
|
||||
@ -80,7 +82,7 @@ fi
|
||||
|
||||
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
|
||||
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
|
||||
current_hostname=`hostname`
|
||||
current_hostname=`/bin/hostname`
|
||||
if [ x$current_hostname = x ] || \
|
||||
[ x$current_hostname = x$old_host_name ]; then
|
||||
if [ x$current_hostname = x ] || \
|
||||
@ -101,7 +103,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
|
||||
for router in $old_routers; do
|
||||
route delete default $router >/dev/null 2>&1
|
||||
done
|
||||
if [ "$old_static_routes" != "" ]; then
|
||||
if [ -n "$old_static_routes" ]; then
|
||||
set -- $old_static_routes
|
||||
while [ $# -gt 1 ]; do
|
||||
route delete $1 $2
|
||||
@ -114,17 +116,17 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
|
||||
[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
|
||||
eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
|
||||
$new_broadcast_arg $medium"
|
||||
$LOGGER "New IP Address($interface): $new_ip_address"
|
||||
$LOGGER "New Subnet Mask($interface): $new_subnet_mask"
|
||||
$LOGGER "New Broadcast Address($interface): $new_broadcast_address"
|
||||
if [ "$new_routers" != "" ]; then
|
||||
$LOGGER "New IP Address ($interface): $new_ip_address"
|
||||
$LOGGER "New Subnet Mask ($interface): $new_subnet_mask"
|
||||
$LOGGER "New Broadcast Address ($interface): $new_broadcast_address"
|
||||
if [ -n "$new_routers" ]; then
|
||||
$LOGGER "New Routers: $new_routers"
|
||||
fi
|
||||
route add $new_ip_address 127.1 >/dev/null 2>&1
|
||||
for router in $new_routers; do
|
||||
route add default $router >/dev/null 2>&1
|
||||
done
|
||||
if [ "$new_static_routes" != "" ]; then
|
||||
if [ -n "$new_static_routes" ]; then
|
||||
$LOGGER "New Static Routes: $new_static_routes"
|
||||
set -- $new_static_routes
|
||||
while [ $# -gt 1 ]; do
|
||||
@ -154,14 +156,14 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
|
||||
for router in $old_routers; do
|
||||
route delete default $router >/dev/null 2>&1
|
||||
done
|
||||
if [ "$old_static_routes" != "" ]; then
|
||||
if [ -n "$old_static_routes" ]; then
|
||||
set -- $old_static_routes
|
||||
while [ $# -gt 1 ]; do
|
||||
route delete $1 $2
|
||||
shift; shift
|
||||
done
|
||||
fi
|
||||
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
|
||||
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \
|
||||
|sh >/dev/null 2>&1
|
||||
fi
|
||||
if [ x$alias_ip_address != x ]; then
|
||||
@ -178,11 +180,11 @@ if [ x$reason = xTIMEOUT ]; then
|
||||
fi
|
||||
eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
|
||||
$new_broadcast_arg $medium"
|
||||
$LOGGER "New IP Address($interface): $new_ip_address"
|
||||
$LOGGER "New Subnet Mask($interface): $new_subnet_mask"
|
||||
$LOGGER "New Broadcast Address($interface): $new_broadcast_address"
|
||||
$LOGGER "New IP Address ($interface): $new_ip_address"
|
||||
$LOGGER "New Subnet Mask ($interface): $new_subnet_mask"
|
||||
$LOGGER "New Broadcast Address ($interface): $new_broadcast_address"
|
||||
sleep 1
|
||||
if [ "$new_routers" != "" ]; then
|
||||
if [ -n "$new_routers" ]; then
|
||||
$LOGGER "New Routers: $new_routers"
|
||||
set -- $new_routers
|
||||
if ping -q -c 1 $1; then
|
||||
@ -208,7 +210,7 @@ if [ x$reason = xTIMEOUT ]; then
|
||||
for router in $old_routers; do
|
||||
route delete default $router >/dev/null 2>&1
|
||||
done
|
||||
if [ "$old_static_routes" != "" ]; then
|
||||
if [ -n "$old_static_routes" ]; then
|
||||
set -- $old_static_routes
|
||||
while [ $# -gt 1 ]; do
|
||||
route delete $1 $2
|
||||
|
@ -3,7 +3,7 @@
|
||||
Lexical scanner for dhcpd config file... */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995-2001 Internet Software Consortium.
|
||||
* Copyright (c) 1995-2002 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: conflex.c,v 1.92.2.4 2002/01/10 19:35:59 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
|
||||
"$Id: conflex.c,v 1.92.2.5 2002/02/09 03:15:17 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
@ -612,6 +612,8 @@ static enum dhcp_token intern (atom, dfv)
|
||||
return DOMAIN;
|
||||
if (!strcasecmp (atom + 1, "omain-name"))
|
||||
return DOMAIN_NAME;
|
||||
if (!strcasecmp (atom + 1, "o-forward-update"))
|
||||
return DO_FORWARD_UPDATE;
|
||||
if (!strcasecmp (atom + 1, "ebug"))
|
||||
return TOKEN_DEBUG;
|
||||
if (!strcasecmp (atom + 1, "eny"))
|
||||
|
@ -426,7 +426,9 @@ to the client. Servers should be listed in order of preference.
|
||||
This option specifies the name of the client. The name may or may
|
||||
not be qualified with the local domain name (it is preferable to use
|
||||
the domain-name option to specify the domain name). See RFC 1035 for
|
||||
character set restrictions.
|
||||
character set restrictions. This option is only honored by
|
||||
.B dhclient-script(8)
|
||||
if the hostname for the client machine is not set.
|
||||
.RE
|
||||
.PP
|
||||
.B option \fBieee802-3-encapsulation\fR \fIflag\fR\fB;\fR
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"$Id: dns.c,v 1.35.2.10 2001/10/26 21:26:39 mellon Exp $ Copyright (c) 2001 The Internet Software Consortium. All rights reserved.\n";
|
||||
"$Id: dns.c,v 1.35.2.12 2002/02/20 22:28:17 mellon Exp $ Copyright (c) 2001 The Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
@ -619,14 +619,9 @@ isc_result_t ddns_update_a (struct data_string *ddns_fwd_name,
|
||||
*/
|
||||
result = minires_nupdate (&resolver_state, ISC_LIST_HEAD (updqueue));
|
||||
|
||||
#ifdef DEBUG_DNS_UPDATES
|
||||
print_dns_status ((int)result, &updqueue);
|
||||
|
||||
while (!ISC_LIST_EMPTY (updqueue)) {
|
||||
updrec = ISC_LIST_HEAD (updqueue);
|
||||
ISC_LIST_UNLINK (updqueue, updrec, r_link);
|
||||
minires_freeupdrec (updrec);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If this update operation succeeds, the updater can conclude that it
|
||||
@ -636,8 +631,12 @@ isc_result_t ddns_update_a (struct data_string *ddns_fwd_name,
|
||||
* -- "Interaction between DHCP and DNS"
|
||||
*/
|
||||
|
||||
if (result == ISC_R_SUCCESS)
|
||||
return result;
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
log_info ("Added new forward map from %.*s to %s",
|
||||
(int)ddns_fwd_name -> len,
|
||||
(const char *)ddns_fwd_name -> data, ddns_address);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -653,9 +652,19 @@ isc_result_t ddns_update_a (struct data_string *ddns_fwd_name,
|
||||
* -- "Interaction between DHCP and DNS"
|
||||
*/
|
||||
|
||||
if (result != (rrsetp ? ISC_R_YXRRSET : ISC_R_YXDOMAIN))
|
||||
return result;
|
||||
if (result != (rrsetp ? ISC_R_YXRRSET : ISC_R_YXDOMAIN)) {
|
||||
log_error ("Unable to add forward map from %.*s to %s: %s",
|
||||
(int)ddns_fwd_name -> len,
|
||||
(const char *)ddns_fwd_name -> data, ddns_address,
|
||||
isc_result_totext (result));
|
||||
goto error;
|
||||
}
|
||||
|
||||
while (!ISC_LIST_EMPTY (updqueue)) {
|
||||
updrec = ISC_LIST_HEAD (updqueue);
|
||||
ISC_LIST_UNLINK (updqueue, updrec, r_link);
|
||||
minires_freeupdrec (updrec);
|
||||
}
|
||||
|
||||
/*
|
||||
* DHCID RR exists, and matches client identity.
|
||||
@ -716,7 +725,27 @@ isc_result_t ddns_update_a (struct data_string *ddns_fwd_name,
|
||||
*/
|
||||
result = minires_nupdate (&resolver_state, ISC_LIST_HEAD (updqueue));
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
if (result == YXRRSET || result == YXDOMAIN ||
|
||||
result == NXRRSET || result == NXDOMAIN)
|
||||
log_error ("Forward map from %.*s to %s already in use",
|
||||
(int)ddns_fwd_name -> len,
|
||||
(const char *)ddns_fwd_name -> data,
|
||||
ddns_address);
|
||||
else
|
||||
log_error ("Can't update forward map %.*s to %s: %s",
|
||||
(int)ddns_fwd_name -> len,
|
||||
(const char *)ddns_fwd_name -> data,
|
||||
ddns_address, isc_result_totext (result));
|
||||
|
||||
} else {
|
||||
log_info ("Added new forward map from %.*s to %s",
|
||||
(int)ddns_fwd_name -> len,
|
||||
(const char *)ddns_fwd_name -> data, ddns_address);
|
||||
}
|
||||
#if defined (DEBUG_DNS_UPDATES)
|
||||
print_dns_status ((int)result, &updqueue);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If this query succeeds, the updater can conclude that the current
|
||||
|
@ -3,7 +3,7 @@
|
||||
DHCP options parsing and reassembly. */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995-2001 Internet Software Consortium.
|
||||
* Copyright (c) 1995-2002 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: options.c,v 1.85.2.6 2001/10/18 20:11:38 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
|
||||
"$Id: options.c,v 1.85.2.8 2002/02/19 20:36:52 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#define DHCP_OPTION_DATA
|
||||
@ -373,9 +373,16 @@ int fqdn_universe_decode (struct option_state *options,
|
||||
|
||||
*s = '.';
|
||||
s += len + 1;
|
||||
total_len += len;
|
||||
total_len += len + 1;
|
||||
}
|
||||
|
||||
/* We wind up with a length that's one too many because
|
||||
we shouldn't increment for the last label, but there's
|
||||
no way to tell we're at the last label until we exit
|
||||
the loop. :'*/
|
||||
if (total_len > 0)
|
||||
total_len--;
|
||||
|
||||
if (!terminated) {
|
||||
first_len = total_len;
|
||||
}
|
||||
@ -508,6 +515,7 @@ int cons_options (inpacket, outpacket, lease, client_state,
|
||||
priority_list [priority_len++] = DHO_DHCP_LEASE_TIME;
|
||||
priority_list [priority_len++] = DHO_DHCP_MESSAGE;
|
||||
priority_list [priority_len++] = DHO_DHCP_REQUESTED_ADDRESS;
|
||||
priority_list [priority_len++] = DHO_FQDN;
|
||||
|
||||
if (prl && prl -> len > 0) {
|
||||
if ((op = lookup_option (&dhcp_universe, cfg_options,
|
||||
@ -544,7 +552,8 @@ int cons_options (inpacket, outpacket, lease, client_state,
|
||||
if (cfg_options -> site_code_min) {
|
||||
for (i = 0; i < OPTION_HASH_SIZE; i++) {
|
||||
hash = cfg_options -> universes [dhcp_universe.index];
|
||||
for (pp = hash [i]; pp; pp = pp -> cdr) {
|
||||
if (hash) {
|
||||
for (pp = hash [i]; pp; pp = pp -> cdr) {
|
||||
op = (struct option_cache *)(pp -> car);
|
||||
if (op -> option -> code <
|
||||
cfg_options -> site_code_min &&
|
||||
@ -553,6 +562,7 @@ int cons_options (inpacket, outpacket, lease, client_state,
|
||||
DHO_DHCP_AGENT_OPTIONS))
|
||||
priority_list [priority_len++] =
|
||||
op -> option -> code;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -561,8 +571,9 @@ int cons_options (inpacket, outpacket, lease, client_state,
|
||||
is no site option space, we'll be cycling through the
|
||||
dhcp option space. */
|
||||
for (i = 0; i < OPTION_HASH_SIZE; i++) {
|
||||
hash = (cfg_options -> universes
|
||||
[cfg_options -> site_universe]);
|
||||
hash = (cfg_options -> universes
|
||||
[cfg_options -> site_universe]);
|
||||
if (hash)
|
||||
for (pp = hash [i]; pp; pp = pp -> cdr) {
|
||||
op = (struct option_cache *)(pp -> car);
|
||||
if (op -> option -> code >=
|
||||
@ -770,8 +781,9 @@ int store_options (buffer, buflen, packet, lease, client_state,
|
||||
to be encapsulated first, except that if it's a straight
|
||||
encapsulation and the user has provided a value for the
|
||||
encapsulation option, use the user-provided value. */
|
||||
if ((u -> options [code] -> format [0] == 'E' && !oc) ||
|
||||
u -> options [code] -> format [0] == 'e') {
|
||||
if (u -> options [code] &&
|
||||
((u -> options [code] -> format [0] == 'E' && !oc) ||
|
||||
u -> options [code] -> format [0] == 'e')) {
|
||||
int uix;
|
||||
static char *s, *t;
|
||||
struct option_cache *tmp;
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"$Id: print.c,v 1.53.2.4 2001/08/08 14:49:20 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
|
||||
"$Id: print.c,v 1.53.2.5 2002/02/09 03:23:19 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
@ -1197,6 +1197,14 @@ void print_dns_status (int status, ns_updque *uq)
|
||||
}
|
||||
predicate = "and";
|
||||
}
|
||||
if (u -> r_dname) {
|
||||
if (s + 1 < end)
|
||||
*s++ = ' ';
|
||||
if (s + strlen (u -> r_dname) < end) {
|
||||
strcpy (s, u -> r_dname);
|
||||
s += strlen (s);
|
||||
}
|
||||
}
|
||||
if (ttlp) {
|
||||
if (s + 1 < end)
|
||||
*s++ = ' ';
|
||||
@ -1253,14 +1261,6 @@ void print_dns_status (int status, ns_updque *uq)
|
||||
strcpy (s, en);
|
||||
s += strlen (en);
|
||||
}
|
||||
if (u -> r_dname) {
|
||||
if (s + 1 < end)
|
||||
*s++ = ' ';
|
||||
if (s + strlen (u -> r_dname) < end) {
|
||||
strcpy (s, u -> r_dname);
|
||||
s += strlen (s);
|
||||
}
|
||||
}
|
||||
if (u -> r_data) {
|
||||
if (s + 1 < end)
|
||||
*s++ = ' ';
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"$Id: tables.c,v 1.51.2.4 2001/10/17 03:26:26 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
|
||||
"$Id: tables.c,v 1.51.2.5 2002/02/09 03:23:54 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
@ -1195,7 +1195,7 @@ void initialize_common_option_spaces()
|
||||
nwip_universe.tag_size = 1;
|
||||
nwip_universe.store_tag = putUChar;
|
||||
nwip_universe.store_length = putUChar;
|
||||
fqdn_universe.enc_opt = &dhcp_options [DHO_NWIP_SUBOPTIONS];
|
||||
nwip_universe.enc_opt = &dhcp_options [DHO_NWIP_SUBOPTIONS];
|
||||
nwip_universe.index = universe_count++;
|
||||
universes [nwip_universe.index] = &nwip_universe;
|
||||
option_new_hash (&nwip_universe.hash, 1, MDL);
|
||||
|
1
contrib/isc-dhcp/configure
vendored
1
contrib/isc-dhcp/configure
vendored
@ -118,6 +118,7 @@ if [ "$sysname" = "" ]; then
|
||||
case $hw in
|
||||
arm32) sysname=netbsd-nocast;;
|
||||
alpha) sysname=netbsd-nocast;;
|
||||
sparc) sysname=netbsd-nocast;;
|
||||
*) sysname=netbsd;;
|
||||
esac;;
|
||||
OpenBSD)
|
||||
|
@ -272,8 +272,7 @@ typedef enum {
|
||||
FTS_ABANDONED = 5,
|
||||
FTS_RESET = 6,
|
||||
FTS_BACKUP = 7,
|
||||
FTS_RESERVED = 8,
|
||||
FTS_BOOTP = 9
|
||||
FTS_LAST = 8
|
||||
} binding_state_t;
|
||||
|
||||
/* A dhcp lease declaration structure. */
|
||||
@ -304,16 +303,19 @@ struct lease {
|
||||
|
||||
u_int8_t flags;
|
||||
# define STATIC_LEASE 1
|
||||
# define BOOTP_LEASE 2
|
||||
# define PERSISTENT_FLAGS (ON_ACK_QUEUE | ON_UPDATE_QUEUE)
|
||||
# define MS_NULL_TERMINATION 8
|
||||
# define ON_UPDATE_QUEUE 16
|
||||
# define ON_ACK_QUEUE 32
|
||||
# define UNICAST_BROADCAST_HACK 64
|
||||
# define ON_DEFERRED_QUEUE 128
|
||||
# define EPHEMERAL_FLAGS (MS_NULL_TERMINATION | \
|
||||
UNICAST_BROADCAST_HACK)
|
||||
|
||||
binding_state_t __attribute__ ((mode (__byte__))) binding_state;
|
||||
binding_state_t __attribute__ ((mode (__byte__))) next_binding_state;
|
||||
binding_state_t __attribute__ ((mode (__byte__))) desired_binding_state;
|
||||
|
||||
struct lease_state *state;
|
||||
|
||||
@ -415,6 +417,7 @@ struct lease_state {
|
||||
#define SV_PING_CHECKS 42
|
||||
#define SV_UPDATE_STATIC_LEASES 43
|
||||
#define SV_LOG_FACILITY 44
|
||||
#define SV_DO_FORWARD_UPDATES 45
|
||||
|
||||
#if !defined (DEFAULT_DEFAULT_LEASE_TIME)
|
||||
# define DEFAULT_DEFAULT_LEASE_TIME 43200
|
||||
@ -717,6 +720,9 @@ struct client_config {
|
||||
int omapi_port; /* port on which to accept OMAPI
|
||||
connections, or -1 for no
|
||||
listener. */
|
||||
int do_forward_update; /* If nonzero, and if we have the
|
||||
information we need, update the
|
||||
A record for the address we get. */
|
||||
};
|
||||
|
||||
/* Per-interface state used in the dhcp client... */
|
||||
@ -737,6 +743,7 @@ struct client_state {
|
||||
u_int16_t secs; /* secs value from DHCPDISCOVER. */
|
||||
TIME first_sending; /* When was first copy sent? */
|
||||
TIME interval; /* What's the current resend interval? */
|
||||
int dns_update_timeout; /* Last timeout set for DNS update. */
|
||||
struct string_list *medium; /* Last media type tried. */
|
||||
struct dhcp_packet packet; /* Outgoing DHCP packet. */
|
||||
unsigned packet_length; /* Actual length of generated packet. */
|
||||
@ -1891,7 +1898,8 @@ void do_release PROTO ((struct client_state *));
|
||||
int dhclient_interface_shutdown_hook (struct interface_info *);
|
||||
int dhclient_interface_discovery_hook (struct interface_info *);
|
||||
isc_result_t dhclient_interface_startup_hook (struct interface_info *);
|
||||
void client_dns_update (struct client_state *client, int);
|
||||
void client_dns_update_timeout (void *cp);
|
||||
isc_result_t client_dns_update (struct client_state *client, int, int);
|
||||
|
||||
/* db.c */
|
||||
int write_lease PROTO ((struct lease *));
|
||||
@ -1904,6 +1912,7 @@ int db_printable_len PROTO ((const unsigned char *, unsigned));
|
||||
void write_named_billing_class (const char *, unsigned, struct class *);
|
||||
void write_billing_classes (void);
|
||||
int write_billing_class PROTO ((struct class *));
|
||||
void commit_leases_timeout PROTO ((void *));
|
||||
int commit_leases PROTO ((void));
|
||||
void db_startup PROTO ((int));
|
||||
int new_lease_file PROTO ((void));
|
||||
|
@ -3,7 +3,7 @@
|
||||
Tokens for config file lexer and parser. */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-1999 Internet Software Consortium.
|
||||
* Copyright (c) 1996-2002 Internet Software Consortium.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -315,10 +315,11 @@ enum dhcp_token {
|
||||
CONNECT = 610,
|
||||
REMOVE = 611,
|
||||
REFRESH = 612,
|
||||
DOMAIN_NAME = 613
|
||||
DOMAIN_NAME = 613,
|
||||
DO_FORWARD_UPDATE = 614
|
||||
};
|
||||
|
||||
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
|
||||
(x) != STRING && \
|
||||
(x) != NUMBER && \
|
||||
(x) != EOF)
|
||||
(x) != END_OF_FILE)
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "cdefs.h"
|
||||
#include "osdep.h"
|
||||
|
||||
#define _ns_flagdata MR_ns_flagdata
|
||||
|
||||
#include "minires/resolv.h"
|
||||
#include "minires/res_update.h"
|
||||
#include "isc-dhcp/result.h"
|
||||
@ -151,7 +153,7 @@ isc_result_t res_nmkquery (res_state, int, const char *, ns_class, ns_type,
|
||||
const unsigned char *, unsigned,
|
||||
const unsigned char *, double *,
|
||||
unsigned, unsigned *);
|
||||
int ns_initparse (const unsigned char *, unsigned, ns_msg *);
|
||||
isc_result_t ns_initparse (const unsigned char *, unsigned, ns_msg *);
|
||||
isc_result_t res_nquery(res_state, const char *,
|
||||
ns_class, ns_type, double *, unsigned, unsigned *);
|
||||
isc_result_t res_nsearch(res_state, const char *,
|
||||
@ -161,7 +163,8 @@ isc_result_t res_nquerydomain(res_state, const char *, const char *,
|
||||
ns_class class, ns_type type,
|
||||
double *, unsigned, unsigned *);
|
||||
|
||||
int ns_skiprr(const unsigned char *, const unsigned char *, ns_sect, int);
|
||||
isc_result_t ns_skiprr(const unsigned char *,
|
||||
const unsigned char *, ns_sect, int, int *);
|
||||
int dn_skipname (const unsigned char *, const unsigned char *);
|
||||
u_int32_t getULong (const unsigned char *);
|
||||
int32_t getLong (const unsigned char *);
|
||||
|
@ -86,6 +86,11 @@
|
||||
|
||||
/* #define DEBUG_FAILOVER_TIMING */
|
||||
|
||||
/* Define this if you want all leases written to the lease file, even if
|
||||
they are free leases that have never been used. */
|
||||
|
||||
#define DEBUG_DUMP_ALL_LEASES
|
||||
|
||||
/* Define this if you want DHCP failover protocol support in the DHCP
|
||||
server. */
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
/* Current version of ISC DHCP Distribution. */
|
||||
|
||||
#define DHCP_VERSION "V3.0.1rc6"
|
||||
#define DHCP_VERSION "V3.0.1rc8"
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "$Id: ns_parse.c,v 1.2 2001/01/16 22:33:08 mellon Exp $";
|
||||
static const char rcsid[] = "$Id: ns_parse.c,v 1.2.2.1 2002/02/19 19:16:52 mellon Exp $";
|
||||
#endif
|
||||
|
||||
/* Import. */
|
||||
@ -38,8 +38,6 @@ static void setsection(ns_msg *msg, ns_sect sect);
|
||||
|
||||
/* Macros. */
|
||||
|
||||
#define RETERR(err) do { errno = (err); return (-1); } while (0)
|
||||
|
||||
/* Public. */
|
||||
|
||||
/* These need to be in the same order as the nres.h:ns_flag enum. */
|
||||
@ -62,8 +60,9 @@ struct _ns_flagdata _ns_flagdata[16] = {
|
||||
{ 0x0000, 0 }, /* expansion (6/6). */
|
||||
};
|
||||
|
||||
int
|
||||
ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count) {
|
||||
isc_result_t
|
||||
ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count,
|
||||
int *rc) {
|
||||
const u_char *optr = ptr;
|
||||
|
||||
for ((void)NULL; count > 0; count--) {
|
||||
@ -71,11 +70,11 @@ ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count) {
|
||||
|
||||
b = dn_skipname(ptr, eom);
|
||||
if (b < 0)
|
||||
RETERR(EMSGSIZE);
|
||||
return ISC_R_INCOMPLETE;
|
||||
ptr += b/*Name*/ + NS_INT16SZ/*Type*/ + NS_INT16SZ/*Class*/;
|
||||
if (section != ns_s_qd) {
|
||||
if (ptr + NS_INT32SZ + NS_INT16SZ > eom)
|
||||
RETERR(EMSGSIZE);
|
||||
return ISC_R_INCOMPLETE;
|
||||
ptr += NS_INT32SZ/*TTL*/;
|
||||
rdlength = getUShort(ptr);
|
||||
ptr += 2;
|
||||
@ -83,11 +82,13 @@ ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count) {
|
||||
}
|
||||
}
|
||||
if (ptr > eom)
|
||||
RETERR(EMSGSIZE);
|
||||
return (ptr - optr);
|
||||
return ISC_R_INCOMPLETE;
|
||||
if (rc)
|
||||
*rc = ptr - optr;
|
||||
return ISC_R_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
isc_result_t
|
||||
ns_initparse(const u_char *msg, unsigned msglen, ns_msg *handle) {
|
||||
const u_char *eom = msg + msglen;
|
||||
int i;
|
||||
@ -96,16 +97,16 @@ ns_initparse(const u_char *msg, unsigned msglen, ns_msg *handle) {
|
||||
handle->_msg = msg;
|
||||
handle->_eom = eom;
|
||||
if (msg + NS_INT16SZ > eom)
|
||||
RETERR(EMSGSIZE);
|
||||
return ISC_R_INCOMPLETE;
|
||||
handle->_id = getUShort (msg);
|
||||
msg += 2;
|
||||
if (msg + NS_INT16SZ > eom)
|
||||
RETERR(EMSGSIZE);
|
||||
return ISC_R_INCOMPLETE;
|
||||
handle->_flags = getUShort (msg);
|
||||
msg += 2;
|
||||
for (i = 0; i < ns_s_max; i++) {
|
||||
if (msg + NS_INT16SZ > eom)
|
||||
RETERR(EMSGSIZE);
|
||||
return ISC_R_INCOMPLETE;
|
||||
handle->_counts[i] = getUShort (msg);
|
||||
msg += 2;
|
||||
}
|
||||
@ -113,23 +114,26 @@ ns_initparse(const u_char *msg, unsigned msglen, ns_msg *handle) {
|
||||
if (handle->_counts[i] == 0)
|
||||
handle->_sections[i] = NULL;
|
||||
else {
|
||||
int b = ns_skiprr(msg, eom, (ns_sect)i,
|
||||
handle->_counts[i]);
|
||||
int b;
|
||||
isc_result_t status =
|
||||
ns_skiprr(msg, eom, (ns_sect)i,
|
||||
handle->_counts[i], &b);
|
||||
|
||||
if (b < 0)
|
||||
return (-1);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return STATUS;
|
||||
handle->_sections[i] = msg;
|
||||
msg += b;
|
||||
}
|
||||
if (msg != eom)
|
||||
RETERR(EMSGSIZE);
|
||||
return ISC_R_INCOMPLETE;
|
||||
setsection(handle, ns_s_max);
|
||||
return (0);
|
||||
return ISC_R_SUCCESS;
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
|
||||
int b;
|
||||
isc_result_t status;
|
||||
|
||||
/* Make section right. */
|
||||
if (section < 0 || section >= ns_s_max)
|
||||
@ -141,15 +145,15 @@ ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
|
||||
if (rrnum == -1)
|
||||
rrnum = handle->_rrnum;
|
||||
if (rrnum < 0 || rrnum >= handle->_counts[(int)section])
|
||||
RETERR(ENODEV);
|
||||
return ISC_R_UNKNOWNATTRIBUTE;
|
||||
if (rrnum < handle->_rrnum)
|
||||
setsection(handle, section);
|
||||
if (rrnum > handle->_rrnum) {
|
||||
b = ns_skiprr(handle->_ptr, handle->_eom, section,
|
||||
rrnum - handle->_rrnum);
|
||||
status = ns_skiprr(handle->_ptr, handle->_eom, section,
|
||||
rrnum - handle->_rrnum, &b);
|
||||
|
||||
if (b < 0)
|
||||
return (-1);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
handle->_ptr += b;
|
||||
handle->_rrnum = rrnum;
|
||||
}
|
||||
@ -158,10 +162,10 @@ ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
|
||||
b = dn_expand(handle->_msg, handle->_eom,
|
||||
handle->_ptr, rr->name, NS_MAXDNAME);
|
||||
if (b < 0)
|
||||
return (-1);
|
||||
return ISC_R_FORMERR;
|
||||
handle->_ptr += b;
|
||||
if (handle->_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom)
|
||||
return ISC_R_NOSPACE;
|
||||
return ISC_R_INCOMPLETE;
|
||||
rr->type = getUShort (handle->_ptr);
|
||||
handle -> _ptr += 2;
|
||||
rr->rr_class = getUShort (handle->_ptr);
|
||||
@ -172,13 +176,13 @@ ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
|
||||
rr->rdata = NULL;
|
||||
} else {
|
||||
if (handle->_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom)
|
||||
return ISC_R_NOSPACE;
|
||||
return ISC_R_INCOMPLETE;
|
||||
rr->ttl = getULong (handle->_ptr);
|
||||
handle -> _ptr += 4;
|
||||
rr->rdlength = getUShort (handle->_ptr);
|
||||
handle -> _ptr += 2;
|
||||
if (handle->_ptr + rr->rdlength > handle->_eom)
|
||||
return ISC_R_NOSPACE;
|
||||
return ISC_R_INCOMPLETE;
|
||||
rr->rdata = handle->_ptr;
|
||||
handle->_ptr += rr->rdlength;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "$Id: ns_verify.c,v 1.5.2.1 2001/05/17 20:47:34 mellon Exp $";
|
||||
static const char rcsid[] = "$Id: ns_verify.c,v 1.5.2.2 2002/02/19 19:23:31 mellon Exp $";
|
||||
#endif
|
||||
|
||||
#define time(x) trace_mr_time (x)
|
||||
@ -60,6 +60,7 @@ ns_find_tsig(u_char *msg, u_char *eom) {
|
||||
HEADER *hp = (HEADER *)msg;
|
||||
int n, type;
|
||||
u_char *cp = msg, *start;
|
||||
isc_result_t status;
|
||||
|
||||
if (msg == NULL || eom == NULL || msg > eom)
|
||||
return (NULL);
|
||||
@ -72,23 +73,23 @@ ns_find_tsig(u_char *msg, u_char *eom) {
|
||||
|
||||
cp += HFIXEDSZ;
|
||||
|
||||
n = ns_skiprr(cp, eom, ns_s_qd, ntohs(hp->qdcount));
|
||||
if (n < 0)
|
||||
status = ns_skiprr(cp, eom, ns_s_qd, ntohs(hp->qdcount), &n);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return (NULL);
|
||||
cp += n;
|
||||
|
||||
n = ns_skiprr(cp, eom, ns_s_an, ntohs(hp->ancount));
|
||||
if (n < 0)
|
||||
status = ns_skiprr(cp, eom, ns_s_an, ntohs(hp->ancount), &n);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return (NULL);
|
||||
cp += n;
|
||||
|
||||
n = ns_skiprr(cp, eom, ns_s_ns, ntohs(hp->nscount));
|
||||
if (n < 0)
|
||||
status = ns_skiprr(cp, eom, ns_s_ns, ntohs(hp->nscount), &n);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return (NULL);
|
||||
cp += n;
|
||||
|
||||
n = ns_skiprr(cp, eom, ns_s_ar, ntohs(hp->arcount) - 1);
|
||||
if (n < 0)
|
||||
status = ns_skiprr(cp, eom, ns_s_ar, ntohs(hp->arcount) - 1, &n);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return (NULL);
|
||||
cp += n;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user