Commit ace63813 authored by Michael Gilbert's avatar Michael Gilbert

import upstream 4.3.4~b1

parent 35c16ad3
# Copyright (c) 2004-2015 by Internet Systems Consortium, Inc. ("ISC")
# Copyright (c) 2004-2016 by Internet Systems Consortium, Inc. ("ISC")
# Copyright (c) 1995-2003 by Internet Software Consortium
#
# Permission to use, copy, modify, and distribute this software for any
......
......@@ -13,6 +13,7 @@ EXTRA_DIST = RELNOTES LICENSE \
contrib/ms2isc/readme.txt contrib/ldap/dhcpd-conf-to-ldap \
contrib/ldap/dhcp.schema contrib/ldap/README.ldap \
contrib/dhcp-lease-list.pl \
doc/DHCPv4-over-DHCPv6 \
doc/IANA-arp-parameters doc/Makefile doc/References.html \
doc/References.txt doc/References.xml doc/api+protocol \
doc/ja_JP.eucJP/dhclient-script.8 doc/ja_JP.eucJP/dhclient.8 \
......@@ -25,7 +26,18 @@ EXTRA_DIST = RELNOTES LICENSE \
bind/Makefile.in bind/bind.tar.gz bind/version.tmp \
common/tests/Atffile server/tests/Atffile
SUBDIRS = bind includes tests common omapip client dhcpctl relay server
SUBDIRS = @BINDSRCDIR@ includes tests common omapip client dhcpctl relay server
nobase_include_HEADERS = dhcpctl/dhcpctl.h
#
# distcheck tuning
#
DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_ATF_CONFIGURE_FLAG@
distcheck-hook:
chmod u+w $(distdir)/bind
distclean-local:
rm -f config.report
Internet Systems Consortium DHCP Distribution
Version 4.3.3
03 September 2015
Version 4.3.4b1
09 March 2016
README FILE
......@@ -142,12 +142,12 @@ 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:
gunzip dhcp-4.3.3.tar.gz
tar xvf dhcp-4.3.3.tar
gunzip dhcp-4.3.4b1.tar.gz
tar xvf dhcp-4.3.4b1.tar
CONFIGURING IT
Now, cd to the dhcp-4.3.3 subdirectory that you've just created and
Now, cd to the dhcp-4.3.4b1 subdirectory that you've just created and
configure the source tree by typing:
./configure
......@@ -199,6 +199,10 @@ If you get errors on a system not mentioned above, you will need
to do some programming or debugging on your own to get the DHCP
Distribution working.
If you cross compile you have to follow the instructions from
the BIND README, in particular you must set the BUILD_CC
environment variable.
INSTALLING THE DHCP DISTRIBUTION
Once you have successfully gotten the DHCP Distribution to build, you
......
This diff is collapsed.
......@@ -4,21 +4,18 @@
# production code. Sadly, we are not there yet.
SUBDIRS = . tests
BINDLIBDIR = @BINDDIR@/lib
AM_CPPFLAGS = -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"' \
-DLOCALSTATEDIR='"$(localstatedir)"'
dist_sysconf_DATA = dhclient.conf.example
sbin_PROGRAMS = dhclient
dhclient_SOURCES = clparse.c dhclient.c dhc6.c \
scripts/bsdos scripts/freebsd scripts/linux scripts/macos \
scripts/netbsd scripts/nextstep scripts/openbsd \
scripts/solaris scripts/openwrt
dhclient_LDADD = ../common/libdhcp.a ../omapip/libomapi.a ../bind/lib/libirs.a \
../bind/lib/libdns.a ../bind/lib/libisccfg.a ../bind/lib/libisc.a
dhclient_LDADD = ../common/libdhcp.a ../omapip/libomapi.a $(BINDLIBDIR)/libirs.a \
$(BINDLIBDIR)/libdns.a $(BINDLIBDIR)/libisccfg.a $(BINDLIBDIR)/libisc.a
man_MANS = dhclient.8 dhclient-script.8 dhclient.conf.5 dhclient.leases.5
EXTRA_DIST = $(man_MANS)
dhclient.o: dhclient.c
$(COMPILE) -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"' \
-DLOCALSTATEDIR='"$(localstatedir)"' -c dhclient.c
dhc6.o: dhc6.c
$(COMPILE) -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"' \
-DLOCALSTATEDIR='"$(localstatedir)"' -c dhc6.c
......@@ -3,7 +3,7 @@
Parser for dhclient config and lease files... */
/*
* Copyright (c) 2004-2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2016 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
......@@ -32,7 +32,8 @@
struct client_config top_level_config;
#define NUM_DEFAULT_REQUESTED_OPTS 9
struct option *default_requested_options[NUM_DEFAULT_REQUESTED_OPTS + 1];
/* There can be 2 extra requested options for DHCPv4-over-DHCPv6. */
struct option *default_requested_options[NUM_DEFAULT_REQUESTED_OPTS + 2 + 1];
static void parse_client_default_duid(struct parse *cfile);
static void parse_client6_lease_statement(struct parse *cfile);
......@@ -44,6 +45,8 @@ static struct dhc6_addr *parse_client6_iaaddr_statement(struct parse *cfile);
static struct dhc6_addr *parse_client6_iaprefix_statement(struct parse *cfile);
#endif /* DHCPv6 */
static void parse_lease_id_format (struct parse *cfile);
/* client-conf-file :== client-declarations END_OF_FILE
client-declarations :== <nil>
| client-declaration
......@@ -120,6 +123,43 @@ isc_result_t read_client_conf ()
"assembly.", code);
}
#ifdef DHCP4o6
/* DHCPv4-over-DHCPv6 extra requested options in code order */
if (dhcpv4_over_dhcpv6 == 1) {
/* The DHCP4o6 server option should be requested */
code = D6O_DHCP4_O_DHCP6_SERVER;
option_code_hash_lookup(&default_requested_options[9],
dhcpv6_universe.code_hash,
&code, 0, MDL);
if (default_requested_options[9] == NULL) {
log_fatal("Unable to find option definition for "
"index %u during default parameter request "
"assembly.", code);
}
} else if (dhcpv4_over_dhcpv6 > 1) {
/* Called from run_stateless so the IRT should
be requested too */
code = D6O_INFORMATION_REFRESH_TIME;
option_code_hash_lookup(&default_requested_options[9],
dhcpv6_universe.code_hash,
&code, 0, MDL);
if (default_requested_options[9] == NULL) {
log_fatal("Unable to find option definition for "
"index %u during default parameter request "
"assembly.", code);
}
code = D6O_DHCP4_O_DHCP6_SERVER;
option_code_hash_lookup(&default_requested_options[10],
dhcpv6_universe.code_hash,
&code, 0, MDL);
if (default_requested_options[10] == NULL) {
log_fatal("Unable to find option definition for "
"index %u during default parameter request "
"assembly.", code);
}
}
#endif
/* Initialize the top level client configuration. */
memset (&top_level_config, 0, sizeof top_level_config);
......@@ -130,6 +170,7 @@ isc_result_t read_client_conf ()
top_level_config.retry_interval = 300;
top_level_config.backoff_cutoff = 15;
top_level_config.initial_interval = 3;
top_level_config.lease_id_format = TOKEN_OCTAL;
/*
* RFC 2131, section 4.4.1 specifies that the client SHOULD wait a
......@@ -771,6 +812,12 @@ void parse_client_statement (cfile, ip, config)
parse_reject_statement (cfile, config);
return;
case LEASE_ID_FORMAT:
skip_token(&val, (unsigned *)0, cfile);
parse_lease_id_format(cfile);
break;
default:
lose = 0;
stmt = (struct executable_statement *)0;
......@@ -1286,25 +1333,17 @@ static void
parse_client_default_duid(struct parse *cfile)
{
struct data_string new_duid;
const char *val = NULL;
u_int8_t buf[128];
unsigned len;
int token;
memset(&new_duid, 0, sizeof(new_duid));
token = next_token(&val, &len, cfile);
if (token != STRING) {
parse_warn(cfile, "Expected DUID string.");
skip_to_semi(cfile);
return;
}
len = parse_X(cfile, buf, sizeof(buf));
if (len <= 2) {
parse_warn(cfile, "Invalid DUID contents.");
skip_to_semi(cfile);
return;
}
memset(&new_duid, 0, sizeof(new_duid));
if (!buffer_allocate(&new_duid.buffer, len, MDL)) {
parse_warn(cfile, "Out of memory parsing default DUID.");
skip_to_semi(cfile);
......@@ -1313,7 +1352,7 @@ parse_client_default_duid(struct parse *cfile)
new_duid.data = new_duid.buffer->data;
new_duid.len = len;
memcpy(new_duid.buffer->data, val, len);
memcpy(new_duid.buffer->data, buf, len);
/* Rotate the last entry into place. */
if (default_duid.buffer != NULL)
......@@ -2272,3 +2311,45 @@ int parse_allow_deny (oc, cfile, flag)
skip_to_semi (cfile);
return 0;
}
/*!
* \brief Parses an lease-id-format statement
*
* A valid statement looks like this:
*
* lease-id-format :==
* LEASE_ID_FORMAT TOKEN_OCTAL | TOKEN_HEX ;
*
* This function is used to parse the lease-id-format statement. It sets
* top_level_config.lease_id_format.
*
* \param cfile the current parse file
*
*/
void parse_lease_id_format (struct parse *cfile)
{
enum dhcp_token token;
const char *val;
token = next_token(&val, NULL, cfile);
switch(token) {
case TOKEN_OCTAL:
top_level_config.lease_id_format = TOKEN_OCTAL;
break;
case TOKEN_HEX:
top_level_config.lease_id_format = TOKEN_HEX;
break;
default:
parse_warn(cfile, "lease-id-format is invalid: "
" it must be octal or hex.");
skip_to_semi(cfile);
return;
}
log_debug("lease_id_format is: %s",
(top_level_config.lease_id_format == TOKEN_OCTAL
? "octal" : "hex"));
}
This diff is collapsed.
.\" $Id: dhclient.8,v 1.36 2011/04/15 21:58:12 sar Exp $
.\"
.\" Copyright (c) 2004,2007-2015 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004-2016 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1996-2003 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
......@@ -55,6 +55,8 @@ dhclient - Dynamic Host Configuration Protocol Client
.B -P...
]
]
.B -R
]
[
.B -i
]
......@@ -62,6 +64,10 @@ dhclient - Dynamic Host Configuration Protocol Client
.B -I
]
[
.B -4o6
.I port
]
[
.B -D
.I LL|LLT
]
......@@ -237,6 +243,14 @@ along with configuration parameters. It cannot be combined with
processing. Note: it is not recommended to mix queries of different
types together or even to share the lease file between them.
.TP
.BI \-4o6 \ port
Participate in the DHCPv4 over DHCPv6 protocol specified by RFC 7341.
This associates a DHCPv4 and a DHCPv6 client to allow the v4 client to
send v4 requests encapuslated in a v6 packet. Communication
between the two clients is done on a pair of UDP sockets bound
to ::1 \fIport\fR and \fIport + 1\fR. Both clients must
be launched using the same \fIport\fR argument.
.TP
.BI \-1
Try to get a lease once. On failure exit with code 2. In DHCPv6 this
sets the maximum duration of the initial exchange to
......@@ -364,8 +378,21 @@ See \fB\-N\fR to restore it.
.BI \-P
Enable IPv6 prefix delegation. This implies \fB\-6\fR and also
disables the normal address query. See \fB\-N\fR to restore it.
Multiple prefixes can be requested with multiple \fB\-P\fR flags.
Note only one requested interface is allowed.
.TP
.BI \-R
Require that responses include all of the items requested by any
\fB\-N\fR, \fB\-T\fR, or \fB\-P\fR options. Normally even if
the command line includes a number of these the client will be willing
to accept the best lease it can even if the lease doesn't include all
of the requested items. This option causes the client to only
accept leases that include all of the requested items.
Note well: enabling this may prevent the client from using any
leases it receives if the servers aren't configured to supply
all of the items.
.TP
.BI \-D \ LL\ or\ LLT
Override the default when selecting the type of DUID to use. By default,
DHCPv6 \fBdhclient\fR creates an identifier based on the link-layer address
......@@ -381,6 +408,7 @@ overrides these default, with a value of either \fILL\fR or \fILLT\fR.
.\" TODO: is this for telling an already running dhclient?
Restore normal address query for IPv6. This implies \fB-6\fR.
It is used to restore normal operation after using \fB-T\fR or \fB-P\fR.
Multiple addresses can be requested with multiple \fB\-N\fR flags.
.PP
.I Modifying default file locations:
The following options can be used to modify the locations a client uses
......
This diff is collapsed.
.\" $Id: dhclient.conf.5,v 1.34 2012/01/24 22:23:39 sar Exp $
.\"
.\" Copyright (c) 2009-2012,2014 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004-2016 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1996-2003 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
......@@ -55,16 +54,15 @@ reasonable timing behaviour will be used by default - one which
results in fairly timely updates without placing an inordinate load on
the server.
.PP
The following statements can be used to adjust the timing behaviour of
the DHCP client if required, however:
If required the following statements can be used to adjust the timing
behaviour of the DHCPv4 client. The DHCPv6 protocol provides values
to use and they are not currently configurable.
.PP
.I The
.B timeout
.I statement
.PP
.B timeout
.I time
.B ;
\fBtimeout \fItime\fR\fB;\fR
.PP
The
.I timeout
......@@ -176,6 +174,37 @@ client used to wait random time up to 5 seconds, but that was unwanted
due to impact on startup time. As such, new versions have the default
initial delay set to 0. To restore old behavior, please set initial-delay
to 5.
.SH DHCPv6 LEASE SELECTION
In the DHCPv6 protocol the client will wait a small amount of time to
allow ADVERTISE messages from multiple servers to arrive. It will then
need to choose from all of the messages that may have arrived before
proceeding to making a request of the selected server.
The first selection criteria is the set of options and addresses
in the message. Messages that don't include an option specified
as required will be given a score of 0 and not used. If the
\fI-R\fR option is given on the command line then messages that
don't include the correct number of bindings (IA-NA, IA-TA or
IA-PD) will be discarded.
The next criteria is the preference value from the message. With
the highest preference value being used even if leases with better
addresses or options are available.
Finally the lease is scored and the lease with the highest score
is selected. A lease's score is based on the number of bindings,
number of addresses and number of options it contains:
.nf
bindings * X + addresses * Y + options
.fi
By default X = 10000 and Y = 100, this will cause the client to
select a lease with more bindings over a lease with less bindings
but more addresses. The weightings were changed as part of
implementing RFC 7550. Previously they were X = 50 and Y = 100
meaning more addresses were preferred over more bindings. If
you wish to continue using the old style you may do so by editing
the file includes/site.h and uncommenting the define for
USE_ORIGINAL_CLIENT_LEASE_WEIGHTS.
.SH LEASE REQUIREMENTS AND REQUESTS
The DHCP protocol allows the client to request that the server send it
specific information, and not send it other information that it is not
......@@ -236,17 +265,17 @@ options will be ignored. There is no default require list.
interface eth0 {
also require domain-search;
}
.fi
.PP
.I The
.B send
.I statement
.PP
\fBsend { [ \fIoption declaration\fR ]
[\fB,\fI ... \fIoption declaration\fR ]\fB}\fR
\fBsend [ \fIoption declaration\fR ] \fB;\fR
.PP
The send statement causes the client to send the specified options to
the server with the specified values. These are full option
declarations as described in \fBdhcp-options(5)\fR. Options that are
The send statement causes the client to send the specified option to
the server with the specified value. This is a full option
declaration as described in \fBdhcp-options(5)\fR. Options that are
always sent in the DHCP protocol should not be specified here, except
that the client can specify a requested \fBdhcp-lease-time\fR option other
than the default requested lease time, which is two hours. The other
......@@ -568,6 +597,28 @@ day-and-time in UTC, whereas \fIlocal\fR uses a seconds-since-epoch to store
the time value, and helpfully places a local timezone time in a comment on
the same line. The formats are described in detail in this manpage, within
the LEASE DECLARATIONS section.
.PP
The
.I lease-id-format
parameter
.RS 0.25i
.PP
.B lease-id-format \fIformat\fB;\fR
.PP
The \fIformat\fR parameter must be either \fBoctal\fR or \fBhex\fR.
This parameter governs the format used to write certain values to lease
files. With the default format, octal, values are written as quoted strings in
which non-printable characters are represented as octal escapes -
a backslash character followed by three octal digits. When the hex format
is specified, values are written as an unquoted series of hexadecimal digit
pairs, separated by colons.
Currently, the values written out based on lease-id-format are the default-duid
and the IAID value (DHCPv6 only). The client automatically reads the values
in either format. Note that when the format is octal, rather than as an octal
string, IAID is output as hex if it contains no printable characters or as a
string if contains only printable characters. This is done to maintain backward
compatibility.
.PP
\fBreject \fIcidr-ip-address\fR [\fB,\fR \fI...\fB \fIcidr-ip-address\fR ] \fB;\fR
.PP
......
SUBDIRS = .
BINDLIBDIR = @BINDDIR@/lib
AM_CPPFLAGS = $(ATF_CFLAGS) -DUNIT_TEST -I$(top_srcdir)/includes
AM_CPPFLAGS += -I$(top_srcdir)/bind/include -I$(top_srcdir)
AM_CPPFLAGS += -I@BINDDIR@/include -I$(top_srcdir)
AM_CPPFLAGS += -DLOCALSTATEDIR='"."'
AM_CPPFLAGS += -DCLIENT_PATH='"."'
......@@ -16,9 +18,9 @@ info:
DHCPSRC = ../clparse.c ../dhc6.c ../dhclient.c
DHCPLIBS = $(top_builddir)/common/libdhcp.a $(top_builddir)/omapip/libomapi.a \
$(top_builddir)/dhcpctl/libdhcpctl.a $(top_builddir)/bind/lib/libirs.a \
$(top_builddir)/bind/lib/libdns.a $(top_builddir)/bind/lib/libisccfg.a \
$(top_builddir)/bind/lib/libisc.a
$(top_builddir)/dhcpctl/libdhcpctl.a $(BINDLIBDIR)/libirs.a \
$(BINDLIBDIR)/libdns.a $(BINDLIBDIR)/libisccfg.a \
$(BINDLIBDIR)/libisc.a
ATF_TESTS =
if HAVE_ATF
......@@ -32,7 +34,18 @@ duid_unittests_LDADD = $(ATF_LDFLAGS)
duid_unittests_LDADD += $(DHCPLIBS)
check: $(ATF_TESTS)
sh ${top_srcdir}/tests/unittest.sh
-cp -n $(top_srcdir)/client/tests/Atffile Atffile
-cp -n $(top_srcdir)/client/tests/duid0_test.txt duid0_test.txt
-cp -n $(top_srcdir)/client/tests/duid1_test.txt duid1_test.txt
-cp -n $(top_srcdir)/client/tests/duid2_test.txt duid2_test.txt
-cp -n $(top_srcdir)/client/tests/duid3_test.txt duid3_test.txt
sh ${top_builddir}/tests/unittest.sh
distclean-local:
@if test $(top_srcdir) != ${top_builddir}; then \
rm -f Atffile duid0_test.txt duid1_test.txt; \
rm -f duid2_test.txt duid3_test.txt; \
fi
endif
......
AM_CPPFLAGS = -I.. -DLOCALSTATEDIR='"@localstatedir@"'
AM_CPPFLAGS = -I$(top_srcdir) -DLOCALSTATEDIR='"@localstatedir@"'
AM_CFLAGS = $(LDAP_CFLAGS)
noinst_LIBRARIES = libdhcp.a
libdhcp_a_SOURCES = alloc.c bpf.c comapi.c conflex.c ctrace.c discover.c \
dispatch.c dlpi.c dns.c ethernet.c execute.c fddi.c \
icmp.c inet.c lpf.c memory.c nit.c ns_name.c options.c \
packet.c parse.c print.c raw.c resolv.c socket.c \
tables.c tr.c tree.c upf.c
libdhcp_a_SOURCES = alloc.c bpf.c comapi.c conflex.c ctrace.c dhcp4o6.c \
discover.c dispatch.c dlpi.c dns.c ethernet.c execute.c \
fddi.c icmp.c inet.c lpf.c memory.c nit.c ns_name.c \
options.c packet.c parse.c print.c raw.c resolv.c \
socket.c tables.c tr.c tree.c upf.c
man_MANS = dhcp-eval.5 dhcp-options.5
EXTRA_DIST = $(man_MANS)
......
......@@ -3,8 +3,7 @@
Memory allocation... */
/*
* Copyright (c) 2009,2013-2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2016 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
......@@ -240,7 +239,7 @@ int group_dereference (ptr, file, line)
if (group -> object)
group_object_dereference (&group -> object, file, line);
if (group -> subnet)
if (group -> subnet)
subnet_dereference (&group -> subnet, file, line);
if (group -> shared_network)
shared_network_dereference (&group -> shared_network,
......@@ -497,7 +496,7 @@ void relinquish_free_expressions ()
#endif
struct binding_value *free_binding_values;
int binding_value_allocate (cptr, file, line)
struct binding_value **cptr;
const char *file;
......@@ -685,7 +684,7 @@ int buffer_allocate (ptr, len, file, line)
{
struct buffer *bp;
/* XXXSK: should check for bad ptr values, otherwise we
/* XXXSK: should check for bad ptr values, otherwise we
leak memory if they are wrong */
bp = dmalloc (len + sizeof *bp, file, line);
if (!bp)
......@@ -1279,25 +1278,25 @@ data_string_new(struct data_string *new_string,
if (new_string == NULL) {
log_error("data_string_new: new_string cannot be NULL %s(%d)",
file, line);
return (0);
return (0);
}
if (src == NULL) {
log_error("data_string_new: src cannot be NULL %s(%d)",
file, line);
return (0);
return (0);
}
memset(new_string, 0, sizeof (struct data_string));
/* If we already have a NULL back off length by one. This lets
* us always just add a NULL at the end. */
copy_len = (len > 0 && src[len - 1 ] == 0) ? len - 1 : len;
copy_len = (len > 0 && src[len - 1] == 0) ? len - 1 : len;
/* Allocate the buffer, accounting for terminating null */
if (!buffer_allocate(&(new_string->buffer), copy_len + 1, MDL)) {
log_error("data_string_new: No memory %s(%d)", file, line);
return (0);
return (0);
}
/* Only copy if there's something to copy */
......@@ -1306,7 +1305,7 @@ data_string_new(struct data_string *new_string,
}
/* Always tack on the null */
new_string->buffer->data[copy_len + 1] = 0;
new_string->buffer->data[copy_len] = 0;
/* Update data_string accessor values. Note len does NOT include
* the NULL. */
......@@ -1347,7 +1346,7 @@ void data_string_forget (data, file, line)
memset (data, 0, sizeof *data);
}
/* If the data_string is larger than the specified length, reduce
/* If the data_string is larger than the specified length, reduce
the data_string to the specified size. */
void data_string_truncate (dp, len)
......@@ -1360,3 +1359,49 @@ void data_string_truncate (dp, len)
dp -> len = len;
}
}
/* \brief Converts a data_string to a null-terminated data string
*
* If the given string isn't null-terminated, replace it with a
* null-terminated version and free the current string decrementing
* the referecne count. If the string is null-terminated it is left
* as is.
*
* Currently this routine doesn't check if the string is 0 length
* that must be checked by the caller.
*
* \param [in/out] str the data_string to convert
* \param file the file this routine was called from
* \param line the line this routine was called from
*
* \return 1 if the string was converted successfully (or already terminated),
* 0 if the conversion failed. Failure is only possible if memory for the new
* string could not be allocated. If the conversion fails, the original
* string's content is lost.
*/
int data_string_terminate(str, file, line)
struct data_string* str;
const char *file;
int line;
{
int ret_val = 1;
if (str->terminated == 0) {
struct data_string temp;
memset(&temp, 0, sizeof(temp));
data_string_copy(&temp, str, file, line);
data_string_forget(str, file, line);
if (data_string_new(str, (const char*)temp.data, temp.len,
file, line) == 0) {
/* couldn't create a copy, probably a memory issue,
* an error message has already been logged. */
ret_val = 0;
}
/* get rid of temp string */
data_string_forget(&temp, file, line);
}
return (ret_val);
}
......@@ -3,8 +3,7 @@
BPF socket interface code, originally contributed by Archie Cobbs. */
/*
* Copyright (c) 2009,2012-2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2016 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
......@@ -200,7 +199,7 @@ struct bpf_insn dhcp_bpf_filter [] = {
};
#if defined (DEC_FDDI)
struct bpf_insn *bpf_fddi_filter;
struct bpf_insn *bpf_fddi_filter = NULL;
#endif
int dhcp_bpf_filter_len = sizeof dhcp_bpf_filter / sizeof (struct bpf_insn);
......@@ -285,7 +284,7 @@ void if_register_receive (info)
if (ioctl(info -> rfdesc, BIOCGDLT, &link_layer) >= 0 &&
link_layer == DLT_FDDI) {
if (!bpf_fddi_filter) {
bpf_fddi_filter = dmalloc (sizeof bpf_fddi_filter,
bpf_fddi_filter = dmalloc (sizeof dhcp_bpf_filter,
MDL);
if (!bpf_fddi_filter)
log_fatal ("No memory for FDDI filter.");
......
......@@ -3,8 +3,7 @@
OMAPI object interfaces for the DHCP server. */
/*
* Copyright (c) 2012,2014 Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2016 Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
......@@ -653,16 +652,11 @@ isc_result_t dhcp_subnet_get_value (omapi_object_t *h, omapi_object_t *id,
isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line)
{
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct subnet *subnet;
#endif
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
subnet = (struct subnet *)h;
if (subnet -> next_subnet)
subnet_dereference (&subnet -> next_subnet, file, line);
......@@ -675,7 +669,6 @@ isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line)
interface_dereference (&subnet -> interface, file, line);
if (subnet -> group)
group_dereference (&subnet -> group, file, line);
#endif
return ISC_R_SUCCESS;
}
......@@ -807,16 +800,11 @@ isc_result_t dhcp_shared_network_destroy (omapi_object_t *h,
{
/* In this function h should be a (struct shared_network *) */
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct shared_network *shared_network;
#endif
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
shared_network = (struct shared_network *)h;
if (shared_network -> next)
shared_network_dereference (&shared_network -> next,
......@@ -841,7 +829,6 @@ isc_result_t dhcp_shared_network_destroy (omapi_object_t *h,
&shared_network -> failover_peer,
file, line);
#endif
#endif /* DEBUG_MEMORY_LEAKAGE */
return ISC_R_SUCCESS;
}
......