aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/isc-dhcp/README124
-rw-r--r--contrib/isc-dhcp/RELNOTES229
-rw-r--r--contrib/isc-dhcp/client/clparse.c24
-rw-r--r--contrib/isc-dhcp/client/dhclient.c143
-rwxr-xr-xcontrib/isc-dhcp/client/scripts/freebsd1
-rw-r--r--contrib/isc-dhcp/common/alloc.c7
-rw-r--r--contrib/isc-dhcp/common/bpf.c69
-rw-r--r--contrib/isc-dhcp/common/conflex.c22
-rw-r--r--contrib/isc-dhcp/common/dhcp-options.5236
-rw-r--r--contrib/isc-dhcp/common/dispatch.c271
-rw-r--r--contrib/isc-dhcp/common/lpf.c287
-rw-r--r--contrib/isc-dhcp/common/memory.c88
-rw-r--r--contrib/isc-dhcp/common/nit.c22
-rw-r--r--contrib/isc-dhcp/common/parse.c8
-rw-r--r--contrib/isc-dhcp/common/print.c14
-rw-r--r--contrib/isc-dhcp/common/socket.c40
-rw-r--r--contrib/isc-dhcp/common/tables.c6
-rw-r--r--contrib/isc-dhcp/common/upf.c22
-rw-r--r--contrib/isc-dhcp/includes/cf/freebsd.h8
-rw-r--r--contrib/isc-dhcp/includes/dhcp.h1
-rw-r--r--contrib/isc-dhcp/includes/dhcpd.h87
-rw-r--r--contrib/isc-dhcp/includes/dhctoken.h8
-rw-r--r--contrib/isc-dhcp/includes/osdep.h14
23 files changed, 1398 insertions, 333 deletions
diff --git a/contrib/isc-dhcp/README b/contrib/isc-dhcp/README
index c0f45ed9010a..83c03bbb7dc1 100644
--- a/contrib/isc-dhcp/README
+++ b/contrib/isc-dhcp/README
@@ -1,7 +1,7 @@
Internet Software Consortium
Dynamic Host Configuration Protocol Distribution
- Version 2, Beta 1, Patchlevel 0
- December 6, 1997
+ Version 2, Beta 1, Patchlevel 11
+ February 8, 1998
This is the first Beta release of Version 2 of the Internet Software
Consortium DHCP Distribution. In version 2.0, this distribution
@@ -12,13 +12,14 @@ running a production environment should probably still use version
November of 1996.
In this release, the server and relay agent currently work well on
-Digital Alpha OSF/1, SunOS 4.1.4, NetBSD, FreeBSD, BSD/OS and Ultrix.
-They can also be run usefully on Solaris as long as only one broadcast
-network interface is configured. They also runs on QNX and Linux as
+NetBSD, Linux, FreeBSD, BSD/OS, Ultrix, Digital Alpha OSF/1, and SunOS
+4.1.4. They can also be run usefully on Solaris as long as only one
+broadcast network interface is configured. They also runs on QNX as
long as only one broadcast network interface is configured and a host
route is added from that interface to the 255.255.255.255 broadcast
-address. If you are running a Linux 2.0.31 kernel, the DHCP daemons
-may be able to operate on more than one interface.
+address. If you are running a Linux 2.0.30 or previous kernel, the
+DHCP daemons will only be able to operate on machines with a single
+network interface.
The DHCP client currently only knows how to configure the network on
NetBSD, FreeBSD, BSD/os, Linux, Solaris and NextStep. The client
@@ -27,7 +28,7 @@ configuration - support for other operating systems is simply a matter
of porting this shell script to the new platform.
If you wish to run the DHCP Distribution on Linux, please see the
-Linux-specific notes later in this document. If you wish to run on a
+Linux-specific notes later in this document. If you wish to run on an
SCO release, please see the SCO-specific notes later in this document.
You particularly need to read these notes if you intend to support
Windows 95 clients. If you are running a version of FreeBSD prior to
@@ -43,25 +44,77 @@ information. On Digital Unix, type ``man pfilt''.
BUILDING THE DHCP DISTRIBUTION
-To build the DHCP Distribution, type ``configure''. If configure can
-figure out what sort of system you're running on, it will create a
-custom Makefile for you for that system; otherwise, it will complain.
-If it can't figure out what system you are using, that system is not
-supported - you are on your own.
+To build the DHCP Distribution, unpack the compressed tar file using
+the tar utility and the gzip command - type something like:
+
+ zcat dhcp-2.0b1pl11.tar.gz |tar xvf -
+
+Now, cd to the dhcp-2.0b1pl11 subdirectory that you've just created and
+configure the source tree by typing:
+
+ ./configure
+
+If the configure utility can figure out what sort of system you're
+running on, it will create a custom Makefile for you for that
+system; otherwise, it will complain. If it can't figure out what
+system you are using, that system is not supported - you are on
+your own.
-Once you've run configure, just type ``make'', and after a while you
-should have a dhcp server. If you get compile errors on one of the
-supported systems mentioned earlier, please let us know. 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.
+Once you've run configure, just type ``make'', and after a while
+you should have a dhcp server. If you get compile errors on one
+of the supported systems mentioned earlier, please let us know.
+If you get warnings, it's not likely to be a problem - the DHCP
+server compiles completely warning-free on as many architectures
+as we can manage, but there are a few for which this is difficult.
+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.
+
+Once you have successfully gotten the DHCP Distribution to build, you
+can install it by typing ``make install''. If you already have an old
+version of the DHCP Distribution installed, you may want to save it
+before typing ``make install''.
LINUX
There are three big LINUX issues: the all-ones broadcast address,
Linux 2.1 ip_bootp_agent enabling, and operations with more than one
-network interface.
+network interface. There are also two potential compilation/runtime
+problems for Linux 2.1/2.2: the "SO_ATTACH_FILTER undeclared" problem
+and the "protocol not configured" problem.
+
+ LINUX: SO_ATTACH_FILTER UNDECLARED
+
+In addition, there is a minor issue that we will mention here because
+this release is so close on the heels of the Linux 2.2 release: there
+is a symlink in /usr/include that points at the linux asm headers. It
+appears to be not uncommon that this link won't be updated correctly,
+in which case you'll get the following error when you try to build:
+
+ lpf.c: In function `if_register_receive':
+ lpf.c:152: `SO_ATTACH_FILTER' undeclared (first use this function)
+ lpf.c:152: (Each undeclared identifier is reported only once
+ lpf.c:152: for each function it appears in.)
- BROADCAST
+The line numbers may be different, of course. If you see this
+header, your linux asm header link is probably bad, and you should
+make sure it's pointing to correct linux source directory.
+
+ LINUX: PROTOCOL NOT CONFIGURED
+
+One additional Linux 2.1/2.2 issue: if you get the following message,
+it's because your kernel doesn't have the linux packetfilter
+configured:
+
+ Can't install packet filter program: Protocol not available
+ exiting.
+
+If this happens, you need to edit your linux kernel .config file, set
+CONFIG_FILTER=y, and rebuild your kernel. If the preceding sentence
+made no sense to you, ask your Linux vendor/guru for help - please
+don't ask us.
+
+ LINUX: BROADCAST
In order for dhcpd to work correctly with picky DHCP clients (e.g.,
Windows 95), it must be able to send packets with an IP destination
@@ -96,7 +149,7 @@ Another route that has worked for some users is:
If you are not using eth0 as your network interface, you should
specify the network interface you *are* using in your route command.
- IP BOOTP AGENT
+ LINUX: IP BOOTP AGENT
Some versions of the Linux 2.1 kernel apparently prevent dhcpd from
working unless you enable it by doing the following:
@@ -104,7 +157,7 @@ working unless you enable it by doing the following:
echo 1 >/proc/sys/net/ipv4/ip_bootp_agent
- MULTIPLE INTERFACES
+ LINUX: MULTIPLE INTERFACES
Most older versions of the Linux kernel do not provide a networking
API that allows dhcpd to operate correctly if the system has more than
@@ -113,20 +166,8 @@ version numbers greater than or equal to 2.0.31 add an API feature:
the SO_BINDTODEVICE socket option. If SO_BINDTODEVICE is present, it
is possible for dhcpd to operate on Linux with more than one network
interface. In order to take advantage of this, you must be running a
-2.0.31 or greater kernel, and you must have 2.0.31 system headers
-installed *before* you build dhcpd.
-
-NOTE: People have been having problems finding the 2.0.31 kernel
-because it was only available as a prerelease patch. As of October
-17, Linux 2.0.31 is the stable Linux kernel, and is available as a
-kernel distribution rather than as a test patch. With any luck, it
-will be in the latest version of your favourite Linux distribution
-soon.
-
-If you are running a Linux 2.1 kernel, this does not guarantee that you
-have SO_BINDTODEVICE. Linux 2.0.31 was released quite a while after 2.1
-kernel development began. The earliest Linux kernel in the 2.1
-development stream with SO_BINDTODEVICE is version 2.1.68.
+2.0.31 or greater kernel, and you must have 2.0.31 or later system
+headers installed *before* you build the DHCP Distribution.
We have heard reports that you must still add routes to 255.255.255.255
in order for the all-ones broadcast to work, even on 2.0.31 kernels.
@@ -189,6 +230,17 @@ The NeXTSTEP support uses the NeXTSTEP Berkeley Packet Filter
extension, which is not included in the base NextStep system. You
must install this extension in order to get dhcpd or dhclient to work.
+ SOLARIS
+
+One problem which has been observed and is not fixed in this patchlevel
+has to do with using DLPI on Solaris 2.6 machines, probably only on Intel,
+but possibly also on SPARC. The symptom of this problem is that you never
+receive any DHCP packets. If you are running Solaris 2.6, and you
+encounter this symptom, and you are running the DHCP server on a machine
+with a single broadcast network interface, you may wish to edit the
+includes/site.h file and uncomment the #define USE_SOCKETS line. Then
+type ``make clean; make''.
+
SUPPORT
The Internet Software Consortium DHCP server is not a commercial
diff --git a/contrib/isc-dhcp/RELNOTES b/contrib/isc-dhcp/RELNOTES
index 2cad409c8986..c136fd7bac69 100644
--- a/contrib/isc-dhcp/RELNOTES
+++ b/contrib/isc-dhcp/RELNOTES
@@ -1,7 +1,7 @@
Internet Software Consortium
Dynamic Host Configuration Protocol Distribution
- Version 2, Beta 1, Patchlevel 6
- June 26, 1998
+ Version 2, Beta 1, Patchlevel 10
+ February 8, 1998
Release Notes
@@ -13,8 +13,8 @@ stable.
Version 1 of the ISC DHCP Distribution includes just a DHCP Server.
Version 1 has been in feature freeze since late 1996, and is quite
-stable. This is the release that we would expect most sites to run in
-production.
+stable. This is the release that we would expect very conservative
+sites to run in production, but it is no longer recommended.
Version 2 of the ISC DHCP Distribution adds a DHCP Client and a
DHCP/BOOTP Relay Agent to the DHCP Server that was offered in version
@@ -33,19 +33,224 @@ server:
addresses other than the one the server knows they should be
using are disciplined quickly.
-This version is now in Beta testing, and is planned for release in
-mid-1998. It has a number of new features, and is the release that we
-would expect sites that want some stability but need the new lease
-testing feature, or need a client or relay agent. Note that it is
-possible to run the Version 1 server with the Version 2 client.
+This version has been in a near feature freeze since January of 1998,
+has been in Beta test since then, and is planned for final release in
+mid-1999. It has a number of important features, and is the release
+that we would expect most sites to run. It is possible to run the
+Version 1 server with the Version 2 client at sites that want to be
+really conservative.
-Version 3 of the ISC DHCP Distribution will add Dynamic DNS Support,
+Version 3 of the ISC DHCP Distribution will add conditional behaviour,
+client classing, Dynamic DNS Support, DHCPv4 16-bit option codes,
asynchronous DNS query resolution, DHCP Authentication, and possibly
support for a DHCP Interserver Protocol and live querying of the DHCP
-database. This release is not expected to be stable in the near
-future, and is intended for sites that are in a position to
+database. Currently, only client classing and conditional behaviour
+have been implemented - the DNS code is waiting for an enhanced DNS
+resolver. The code has gone through a major internal restructuring
+which will help to support wider option codes, and possibly IPv6, as
+well as a more sensible memory allocation strategy. This release is
+running in producion at the ISC, but is not expected to be stable in
+the near future, and is intended for sites that are in a position to
experiment, or for sites that desperately need the new features.
+ CHANGES FROM VERSION 2.0 BETA 1 PATCHLEVEL 10
+
+- Update top-level Makefile so that it exits correctly on errors in
+ submakes under bash/gnu make (dunno which is the culprit, and don't
+ really care).
+
+- Print a more helpful message if no free BPF devices are found.
+
+- Add support for specifying that the server is or is not
+ authoritative for a particular network segment.
+
+- Fix two stupid typos in lpf.c.
+
+- Print a more helpful message if we can't create an LPF socket or
+ can't attach a filter to it.
+
+ CHANGES FROM VERSION 2.0 BETA 1 PATCHLEVEL 9
+
+- Correct the hopelessly outdated information about Linux at the top
+ of the README - many apologies to the Linux people who have had to
+ read that nonsense for the past couple of snapshots and have been
+ confused or annoyed by it. I simply hadn't read it recently, and
+ didn't realize how out-of-date it was.
+
+- Print a message if the client finds no broadcast interfaces to
+ configure.
+
+- Add support for use-lease-addr-for-default-route flag in server, so
+ that Windows machines can be made to ARP for all addresses.
+
+- Update README file to mention new Linux gotchas.
+
+- After finally understanding Brian Murrel's code (my fault, not his)
+ to get interface names from /proc/net/dev on Linux, fix what I broke
+ of his code and document it.
+
+- Use sendto rather than send for SOCK_PACKET sockets, because they
+ can't be connected, only bound. :'(
+
+- Fix up SOCK_PACKET creation so that the kernel doesn't complain
+ about it.
+
+- Fix incorrect tests in linux client script:
+ [ $relmajor == 2 ] -> [ $relmajor -eq 2 ]
+
+- Make typedefs for u8, u16 and u32 types. These are Linux kernel
+ internal data types which are unfortunately exposed in the linux
+ packetfilter header file.
+
+- Don't include <net/ethernet.h> in lpf.c - it defines things we're
+ already correctly defining elsewhere, and doesn't define any useful
+ new stuff.
+
+- Finally fix client PREINIT bug that causes interfaces not specified
+ on the command line to be preinitialized. If no interfaces are
+ specified on the command line, all interfaces are still
+ preinitialized.
+
+ CHANGES FROM VERSION 2.0 BETA 1 PATCHLEVEL 8
+
+- Fix socket API fallback setup code, which was causing Linux servers
+ and clients to loop endlessly on select when run as daemons.
+
+- Add support for Linux 2.2 version number (treated the same as Linux
+ 2.1, for now).
+
+- Correct apparent error in DHCPREQUEST destination address handling
+ when in INIT-REBOOT state.
+
+- Do not set BROADCAST flag if we have a valid IP address.
+
+- Remove hard-coded filenames and use system-specific manifest
+ constants.
+
+- Add entry and exit hooks to Linux dhclient-script (should be added
+ to all operating systems once tested).
+
+- Test for linux major and minor version so as to correctly invoke
+ network configuration programs.
+
+- Add support for Linux's gratuitous name change of bpf_insn structure
+ (can't pollute precious Linux sources with the "Berkeley" word, I
+ guess.
+
+- Correct USE_BPF_{SEND,RECEIVE} ifdefs for if_reinitialize_*
+ functions.
+
+- Ensure that we have ifreq structure before initializing interface -
+ if an interface was specified on the command line on Linux, this was
+ not the case.
+
+- Get rid of references to enstamp structure in lpf.c. Correctly
+ declare and initialize sock_fprog structure (aka bpf_filter
+ structure on non-Linux machines).
+
+- Define ssize_t on Ultrix.
+
+ CHANGES FROM VERSION 2.0 BETA 1 PATCHLEVEL 7
+
+- Generalize FDDI support.
+
+- Fix potential core dump in interface discovery code.
+
+- Put explicit release versions on startup messages.
+
+ CHANGES FROM VERSION 2.0 BETA 1 PATCHLEVEL 6
+
+- Add support for Linux Packet Filter (thanks to Brian Murrell, Interlinx).
+
+- Add support for FDDI hardware type.
+
+- Fix a long-standing bug in DLPI support where the ethertype was
+ being set incorrectly (thanks to Gong Wei, CCENet).
+
+- Don't use DLPI RAW mode on Solaris.
+
+- In the client, when a lease expires, the interface to which that
+ lease is attached is unconfigured. On systems that use the socket
+ API, the interface needs to then be reconfigured with the 0.0.0.0
+ address so that it can be used to get a new address.
+
+- Add fallback support for Linux. This fixes a problem with the
+ relay agent when relaying over non-broadcast links, and may also fix
+ some obscure problems with unicasting DHCPACKs in both the server and
+ relay agent.
+
+- When allocating leases, if the oldest lease is abandoned, try to
+ find a younger-but-still-expired lease rather than reclaiming the
+ abandoned lease.
+
+- Add more documentation to README.
+
+- The absence of the /etc/dhclient.conf file is no longer considered
+ an error.
+
+- The dhcp client's lease file name can be specified on the command
+ line.
+
+- The DHCP client should no longer zap interfaces that it has not been
+ directed to configure.
+
+- If a client starts up in the init-reboot state, the xid will be a
+ "random" number rather than always being zero, as was previously the
+ case.
+
+- In addition to comparing transaction IDs, compare hardware addresses
+ in response packets to verify that they are ours.
+
+- Rewrite the client lease database after 20 leases have been written.
+
+- Fix the exponential backoff code.
+
+- Add a Y2k comment to indicate that something suspicious-looking is
+ in fact _not_ a problem.
+
+- Use mkstemp if possible.
+
+- Add missing fi in various client scripts.
+
+- Use "search" instead of "domain" in linux resolv.conf files.
+
+- Specify a hop count in all route command on solaris.
+
+- If an allocation fails, don't try to zero out the allocation buffer
+ we didn't get.
+
+- Support subnets that are subsets of other subnets - that is, for
+ example, 10.0.1.0/24 and 10.0.0.0/16. This is useful in fairly
+ obscure circumstances.
+
+- Don't set the lease end time if it's already expired.
+
+- Don't define INADDR_LOOPBACK on FreeBSD if it's already defined in a
+ system header.
+
+- Use the broadcast address in the relay agent if we are using the BSD
+ socket API.
+
+- Allow host declarations without names.
+
+- Allow the server identifier option to be specified.
+
+- Don't dump hostnames into the lease file if they contain
+ non-printable characters.
+
+- Copy the entire client hardware address buffer that the client sends
+ to the output packet, not just the portion of it that's supposedly
+ significant according to the hardware address length field. This
+ is done for the benefit of certain Microsoft clients.
+
+- Don't send a second ICMP echo request if we receive two DHCPDISCOVER
+ messages in quick succession. This prevents a rather annoying
+ timing race in configuring some Win95 clients.
+
+- Fix up dhcp-options man page to make it more readable. Note that
+ netbios-name-server is the same thing as WINS.
+
+
CHANGES FROM VERSION 2.0 BETA 1 PATCHLEVEL 5
- Define some extra DLPI support flags that make DLPI work much better
diff --git a/contrib/isc-dhcp/client/clparse.c b/contrib/isc-dhcp/client/clparse.c
index 37fafd378f97..e55ea6106949 100644
--- a/contrib/isc-dhcp/client/clparse.c
+++ b/contrib/isc-dhcp/client/clparse.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: clparse.c,v 1.13.2.1 1998/06/25 21:11:27 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
+"$Id: clparse.c,v 1.13.2.2 1998/07/10 23:17:00 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -112,16 +112,18 @@ int read_client_conf ()
top_level_config.send_options [DHO_DHCP_LEASE_TIME].len
= sizeof requested_lease_time;
- if ((cfile = fopen (path_dhclient_conf, "r")) == NULL)
- error ("Can't open %s: %m", path_dhclient_conf);
- do {
- token = peek_token (&val, cfile);
- if (token == EOF)
- break;
- parse_client_statement (cfile, (struct interface_info *)0,
- &top_level_config);
- } while (1);
- token = next_token (&val, cfile); /* Clear the peek buffer */
+ if ((cfile = fopen (path_dhclient_conf, "r")) != NULL) {
+ do {
+ token = peek_token (&val, cfile);
+ if (token == EOF)
+ break;
+ parse_client_statement (cfile,
+ (struct interface_info *)0,
+ &top_level_config);
+ } while (1);
+ token = next_token (&val, cfile); /* Clear the peek buffer */
+ fclose (cfile);
+ }
/* Set up state and config structures for clients that don't
have per-interface configuration declarations. */
diff --git a/contrib/isc-dhcp/client/dhclient.c b/contrib/isc-dhcp/client/dhclient.c
index eb4d268f9768..08fa4fcef895 100644
--- a/contrib/isc-dhcp/client/dhclient.c
+++ b/contrib/isc-dhcp/client/dhclient.c
@@ -3,8 +3,8 @@
DHCP Client. */
/*
- * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
- * All rights reserved.
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999
+ * The Internet Software Consortium. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -55,8 +55,8 @@
*/
#ifndef lint
-static char copyright[] =
-"$Id: dhclient.c,v 1.44.2.1 1997/12/06 11:24:31 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+static char ocopyright[] =
+"$Id: dhclient.c,v 1.44.2.14 1999/02/09 04:59:50 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -83,16 +83,19 @@ struct sockaddr_in sockaddr_broadcast;
assert (state_is == state_shouldbe). */
#define ASSERT_STATE(state_is, state_shouldbe) {}
-#ifdef USE_FALLBACK
-struct interface_info fallback_interface;
-#endif
-
u_int16_t local_port;
u_int16_t remote_port;
int log_priority;
int no_daemon;
int save_scripts;
+static char copyright[] =
+"Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.";
+static char arr [] = "All rights reserved.";
+static char message [] = "Internet Software Consortium DHCP Client V2.0b1pl11";
+static char contrib [] = "\nPlease contribute if you find this software useful.";
+static char url [] = "For info, please visit http://www.isc.org/dhcp-contrib.html\n";
+
static void usage PROTO ((void));
int main (argc, argv, envp)
@@ -103,6 +106,7 @@ int main (argc, argv, envp)
struct servent *ent;
struct interface_info *ip;
int seed;
+ int quiet;
#ifdef SYSLOG_4_2
openlog ("dhclient", LOG_NDELAY);
@@ -126,6 +130,13 @@ int main (argc, argv, envp)
no_daemon = 1;
} else if (!strcmp (argv [i], "-D")) {
save_scripts = 1;
+ } else if (!strcmp (argv [i], "-lf")) {
+ if (++i == argc)
+ usage ();
+ path_dhclient_db = argv [i];
+ } else if (!strcmp (argv [i], "-q")) {
+ quiet = 1;
+ quiet_interface_discovery = 1;
} else if (argv [i][0] == '-') {
usage ();
} else {
@@ -143,6 +154,15 @@ int main (argc, argv, envp)
interfaces = tmp;
}
}
+
+ if (!quiet) {
+ note (message);
+ note (copyright);
+ note (arr);
+ note (contrib);
+ note (url);
+ }
+
/* Default to the DHCP/BOOTP port. */
if (!local_port) {
ent = getservbyname ("dhcpc", "udp");
@@ -186,11 +206,19 @@ int main (argc, argv, envp)
(struct string_list *)0);
script_go ((struct interface_info *)0);
+ note ("No broadcast interfaces found - exiting.");
/* Nothing more to do. */
exit (0);
} else {
/* Call the script with the list of interfaces. */
for (ip = interfaces; ip; ip = ip -> next) {
+ /* If interfaces were specified, don't configure
+ interfaces that weren't specified! */
+ if (interfaces_requested &&
+ ((ip -> flags & (INTERFACE_REQUESTED |
+ INTERFACE_AUTOMATIC)) !=
+ INTERFACE_REQUESTED))
+ continue;
script_init (ip, "PREINIT", (struct string_list *)0);
if (ip -> client -> alias)
script_write_params (ip, "alias_",
@@ -240,7 +268,7 @@ int main (argc, argv, envp)
static void usage ()
{
- error ("Usage: dhclient [-c] [-p <port>] [interface]");
+ error ("Usage: dhclient [-c] [-p <port>] [-lf lease-file] [interface]");
}
void cleanup ()
@@ -291,10 +319,14 @@ void state_reboot (ipp)
/* We are in the rebooting state. */
ip -> client -> state = S_REBOOTING;
+ /* make_request doesn't initialize xid because it normally comes
+ from the DHCPDISCOVER, but we haven't sent a DHCPDISCOVER,
+ so pick an xid now. */
+ ip -> client -> xid = random ();
+
/* Make a DHCPREQUEST packet, and set appropriate per-interface
flags. */
make_request (ip, ip -> client -> active);
- ip -> client -> xid = ip -> client -> packet.xid;
ip -> client -> destination = iaddr_broadcast;
ip -> client -> first_sending = cur_time;
ip -> client -> interval = ip -> client -> config -> initial_interval;
@@ -432,7 +464,11 @@ void dhcpack (packet)
/* If we're not receptive to an offer right now, or if the offer
has an unrecognizable transaction id, then just drop it. */
- if (packet -> interface -> client -> xid != packet -> raw -> xid) {
+ if (packet -> interface -> client -> xid != packet -> raw -> xid ||
+ (packet -> interface -> hw_address.hlen !=
+ packet -> raw -> hlen) ||
+ (memcmp (packet -> interface -> hw_address.haddr,
+ packet -> raw -> chaddr, packet -> raw -> hlen))) {
debug ("DHCPACK in wrong transaction.");
return;
}
@@ -498,7 +534,7 @@ void bind_lease (ip)
ip -> client -> new -> medium = ip -> client -> medium;
/* Write out the new lease. */
- write_client_lease (ip, ip -> client -> new);
+ write_client_lease (ip, ip -> client -> new, 0);
/* Run the client script with the new parameters. */
script_init (ip, (ip -> client -> state == S_REQUESTING
@@ -662,7 +698,11 @@ void dhcpoffer (packet)
/* If we're not receptive to an offer right now, or if the offer
has an unrecognizable transaction id, then just drop it. */
if (ip -> client -> state != S_SELECTING ||
- packet -> interface -> client -> xid != packet -> raw -> xid) {
+ packet -> interface -> client -> xid != packet -> raw -> xid ||
+ (packet -> interface -> hw_address.hlen !=
+ packet -> raw -> hlen) ||
+ (memcmp (packet -> interface -> hw_address.haddr,
+ packet -> raw -> chaddr, packet -> raw -> hlen))) {
debug ("%s in wrong transaction.", name);
return;
}
@@ -861,7 +901,11 @@ void dhcpnak (packet)
/* If we're not receptive to an offer right now, or if the offer
has an unrecognizable transaction id, then just drop it. */
- if (packet -> interface -> client -> xid != packet -> raw -> xid) {
+ if (packet -> interface -> client -> xid != packet -> raw -> xid ||
+ (packet -> interface -> hw_address.hlen !=
+ packet -> raw -> hlen) ||
+ (memcmp (packet -> interface -> hw_address.haddr,
+ packet -> raw -> chaddr, packet -> raw -> hlen))) {
debug ("DHCPNAK in wrong transaction.");
return;
}
@@ -963,8 +1007,8 @@ void send_discover (ipp)
ip -> client -> config -> backoff_cutoff)
ip -> client -> interval =
((ip -> client -> config -> backoff_cutoff / 2)
- + ((random () >> 2)
- % ip -> client -> interval));
+ + ((random () >> 2) %
+ ip -> client -> config -> backoff_cutoff));
} else if (!ip -> client -> interval)
ip -> client -> interval =
ip -> client -> config -> initial_interval;
@@ -1161,6 +1205,14 @@ void send_request (ipp)
ip -> client -> alias);
script_go (ip);
+ /* Now do a preinit on the interface so that we can
+ discover a new address. */
+ script_init (ip, "PREINIT", (struct string_list *)0);
+ if (ip -> client -> alias)
+ script_write_params (ip, "alias_",
+ ip -> client -> alias);
+ script_go (ip);
+
ip -> client -> state = S_INIT;
state_init (ip);
return;
@@ -1195,6 +1247,7 @@ void send_request (ipp)
/* If the lease T2 time has elapsed, or if we're not yet bound,
broadcast the DHCPREQUEST rather than unicasting. */
if (ip -> client -> state == S_REQUESTING ||
+ ip -> client -> state == S_REBOOTING ||
cur_time > ip -> client -> active -> rebind)
destination.sin_addr.s_addr = INADDR_BROADCAST;
else
@@ -1223,16 +1276,15 @@ void send_request (ipp)
inet_ntoa (destination.sin_addr),
ntohs (destination.sin_port));
-#ifdef USE_FALLBACK
- if (destination.sin_addr.s_addr != INADDR_BROADCAST)
- result = send_fallback (&fallback_interface,
- (struct packet *)0,
- &ip -> client -> packet,
- ip -> client -> packet_length,
- from, &destination,
- (struct hardware *)0);
+ if (destination.sin_addr.s_addr != INADDR_BROADCAST &&
+ fallback_interface)
+ result = send_packet (fallback_interface,
+ (struct packet *)0,
+ &ip -> client -> packet,
+ ip -> client -> packet_length,
+ from, &destination,
+ (struct hardware *)0);
else
-#endif /* USE_FALLBACK */
/* Send out a packet. */
result = send_packet (ip, (struct packet *)0,
&ip -> client -> packet,
@@ -1473,18 +1525,20 @@ void make_request (ip, lease)
ip -> client -> packet.hops = 0;
ip -> client -> packet.xid = ip -> client -> xid;
ip -> client -> packet.secs = 0; /* Filled in by send_request. */
- ip -> client -> packet.flags = htons (BOOTP_BROADCAST);
/* If we own the address we're requesting, put it in ciaddr;
otherwise set ciaddr to zero. */
if (ip -> client -> state == S_BOUND ||
ip -> client -> state == S_RENEWING ||
- ip -> client -> state == S_REBINDING)
+ ip -> client -> state == S_REBINDING) {
memcpy (&ip -> client -> packet.ciaddr,
lease -> address.iabuf, lease -> address.len);
- else
+ ip -> client -> packet.flags = 0;
+ } else {
memset (&ip -> client -> packet.ciaddr, 0,
sizeof ip -> client -> packet.ciaddr);
+ ip -> client -> packet.flags = htons (BOOTP_BROADCAST);
+ }
memset (&ip -> client -> packet.yiaddr, 0,
sizeof ip -> client -> packet.yiaddr);
@@ -1636,7 +1690,7 @@ void make_release (ip, lease)
ip -> client -> packet.htype = ip -> hw_address.htype;
ip -> client -> packet.hlen = ip -> hw_address.hlen;
ip -> client -> packet.hops = 0;
- ip -> client -> packet.xid = ip -> client -> packet.xid;
+ ip -> client -> packet.xid = ip -> client -> xid;
ip -> client -> packet.secs = 0;
ip -> client -> packet.flags = 0;
memcpy (&ip -> client -> packet.ciaddr,
@@ -1684,36 +1738,45 @@ void rewrite_client_leases ()
fclose (leaseFile);
leaseFile = fopen (path_dhclient_db, "w");
if (!leaseFile)
- error ("can't create /var/db/dhclient.leases: %m");
+ error ("can't create %s: %m", path_dhclient_db);
/* Write out all the leases attached to configured interfaces that
we know about. */
for (ip = interfaces; ip; ip = ip -> next) {
for (lp = ip -> client -> leases; lp; lp = lp -> next) {
- write_client_lease (ip, lp);
+ write_client_lease (ip, lp, 1);
}
if (ip -> client -> active)
- write_client_lease (ip, ip -> client -> active);
+ write_client_lease (ip, ip -> client -> active, 1);
}
/* Write out any leases that are attached to interfaces that aren't
currently configured. */
for (ip = dummy_interfaces; ip; ip = ip -> next) {
for (lp = ip -> client -> leases; lp; lp = lp -> next) {
- write_client_lease (ip, lp);
+ write_client_lease (ip, lp, 1);
}
if (ip -> client -> active)
- write_client_lease (ip, ip -> client -> active);
+ write_client_lease (ip, ip -> client -> active, 1);
}
fflush (leaseFile);
}
-void write_client_lease (ip, lease)
+void write_client_lease (ip, lease, rewrite)
struct interface_info *ip;
struct client_lease *lease;
+ int rewrite;
{
int i;
struct tm *t;
+ static int leases_written;
+
+ if (!rewrite) {
+ if (leases_written++ > 20) {
+ rewrite_client_leases ();
+ leases_written = 0;
+ }
+ }
/* If the lease came from the config file, we don't need to stash
a copy in the lease database. */
@@ -1723,7 +1786,7 @@ void write_client_lease (ip, lease)
if (!leaseFile) { /* XXX */
leaseFile = fopen (path_dhclient_db, "w");
if (!leaseFile)
- error ("can't create /var/db/dhclient.leases: %m");
+ error ("can't create %s: %m", path_dhclient_db);
}
fprintf (leaseFile, "lease {\n");
@@ -1751,6 +1814,10 @@ void write_client_lease (ip, lease)
lease -> options [i].len, 1, 1));
}
}
+
+ /* Note: the following is not a Y2K bug - it's a Y1.9K bug. Until
+ somebody invents a time machine, I think we can safely disregard
+ it. */
t = gmtime (&lease -> renewal);
fprintf (leaseFile,
" renew %d %d/%d/%d %02d:%02d:%02d;\n",
@@ -1793,7 +1860,9 @@ void script_init (ip, reason, medium)
#ifdef HAVE_MKSTEMP
fd = mkstemp (scriptName);
#else
- mktemp (scriptName);
+ if (!mktemp (scriptName))
+ error ("can't create temporary client script %s: %m",
+ scriptName);
fd = creat (scriptName, 0600);
} while (fd < 0);
#endif
diff --git a/contrib/isc-dhcp/client/scripts/freebsd b/contrib/isc-dhcp/client/scripts/freebsd
index 7236a67a9a9a..77fdc5c9f26e 100755
--- a/contrib/isc-dhcp/client/scripts/freebsd
+++ b/contrib/isc-dhcp/client/scripts/freebsd
@@ -155,6 +155,7 @@ if [ x$reason = xTIMEOUT ]; then
mv /etc/resolv.conf.std /etc/resolv.conf
exit 0
fi
+ fi
ifconfig $interface inet -alias $new_ip_address $medium
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
diff --git a/contrib/isc-dhcp/common/alloc.c b/contrib/isc-dhcp/common/alloc.c
index 172fcea606dd..a9584622a6ba 100644
--- a/contrib/isc-dhcp/common/alloc.c
+++ b/contrib/isc-dhcp/common/alloc.c
@@ -3,7 +3,7 @@
Memory allocation... */
/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
+ * Copyright (c) 1995, 1996, 1998 The Internet Software Consortium.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: alloc.c,v 1.13 1997/05/09 07:56:13 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: alloc.c,v 1.13.2.1 1998/11/24 22:17:15 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -57,7 +57,8 @@ VOIDPTR dmalloc (size, name)
VOIDPTR foo = (VOIDPTR)malloc (size);
if (!foo)
warn ("No memory for %s.", name);
- memset (foo, 0, size);
+ else
+ memset (foo, 0, size);
return foo;
}
diff --git a/contrib/isc-dhcp/common/bpf.c b/contrib/isc-dhcp/common/bpf.c
index e47aa1f7822c..ba42a43903cd 100644
--- a/contrib/isc-dhcp/common/bpf.c
+++ b/contrib/isc-dhcp/common/bpf.c
@@ -3,8 +3,8 @@
BPF socket interface code, originally contributed by Archie Cobbs. */
/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
+ * Copyright (c) 1995, 1996, 1998, 1999
+ * The Internet Software Consortium. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -42,22 +42,31 @@
#ifndef lint
static char copyright[] =
-"$Id: bpf.c,v 1.19 1997/10/20 21:47:13 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: bpf.c,v 1.19.2.6 1999/02/09 04:46:59 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
-#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE)
-#include <sys/ioctl.h>
-#include <sys/uio.h>
+#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE) \
+ || defined (USE_LPF_RECEIVE)
+# if defined (USE_LPF_RECEIVE)
+# include <asm/types.h>
+# include <linux/filter.h>
+# define bpf_insn sock_filter /* Linux: dare to be gratuitously different. */
+# else
+# include <sys/ioctl.h>
+# include <sys/uio.h>
+
+# include <net/bpf.h>
+# if defined (NEED_OSF_PFILT_HACKS)
+# include <net/pfilt.h>
+# endif
+# endif
-#include <net/bpf.h>
-#ifdef NEED_OSF_PFILT_HACKS
-#include <net/pfilt.h>
-#endif
#include <netinet/in_systm.h>
#include "includes/netinet/ip.h"
#include "includes/netinet/udp.h"
#include "includes/netinet/if_ether.h"
+#endif
/* Reinitializes the specified interface after an address change. This
is not required for packet-filter APIs. */
@@ -80,6 +89,7 @@ void if_reinitialize_receive (info)
Opens a packet filter for each interface and adds it to the select
mask. */
+#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE)
int if_register_bpf (info)
struct interface_info *info;
{
@@ -99,6 +109,11 @@ int if_register_bpf (info)
if (errno == EBUSY) {
continue;
} else {
+ if (!b)
+ error ("No bpf devices.%s%s%s",
+ " Please read the README",
+ " section for your operating",
+ " system.");
error ("Can't find free bpf: %m");
}
} else {
@@ -137,12 +152,12 @@ void if_register_send (info)
}
#endif /* USE_BPF_SEND */
-#ifdef USE_BPF_RECEIVE
+#if defined (USE_BPF_RECEIVE) || defined (USE_LPF_RECEIVE)
/* Packet filter program...
XXX Changes to the filter program may require changes to the constant
offsets used in if_register_send to patch the BPF program! XXX */
-struct bpf_insn filter [] = {
+struct bpf_insn dhcp_bpf_filter [] = {
/* Make sure this is an IP packet... */
BPF_STMT (BPF_LD + BPF_H + BPF_ABS, 12),
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 8),
@@ -169,6 +184,10 @@ struct bpf_insn filter [] = {
BPF_STMT(BPF_RET+BPF_K, 0),
};
+int dhcp_bpf_filter_len = sizeof dhcp_bpf_filter / sizeof (struct bpf_insn);
+#endif
+
+#if defined (USE_BPF_RECEIVE)
void if_register_receive (info)
struct interface_info *info;
{
@@ -220,13 +239,13 @@ void if_register_receive (info)
info -> rbuf_len = 0;
/* Set up the bpf filter program structure. */
- p.bf_len = sizeof filter / sizeof (struct bpf_insn);
- p.bf_insns = filter;
+ p.bf_len = dhcp_bpf_filter_len;
+ p.bf_insns = dhcp_bpf_filter;
/* Patch the server port into the BPF program...
XXX changes to filter program may require changes
to the insn number(s) used below! XXX */
- filter [8].k = ntohs (local_port);
+ dhcp_bpf_filter [8].k = ntohs (local_port);
if (ioctl (info -> rfdesc, BIOCSETF, &p) < 0)
error ("Can't install packet filter program: %m");
@@ -255,6 +274,10 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
unsigned char buf [256];
struct iovec iov [2];
+ if (!strcmp (interface -> name, "fallback"))
+ return send_fallback (interface, packet, raw,
+ len, from, to, hto);
+
/* Assemble the headers... */
assemble_hw_header (interface, buf, &bufp, hto);
assemble_udp_ip_header (interface, buf, &bufp, from.s_addr,
@@ -383,4 +406,20 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
} while (!length);
return 0;
}
+
+int can_unicast_without_arp ()
+{
+ return 1;
+}
+
+void maybe_setup_fallback ()
+{
+ struct interface_info *fbi;
+ fbi = setup_fallback ();
+ if (fbi) {
+ if_register_fallback (fbi);
+ add_protocol ("fallback", fallback_interface -> wfdesc,
+ fallback_discard, fallback_interface);
+ }
+}
#endif
diff --git a/contrib/isc-dhcp/common/conflex.c b/contrib/isc-dhcp/common/conflex.c
index eedfa054b662..c84daad6bcb8 100644
--- a/contrib/isc-dhcp/common/conflex.c
+++ b/contrib/isc-dhcp/common/conflex.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: conflex.c,v 1.29 1997/10/29 18:32:53 mellon Exp $ Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. All rights reserved.\n";
+"$Id: conflex.c,v 1.29.2.3 1999/02/09 04:49:04 mellon Exp $ Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -362,6 +362,8 @@ static int intern (atom, dfv)
return ALIAS;
if (!strcasecmp (atom + 1, "bandoned"))
return ABANDONED;
+ if (!strcasecmp (atom + 1, "uthoritative"))
+ return AUTHORITATIVE;
break;
case 'b':
if (!strcasecmp (atom + 1, "ackoff-cutoff"))
@@ -417,6 +419,8 @@ static int intern (atom, dfv)
return FILENAME;
if (!strcasecmp (atom + 1, "ixed-address"))
return FIXED_ADDR;
+ if (!strcasecmp (atom + 1, "ddi"))
+ return FDDI;
break;
case 'g':
if (!strcasecmp (atom + 1, "iaddr"))
@@ -462,6 +466,8 @@ static int intern (atom, dfv)
return NETMASK;
if (!strcasecmp (atom + 1, "ext-server"))
return NEXT_SERVER;
+ if (!strcasecmp (atom + 1, "ot"))
+ return TOKEN_NOT;
break;
case 'o':
if (!strcasecmp (atom + 1, "ption"))
@@ -526,12 +532,18 @@ static int intern (atom, dfv)
return TOKEN_RING;
break;
case 'u':
+ if (!strncasecmp (atom + 1, "se", 2)) {
+ if (!strcasecmp (atom + 3, "r-class"))
+ return USER_CLASS;
+ if (!strcasecmp (atom + 3, "-host-decl-names"))
+ return USE_HOST_DECL_NAMES;
+ if (!strcasecmp (atom + 3,
+ "-lease-addr-for-default-route"))
+ return USE_LEASE_ADDR_FOR_DEFAULT_ROUTE;
+ break;
+ }
if (!strcasecmp (atom + 1, "id"))
return UID;
- if (!strcasecmp (atom + 1, "ser-class"))
- return USER_CLASS;
- if (!strcasecmp (atom + 1, "se-host-decl-names"))
- return USE_HOST_DECL_NAMES;
if (!strcasecmp (atom + 1, "nknown-clients"))
return UNKNOWN_CLIENTS;
break;
diff --git a/contrib/isc-dhcp/common/dhcp-options.5 b/contrib/isc-dhcp/common/dhcp-options.5
index eb90ed6eac9b..3375c507f14d 100644
--- a/contrib/isc-dhcp/common/dhcp-options.5
+++ b/contrib/isc-dhcp/common/dhcp-options.5
@@ -1,6 +1,6 @@
.\" dhcp-options.5
.\"
-.\" Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
+.\" Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -126,7 +126,8 @@ no checking is done to ensure the correctness of the entered data.
.PP
The standard options are:
.PP
- \fBoption subnet-mask\fR \fIip-address\fR\fB;\fR
+.B option subnet-mask \fIip-address\fR\fB;\fR
+.RS 0.25i
.PP
The subnet mask option specifies the client's subnet mask as per RFC
950. If no subnet mask option is provided anywhere in scope, as a
@@ -136,114 +137,162 @@ for the network on which an address is being assigned. However,
subnet-mask option declaration that is in scope for the address being
assigned will override the subnet mask specified in the subnet
declaration.
+.RE
.PP
- \fBoption time-offset\fR \fIint32\fR\fB;\fR
+.B option time-offset \fIint32\fR\fB;\fR
+.RS 0.25i
.PP
The time-offset option specifies the offset of the client's subnet in
seconds from Coordinated Universal Time (UTC).
+.RE
.PP
- \fBoption routers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option routers \fIip-address\fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
The routers option specifies a list of IP addresses for routers on the
client's subnet. Routers should be listed in order of preference.
+.RE
.PP
- \fBoption time-servers\fR \fIip-address [, \fIip-address\fR ... ]\fB;\fR
+.B option time-servers \fIip-address\fR [, \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
The time-server option specifies a list of RFC 868 time servers
available to the client. Servers should be listed in order of
preference.
+.RE
.PP
- \fBoption\fR \fBien116-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ];
+.B option \fBien116-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR...
+];
+.RS 0.25i
.PP
The ien116-name-servers option specifies a list of IEN 116 name servers
available to the client. Servers should be listed in order of
preference.
+.RE
.PP
- \fBoption\fR \fBdomain-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option \fBdomain-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
The domain-name-servers option specifies a list of Domain Name System
(STD 13, RFC 1035) name servers available to the client. Servers
should be listed in order of preference.
+.RE
.PP
- \fBoption\fR \fBlog-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option \fBlog-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
The log-server option specifies a list of MIT-LCS UDP log servers
available to the client. Servers should be listed in order of
preference.
+.RE
.PP
- \fBoption\fR \fBcookie-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option \fBcookie-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
The cookie server option specifies a list of RFC 865 cookie
servers available to the client. Servers should be listed in order
of preference.
+.RE
.PP
- \fBoption\fR \fBlpr-servers\fR \fIip-address \fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option \fBlpr-servers\fR \fIip-address \fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
The LPR server option specifies a list of RFC 1179 line printer
servers available to the client. Servers should be listed in order
of preference.
+.RE
.PP
- \fBoption\fR \fBimpress-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option \fBimpress-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
The impress-server option specifies a list of Imagen Impress servers
available to the client. Servers should be listed in order of
preference.
+.RE
.PP
- \fBoption\fR \fBresource-location-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option \fBresource-location-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
This option specifies a list of RFC 887 Resource Location
servers available to the client. Servers should be listed in order
of preference.
+.RE
.PP
- \fBoption\fR \fBhost-name\fR \fIstring\fR\fB;\fR
+.B option \fBhost-name\fR \fIstring\fR\fB;\fR
+.RS 0.25i
.PP
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.
+.RE
.PP
- \fBoption\fR \fBboot-size\fR \fIuint16\fR\fB;\fR
+.B option \fBboot-size\fR \fIuint16\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the length in 512-octet blocks of the default
boot image for the client.
+.RE
.PP
- \fBoption\fR \fBmerit-dump\fR \fIstring\fR\fB;\fR
+.B option \fBmerit-dump\fR \fIstring\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the path-name of a file to which the client's
core image should be dumped in the event the client crashes. The
path is formatted as a character string consisting of characters from
the NVT ASCII character set.
+.RE
.PP
- \fBoption\fR \fBdomain-name\fR \fIstring\fR\fB;\fR
+.B option \fBdomain-name\fR \fIstring\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the domain name that client should use when
resolving hostnames via the Domain Name System.
+.RE
.PP
- \fBoption\fR \fBswap-server\fR \fIip-address\fR\fB;\fR
+.B option \fBswap-server\fR \fIip-address\fR\fB;\fR
+.RS 0.25i
.PP
This specifies the IP address of the client's swap server.
+.RE
.PP
- \fBoption\fR \fBroot-path\fR \fIstring\fB;\fR\fR
+.B option \fBroot-path\fR \fIstring\fB;\fR\fR
+.RS 0.25i
.PP
This option specifies the path-name that contains the client's root
disk. The path is formatted as a character string consisting of
characters from the NVT ASCII character set.
+.RE
.PP
- \fBoption\fR \fBip-forwarding\fR \fIflag\fR\fB;\fR
+.B option \fBip-forwarding\fR \fIflag\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies whether the client should configure its IP
layer for packet forwarding. A value of 0 means disable IP
forwarding, and a value of 1 means enable IP forwarding.
+.RE
.PP
- \fBoption\fR \fBnon-local-source-routing\fR \fIflag\fR\fB;\fR
+.B option \fBnon-local-source-routing\fR \fIflag\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies whether the client should configure its IP
layer to allow forwarding of datagrams with non-local source routes
(see Section 3.3.5 of [4] for a discussion of this topic). A value
of 0 means disallow forwarding of such datagrams, and a value of 1
means allow forwarding.
+.RE
.PP
- \fBoption\fR \fBpolicy-filter\fR \fIip-address ip-address\fR [\fB,\fR \fIip-address ip-address\fR ... ]\fB;\fR
+.B option \fBpolicy-filter\fR \fIip-address ip-address\fR [\fB,\fR \fIip-address ip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
This option specifies policy filters for non-local source routing.
The filters consist of a list of IP addresses and masks which specify
@@ -253,36 +302,49 @@ Any source routed datagram whose next-hop address does not match one
of the filters should be discarded by the client.
.PP
See STD 3 (RFC1122) for further information.
+.RE
.PP
- \fBoption\fR \fBmax-dgram-reassembly\fR \fIuint16\fR\fB;\fR
+.B option \fBmax-dgram-reassembly\fR \fIuint16\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the maximum size datagram that the client
should be prepared to reassemble. The minimum value legal value is
576.
+.RE
.PP
- \fBoption\fR \fBdefault-ip-ttl\fR \fIuint8;\fR
+.B option \fBdefault-ip-ttl\fR \fIuint8;\fR
+.RS 0.25i
.PP
This option specifies the default time-to-live that the client should
use on outgoing datagrams.
+.RE
.PP
- \fBoption\fR \fBpath-mtu-aging-timeout\fR \fIuint32\fR\fB;\fR
+.B option \fBpath-mtu-aging-timeout\fR \fIuint32\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the timeout (in seconds) to use when aging Path
MTU values discovered by the mechanism defined in RFC 1191.
+.RE
.PP
- \fBoption\fR \fBpath-mtu-plateau-table\fR \fIuint16\fR [\fB,\fR \fIuint16\fR ... ]\fB;\fR
+.B option \fBpath-mtu-plateau-table\fR \fIuint16\fR [\fB,\fR \fIuint16\fR...
+]\fB;\fR
+.RS 0.25i
.PP
This option specifies a table of MTU sizes to use when performing
Path MTU Discovery as defined in RFC 1191. The table is formatted as
a list of 16-bit unsigned integers, ordered from smallest to largest.
The minimum MTU value cannot be smaller than 68.
+.RE
.PP
- \fBoption\fR \fBinterface-mtu\fR \fIuint16\fR\fB;\fR
+.B option \fBinterface-mtu\fR \fIuint16\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the MTU to use on this interface. The minimum
legal value for the MTU is 68.
+.RE
.PP
- \fBoption\fR \fBall-subnets-local\fR \fIflag\fR\fB;\fR
+.B option \fBall-subnets-local\fR \fIflag\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies whether or not the client may assume that all
subnets of the IP network to which the client is connected use the
@@ -290,41 +352,54 @@ same MTU as the subnet of that network to which the client is
directly connected. A value of 1 indicates that all subnets share
the same MTU. A value of 0 means that the client should assume that
some subnets of the directly connected network may have smaller MTUs.
+.RE
.PP
- \fBoption\fR \fBbroadcast-address\fR \fIip-address\fR\fB;\fR
+.B option \fBbroadcast-address\fR \fIip-address\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the broadcast address in use on the client's
subnet. Legal values for broadcast addresses are specified in
section 3.2.1.3 of STD 3 (RFC1122).
+.RE
.PP
- \fBoption\fR \fBperform-mask-discovery\fR \fIflag\fR\fB;\fR
+.B option \fBperform-mask-discovery\fR \fIflag\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies whether or not the client should perform subnet
mask discovery using ICMP. A value of 0 indicates that the client
should not perform mask discovery. A value of 1 means that the
client should perform mask discovery.
+.RE
.PP
- \fBoption\fR \fBmask-supplier\fR \fIflag\fR\fB;\fR
+.B option \fBmask-supplier\fR \fIflag\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies whether or not the client should respond to
subnet mask requests using ICMP. A value of 0 indicates that the
client should not respond. A value of 1 means that the client should
respond.
+.RE
.PP
- \fBoption\fR \fBrouter-discovery\fR \fIflag\fR\fB;\fR
+.B option \fBrouter-discovery\fR \fIflag\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies whether or not the client should solicit
routers using the Router Discovery mechanism defined in RFC 1256.
A value of 0 indicates that the client should not perform
router discovery. A value of 1 means that the client should perform
router discovery.
+.RE
.PP
- \fBoption\fR \fBrouter-solicitation-address\fR \fIip-address\fR\fB;\fR
+.B option \fBrouter-solicitation-address\fR \fIip-address\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the address to which the client should transmit
router solicitation requests.
+.RE
.PP
- \fBoption\fR \fBstatic-routes\fR \fIip-address ip-address\fR [\fB,\fR \fIip-address ip-address\fR ... ]\fB;\fR
+.B option \fBstatic-routes\fR \fIip-address ip-address\fR [\fB,\fR \fIip-address ip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
This option specifies a list of static routes that the client should
install in its routing cache. If multiple routes to the same
@@ -339,106 +414,161 @@ The default route (0.0.0.0) is an illegal destination for a static
route. To specify the default route, use the
.B routers
option.
+.RE
.PP
- \fBoption\fR \fBtrailer-encapsulation\fR \fIflag\fR\fB;\fR
+.B option \fBtrailer-encapsulation\fR \fIflag\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies whether or not the client should negotiate the
use of trailers (RFC 893 [14]) when using the ARP protocol. A value
of 0 indicates that the client should not attempt to use trailers. A
value of 1 means that the client should attempt to use trailers.
+.RE
.PP
- \fBoption\fR \fBarp-cache-timeout\fR \fIuint32\fR\fB;\fR
+.B option \fBarp-cache-timeout\fR \fIuint32\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the timeout in seconds for ARP cache entries.
+.RE
.PP
- \fBoption\fR \fBieee802-3-encapsulation\fR \fIflag\fR\fB;\fR
+.B option \fBieee802-3-encapsulation\fR \fIflag\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies whether or not the client should use Ethernet
Version 2 (RFC 894) or IEEE 802.3 (RFC 1042) encapsulation if the
interface is an Ethernet. A value of 0 indicates that the client
should use RFC 894 encapsulation. A value of 1 means that the client
should use RFC 1042 encapsulation.
+.RE
.PP
- \fBoption\fR \fBdefault-tcp-ttl\fR \fIuint8\fR\fB;\fR
+.B option \fBdefault-tcp-ttl\fR \fIuint8\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the default TTL that the client should use when
sending TCP segments. The minimum value is 1.
+.RE
.PP
- \fBoption\fR \fBtcp-keepalive-interval\fR \fIuint32\fR\fB;\fR
+.B option \fBtcp-keepalive-interval\fR \fIuint32\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the interval (in seconds) that the client TCP
should wait before sending a keepalive message on a TCP connection.
The time is specified as a 32-bit unsigned integer. A value of zero
indicates that the client should not generate keepalive messages on
connections unless specifically requested by an application.
+.RE
.PP
- \fBoption\fR \fBtcp-keepalive-garbage\fR \fIflag\fR\fB;\fR
+.B option \fBtcp-keepalive-garbage\fR \fIflag\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the whether or not the client should send TCP
keepalive messages with a octet of garbage for compatibility with
older implementations. A value of 0 indicates that a garbage octet
should not be sent. A value of 1 indicates that a garbage octet
should be sent.
+.RE
.PP
- \fBoption\fR \fBnis-domain\fR \fIstring\fR\fB;\fR
+.B option \fBnis-domain\fR \fIstring\fR\fB;\fR
+.RS 0.25i
.PP
This option specifies the name of the client's NIS (Sun Network
Information Services) domain. The domain is formatted as a character
string consisting of characters from the NVT ASCII character set.
+.RE
.PP
- \fBoption\fR \fBnis-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option \fBnis-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
This option specifies a list of IP addresses indicating NIS servers
available to the client. Servers should be listed in order of
preference.
+.RE
.PP
- \fBoption\fR \fBntp-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option \fBntp-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
This option specifies a list of IP addresses indicating NTP (RFC 1035)
servers available to the client. Servers should be listed in order
of preference.
+.RE
.PP
- \fBoption\fR \fBnetbios-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option \fBnetbios-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
The NetBIOS name server (NBNS) option specifies a list of RFC
-1001/1002 NBNS name servers listed in order of preference.
+1001/1002 NBNS name servers listed in order of preference. NetBIOS
+Name Service is currently more commonly referred to as WINS. WINS
+servers can be specified using the netbios-name-servers option.
+.RE
.PP
- \fBoption\fR \fBnetbios-dd-server\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option \fBnetbios-dd-server\fR \fIip-address\fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
The NetBIOS datagram distribution server (NBDD) option specifies a
list of RFC 1001/1002 NBDD servers listed in order of preference.
+.RE
.PP
- \fBoption\fR \fBnetbios-node-type\fR \fIuint8\fR\fB;\fR
+.B option \fBnetbios-node-type\fR \fIuint8\fR\fB;\fR
+.RS 0.25i
.PP
The NetBIOS node type option allows NetBIOS over TCP/IP clients which
are configurable to be configured as described in RFC 1001/1002. The
value is specified as a single octet which identifies the client type.
-A value of 1 corresponds to a NetBIOS B-node; a value of 2 corresponds
-to a P-node; a value of 4 corresponds to an M-node; a value of 8
-corresponds to an H-node.
.PP
- \fBoption\fR \fBnetbios-scope\fR \fIstring\fR\fB;\fR
+Possible node types are:
+.PP
+.TP 5
+.I 1
+B-node: Broadcast - no WINS
+.TP
+.I 2
+P-node: Peer - WINS only.
+.TP
+.I 4
+M-node: Mixed - broadcast, then WINS
+.TP
+.I 8
+H-node: Hybrid - WINS, then broadcast
+.RE
+.PP
+.B option
+.B netbios-scope
+.I string\fB;\fR
+.RS 0.25i
.PP
The NetBIOS scope option specifies the NetBIOS over TCP/IP scope
parameter for the client as specified in RFC 1001/1002. See RFC1001,
RFC1002, and RFC1035 for character-set restrictions.
+.RE
.PP
- \fBoption\fR \fBfont-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option \fBfont-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
This option specifies a list of X Window System Font servers available
to the client. Servers should be listed in order of preference.
+.RE
.PP
- \fBoption\fR \fBx-display-manager\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
+.B option \fBx-display-manager\fR \fIip-address\fR [\fB,\fR \fIip-address\fR...
+]\fB;\fR
+.RS 0.25i
.PP
This option specifies a list of systems that are running the X Window
System Display Manager and are available to the client. Addresses
should be listed in order of preference.
+.RE
.PP
- \fBoption\fR \fBdhcp-client-identifier\fR \fIdata-string\fR\fB;\fR
+.B option \fBdhcp-client-identifier\fR \fIdata-string\fR\fB;\fR
+.RS 0.25i
.PP
This option can be used to specify the a DHCP client identifier in a
host declaration, so that dhcpd can find the host record by matching
against the client identifier.
+.RE
.SH SEE ALSO
dhcpd.conf(5), dhcpd.leases(5), dhclient.conf(5), dhcpd(8),
dhclient(8), RFC2132, RFC2131.
diff --git a/contrib/isc-dhcp/common/dispatch.c b/contrib/isc-dhcp/common/dispatch.c
index 92fd579b70ab..0a383a04d48c 100644
--- a/contrib/isc-dhcp/common/dispatch.c
+++ b/contrib/isc-dhcp/common/dispatch.c
@@ -3,7 +3,7 @@
Network input dispatcher... */
/*
- * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium.
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -42,13 +42,13 @@
#ifndef lint
static char copyright[] =
-"$Id: dispatch.c,v 1.47.2.2 1998/06/25 21:11:28 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dispatch.c,v 1.47.2.9 1999/02/05 20:23:50 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#include <sys/ioctl.h>
-struct interface_info *interfaces, *dummy_interfaces;
+struct interface_info *interfaces, *dummy_interfaces, *fallback_interface;
struct protocol *protocols;
struct timeout *timeouts;
static struct timeout *free_timeouts;
@@ -57,7 +57,6 @@ void (*bootp_packet_handler) PROTO ((struct interface_info *,
struct dhcp_packet *, int, unsigned int,
struct iaddr, struct hardware *));
-static void got_one PROTO ((struct protocol *));
int quiet_interface_discovery;
/* Use the SIOCGIFCONF ioctl to get a list of all the attached interfaces.
@@ -83,9 +82,6 @@ void discover_interfaces (state)
#ifdef ALIAS_NAMES_PERMUTED
char *s;
#endif
-#ifdef USE_FALLBACK
- static struct shared_network fallback_network;
-#endif
/* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */
if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
@@ -110,9 +106,7 @@ void discover_interfaces (state)
else
ir = INTERFACE_REQUESTED;
- /* Cycle through the list of interfaces looking for IP addresses.
- Go through twice; once to count the number of addresses, and a
- second time to copy them into an array of addresses. */
+ /* Cycle through the list of interfaces looking for IP addresses. */
for (i = 0; i < ic.ifc_len;) {
struct ifreq *ifp = (struct ifreq *)((caddr_t)ic.ifc_req + i);
#ifdef HAVE_SA_LEN
@@ -187,59 +181,6 @@ void discover_interfaces (state)
if (ifp -> ifr_addr.sa_family == AF_INET) {
struct iaddr addr;
-#if defined (SIOCGIFHWADDR) && !defined (AF_LINK)
- struct ifreq ifr;
- struct sockaddr sa;
- int b, sk;
-
- /* Read the hardware address from this interface. */
- ifr = *ifp;
- if (ioctl (sock, SIOCGIFHWADDR, &ifr) < 0)
- error ("Can't get hardware address for %s: %m",
- ifr.ifr_name);
-
- sa = *(struct sockaddr *)&ifr.ifr_hwaddr;
-
- switch (sa.sa_family) {
-#ifdef ARPHRD_LOOPBACK
- case ARPHRD_LOOPBACK:
- /* ignore loopback interface */
- break;
-#endif
-
- case ARPHRD_ETHER:
- tmp -> hw_address.hlen = 6;
- tmp -> hw_address.htype = ARPHRD_ETHER;
- memcpy (tmp -> hw_address.haddr,
- sa.sa_data, 6);
- break;
-
-#ifndef ARPHRD_IEEE802
-# define ARPHRD_IEEE802 HTYPE_IEEE802
-#endif
- case ARPHRD_IEEE802:
- tmp -> hw_address.hlen = 6;
- tmp -> hw_address.htype = ARPHRD_IEEE802;
- memcpy (tmp -> hw_address.haddr,
- sa.sa_data, 6);
- break;
-
-#ifdef ARPHRD_METRICOM
- case ARPHRD_METRICOM:
- tmp -> hw_address.hlen = 6;
- tmp -> hw_address.htype = ARPHRD_METRICOM;
- memcpy (tmp -> hw_address.haddr,
- sa.sa_data, 6);
-
- break;
-#endif
-
- default:
- error ("%s: unknown hardware address type %d",
- ifr.ifr_name, sa.sa_family);
- }
-#endif /* defined (SIOCGIFHWADDR) && !defined (AF_LINK) */
-
/* Get a pointer to the address... */
memcpy (&foo, &ifp -> ifr_addr,
sizeof ifp -> ifr_addr);
@@ -312,6 +253,157 @@ void discover_interfaces (state)
}
}
+#if defined (LINUX_SLASHPROC_DISCOVERY)
+ /* On Linux, interfaces that don't have IP addresses don't show up
+ in the SIOCGIFCONF syscall. We got away with this prior to
+ Linux 2.1 because we would give each interface an IP address of
+ 0.0.0.0 before trying to boot, but that doesn't work after 2.1
+ because we're using LPF, because we can't configure interfaces
+ with IP addresses of 0.0.0.0 anymore (grumble). This only
+ matters for the DHCP client, of course - the relay agent and
+ server should only care about interfaces that are configured
+ with IP addresses anyway.
+
+ The PROCDEV_DEVICE (/proc/net/dev) is a kernel-supplied file
+ that, when read, prints a human readable network status. We
+ extract the names of the network devices by skipping the first
+ two lines (which are header) and then parsing off everything
+ up to the colon in each subsequent line - these lines start
+ with the interface name, then a colon, then a bunch of
+ statistics. Yes, Virgina, this is a kludge, but you work
+ with what you have. */
+
+ if (state == DISCOVER_UNCONFIGURED) {
+ FILE *proc_dev;
+ char buffer [256];
+ struct ifreq *tif;
+ int skip = 2;
+
+ proc_dev = fopen (PROCDEV_DEVICE, "r");
+ if (!proc_dev)
+ error ("%s: %m", PROCDEV_DEVICE);
+
+ while (fgets (buffer, sizeof buffer, proc_dev)) {
+ char *name = buffer;
+ char *sep;
+
+ /* Skip the first two blocks, which are header
+ lines. */
+ if (skip) {
+ --skip;
+ continue;
+ }
+
+ sep = strrchr (buffer, ':');
+ if (sep)
+ *sep = '\0';
+ while (*name == ' ')
+ name++;
+
+ /* See if we've seen an interface that matches
+ this one. */
+ for (tmp = interfaces; tmp; tmp = tmp -> next)
+ if (!strcmp (tmp -> name, name))
+ break;
+
+ /* If we found one, and it already has an ifreq
+ structure, nothing more to do.. */
+ if (tmp && tmp -> ifp)
+ continue;
+
+ /* Make up an ifreq structure. */
+ tif = (struct ifreq *)malloc (sizeof (struct ifreq));
+ if (!tif)
+ error ("no space to remember ifp.");
+ memset (tif, 0, sizeof (struct ifreq));
+ strcpy (tif -> ifr_name, name);
+
+ /* Now, if we just needed the ifreq structure, hook
+ it in and move on. */
+ if (tmp) {
+ tmp -> ifp = tif;
+ continue;
+ }
+
+ /* Otherwise, allocate one. */
+ tmp = ((struct interface_info *)
+ dmalloc (sizeof *tmp, "discover_interfaces"));
+ if (!tmp)
+ error ("Insufficient memory to %s %s",
+ "record interface", name);
+ memset (tmp, 0, sizeof *tmp);
+ strcpy (tmp -> name, name);
+
+ tmp -> ifp = tif;
+ tmp -> flags = ir;
+ tmp -> next = interfaces;
+ interfaces = tmp;
+ }
+ fclose (proc_dev);
+ }
+#endif
+
+ /* Now cycle through all the interfaces we found, looking for
+ hardware addresses. */
+#if defined (SIOCGIFHWADDR) && !defined (AF_LINK)
+ for (tmp = interfaces; tmp; tmp = tmp -> next) {
+ struct ifreq ifr;
+ struct sockaddr sa;
+ int b, sk;
+
+ /* Read the hardware address from this interface. */
+ ifr = *tmp -> ifp;
+ if (ioctl (sock, SIOCGIFHWADDR, &ifr) < 0)
+ continue;
+
+ sa = *(struct sockaddr *)&ifr.ifr_hwaddr;
+
+ switch (sa.sa_family) {
+#ifdef ARPHRD_LOOPBACK
+ case ARPHRD_LOOPBACK:
+ /* ignore loopback interface */
+ break;
+#endif
+
+ case ARPHRD_ETHER:
+ tmp -> hw_address.hlen = 6;
+ tmp -> hw_address.htype = ARPHRD_ETHER;
+ memcpy (tmp -> hw_address.haddr, sa.sa_data, 6);
+ break;
+
+#ifndef ARPHRD_IEEE802
+# define ARPHRD_IEEE802 HTYPE_IEEE802
+#endif
+ case ARPHRD_IEEE802:
+ tmp -> hw_address.hlen = 6;
+ tmp -> hw_address.htype = ARPHRD_IEEE802;
+ memcpy (tmp -> hw_address.haddr, sa.sa_data, 6);
+ break;
+
+#ifndef ARPHRD_FDDI
+# define ARPHRD_FDDI HTYPE_FDDI
+#endif
+ case ARPHRD_FDDI:
+ tmp -> hw_address.hlen = 16;
+ tmp -> hw_address.htype = HTYPE_FDDI; /* XXX */
+ memcpy (tmp -> hw_address.haddr, sa.sa_data, 16);
+ break;
+
+#ifdef ARPHRD_METRICOM
+ case ARPHRD_METRICOM:
+ tmp -> hw_address.hlen = 6;
+ tmp -> hw_address.htype = ARPHRD_METRICOM;
+ memcpy (tmp -> hw_address.haddr, sa.sa_data, 6);
+ break;
+#endif
+
+ default:
+ error ("%s: unknown hardware address type %d",
+ ifr.ifr_name, sa.sa_family);
+ }
+ }
+#endif /* defined (SIOCGIFHWADDR) && !defined (AF_LINK) */
+
/* If we're just trying to get a list of interfaces that we might
be able to configure, we can quit now. */
if (state == DISCOVER_UNCONFIGURED)
@@ -375,14 +467,26 @@ void discover_interfaces (state)
close (sock);
-#ifdef USE_FALLBACK
- strcpy (fallback_interface.name, "fallback");
- fallback_interface.shared_network = &fallback_network;
- fallback_network.name = "fallback-net";
- if_register_fallback (&fallback_interface);
- add_protocol ("fallback", fallback_interface.wfdesc,
- fallback_discard, &fallback_interface);
-#endif
+ maybe_setup_fallback ();
+}
+
+struct interface_info *setup_fallback ()
+{
+ fallback_interface =
+ ((struct interface_info *)
+ dmalloc (sizeof *fallback_interface, "discover_interfaces"));
+ if (!fallback_interface)
+ error ("Insufficient memory to record fallback interface.");
+ memset (fallback_interface, 0, sizeof *fallback_interface);
+ strcpy (fallback_interface -> name, "fallback");
+ fallback_interface -> shared_network =
+ new_shared_network ("parse_statement");
+ if (!fallback_interface -> shared_network)
+ error ("No memory for shared subnet");
+ memset (fallback_interface -> shared_network, 0,
+ sizeof (struct shared_network));
+ fallback_interface -> shared_network -> name = "fallback-net";
+ return fallback_interface;
}
void reinitialize_interfaces ()
@@ -394,24 +498,17 @@ void reinitialize_interfaces ()
if_reinitialize_send (ip);
}
-#ifdef USE_FALLBACK
- if_reinitialize_fallback (&fallback_interface);
-#endif
+ if (fallback_interface)
+ if_reinitialize_send (fallback_interface);
interfaces_invalidated = 1;
}
#ifdef USE_POLL
-/* Wait for packets to come in using poll(). Anyway, when a packet
- comes in, call receive_packet to receive the packet and possibly
- strip hardware addressing information from it, and then call
- do_packet to try to do something with it.
-
- As you can see by comparing this with the code that uses select(),
- below, this is gratuitously complex. Quelle surprise, eh? This is
- SysV we're talking about, after all, and even in the 90's, it
- wouldn't do for SysV to make networking *easy*, would it? Rant,
- rant... */
+/* Wait for packets to come in using poll(). When a packet comes in,
+ call receive_packet to receive the packet and possibly strip hardware
+ addressing information from it, and then call through the
+ bootp_packet_handler hook to try to do something with it. */
void dispatch ()
{
@@ -499,8 +596,8 @@ void dispatch ()
#else
/* Wait for packets to come in using select(). When one does, call
receive_packet to receive the packet and possibly strip hardware
- addressing information from it, and then call do_packet to try to
- do something with it. */
+ addressing information from it, and then call through the
+ bootp_packet_handler hook to try to do something with it. */
void dispatch ()
{
@@ -566,7 +663,7 @@ void dispatch ()
}
#endif /* USE_POLL */
-static void got_one (l)
+void got_one (l)
struct protocol *l;
{
struct sockaddr_in from;
diff --git a/contrib/isc-dhcp/common/lpf.c b/contrib/isc-dhcp/common/lpf.c
new file mode 100644
index 000000000000..7c6ff74d628e
--- /dev/null
+++ b/contrib/isc-dhcp/common/lpf.c
@@ -0,0 +1,287 @@
+/* lpf.c
+
+ Linux packet filter code, contributed by Brian Murrel at Interlinx
+ Support Services in Vancouver, B.C. */
+
+/*
+ * Copyright (c) 1995, 1996, 1998, 1999
+ * The Internet Software Consortium. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The Internet Software Consortium nor the names
+ * of its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This software has been written for the Internet Software Consortium
+ * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
+ * Enterprises. To learn more about the Internet Software Consortium,
+ * see ``http://www.vix.com/isc''. To learn more about Vixie
+ * Enterprises, see ``http://www.vix.com''.
+ */
+
+#ifndef lint
+static char copyright[] =
+"$Id: lpf.c,v 1.1.2.4 1999/02/09 04:51:05 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+#endif /* not lint */
+
+#include "dhcpd.h"
+#if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
+#include <sys/ioctl.h>
+#include <sys/uio.h>
+
+#include <asm/types.h>
+#include <linux/filter.h>
+#include <linux/if_ether.h>
+#include <netinet/in_systm.h>
+#include "includes/netinet/ip.h"
+#include "includes/netinet/udp.h"
+#include "includes/netinet/if_ether.h"
+
+/* Reinitializes the specified interface after an address change. This
+ is not required for packet-filter APIs. */
+
+#ifdef USE_LPF_SEND
+void if_reinitialize_send (info)
+ struct interface_info *info;
+{
+}
+#endif
+
+#ifdef USE_LPF_RECEIVE
+void if_reinitialize_receive (info)
+ struct interface_info *info;
+{
+}
+#endif
+
+/* Called by get_interface_list for each interface that's discovered.
+ Opens a packet filter for each interface and adds it to the select
+ mask. */
+
+int if_register_lpf (info)
+ struct interface_info *info;
+{
+ int sock;
+ char filename[50];
+ int b;
+ struct sockaddr sa;
+
+ /* Make an LPF socket. */
+ if ((sock = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ALL))) < 0) {
+ if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
+ errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
+ errno == EAFNOSUPPORT)
+ error ("socket: %m - make sure %s %s!",
+ "CONFIG_PACKET and CONFIG_FILTER are defined",
+ "in your kernel configuration");
+ error("Open a socket for LPF: %m");
+ }
+
+ /* Bind to the interface name */
+ memset (&sa, 0, sizeof sa);
+ sa.sa_family = AF_PACKET;
+ strncpy (sa.sa_data, (const char *)info -> ifp, sizeof sa.sa_data);
+ if (bind (sock, &sa, sizeof sa)) {
+ if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
+ errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
+ errno == EAFNOSUPPORT)
+ error ("socket: %m - make sure %s %s!",
+ "CONFIG_PACKET and CONFIG_FILTER are defined",
+ "in your kernel configuration");
+ error("Bind socket to interface: %m");
+ }
+
+ return sock;
+}
+#endif /* USE_LPF_SEND || USE_LPF_RECEIVE */
+
+#ifdef USE_LPF_SEND
+void if_register_send (info)
+ struct interface_info *info;
+{
+ /* If we're using the lpf API for sending and receiving,
+ we don't need to register this interface twice. */
+#ifndef USE_LPF_RECEIVE
+ info -> wfdesc = if_register_lpf (info, interface);
+#else
+ info -> wfdesc = info -> rfdesc;
+#endif
+ if (!quiet_interface_discovery)
+ note ("Sending on LPF/%s/%s/%s",
+ info -> name,
+ print_hw_addr (info -> hw_address.htype,
+ info -> hw_address.hlen,
+ info -> hw_address.haddr),
+ (info -> shared_network ?
+ info -> shared_network -> name : "unattached"));
+}
+#endif /* USE_LPF_SEND */
+
+#ifdef USE_LPF_RECEIVE
+/* Defined in bpf.c. We can't extern these in dhcpd.h without pulling
+ in bpf includes... */
+extern struct sock_filter dhcp_bpf_filter [];
+extern int dhcp_bpf_filter_len;
+
+void if_register_receive (info)
+ struct interface_info *info;
+{
+ struct sock_fprog p;
+
+ /* Open a LPF device and hang it on this interface... */
+ info -> rfdesc = if_register_lpf (info);
+
+ /* Set up the bpf filter program structure. This is defined in
+ bpf.c */
+ p.len = dhcp_bpf_filter_len;
+ p.filter = dhcp_bpf_filter;
+
+ /* Patch the server port into the LPF program...
+ XXX changes to filter program may require changes
+ to the insn number(s) used below! XXX */
+ dhcp_bpf_filter [8].k = ntohs (local_port);
+
+ if (setsockopt (info -> rfdesc, SOL_SOCKET, SO_ATTACH_FILTER, &p,
+ sizeof p) < 0) {
+ if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
+ errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
+ errno == EAFNOSUPPORT)
+ error ("socket: %m - make sure %s %s!",
+ "CONFIG_PACKET and CONFIG_FILTER are defined",
+ "in your kernel configuration");
+ error ("Can't install packet filter program: %m");
+ }
+ if (!quiet_interface_discovery)
+ note ("Listening on LPF/%s/%s/%s",
+ info -> name,
+ print_hw_addr (info -> hw_address.htype,
+ info -> hw_address.hlen,
+ info -> hw_address.haddr),
+ (info -> shared_network ?
+ info -> shared_network -> name : "unattached"));
+}
+#endif /* USE_LPF_RECEIVE */
+
+#ifdef USE_LPF_SEND
+ssize_t send_packet (interface, packet, raw, len, from, to, hto)
+ struct interface_info *interface;
+ struct packet *packet;
+ struct dhcp_packet *raw;
+ size_t len;
+ struct in_addr from;
+ struct sockaddr_in *to;
+ struct hardware *hto;
+{
+ int bufp = 0;
+ unsigned char buf [1500];
+ struct sockaddr sa;
+
+ if (!strcmp (interface -> name, "fallback"))
+ return send_fallback (interface, packet, raw,
+ len, from, to, hto);
+
+ /* Assemble the headers... */
+ assemble_hw_header (interface, buf, &bufp, hto);
+ assemble_udp_ip_header (interface, buf, &bufp, from.s_addr,
+ to -> sin_addr.s_addr, to -> sin_port,
+ (unsigned char *)raw, len);
+ memcpy (buf + bufp, raw, len);
+
+ /* For some reason, SOCK_PACKET sockets can't be connected,
+ so we have to do a sentdo every time. */
+ memset (&sa, 0, sizeof sa);
+ sa.sa_family = AF_PACKET;
+ strncpy (sa.sa_data,
+ (const char *)interface -> ifp, sizeof sa.sa_data);
+
+ return sendto (interface -> wfdesc, buf, bufp + len, 0,
+ &sa, sizeof sa);
+}
+#endif /* USE_LPF_SEND */
+
+#ifdef USE_LPF_RECEIVE
+ssize_t receive_packet (interface, buf, len, from, hfrom)
+ struct interface_info *interface;
+ unsigned char *buf;
+ size_t len;
+ struct sockaddr_in *from;
+ struct hardware *hfrom;
+{
+ int nread;
+ int length = 0;
+ int offset = 0;
+ unsigned char ibuf [1500];
+ int bufix = 0;
+
+ length = read (interface -> rfdesc, ibuf, sizeof ibuf);
+ if (length <= 0)
+ return length;
+
+ bufix = 0;
+ /* Decode the physical header... */
+ offset = decode_hw_header (interface, ibuf, bufix, hfrom);
+
+ /* If a physical layer checksum failed (dunno of any
+ physical layer that supports this, but WTH), skip this
+ packet. */
+ if (offset < 0) {
+ return 0;
+ }
+
+ bufix += offset;
+ length -= offset;
+
+ /* Decode the IP and UDP headers... */
+ offset = decode_udp_ip_header (interface, ibuf, bufix,
+ from, (unsigned char *)0, length);
+
+ /* If the IP or UDP checksum was bad, skip the packet... */
+ if (offset < 0)
+ return 0;
+
+ bufix += offset;
+ length -= offset;
+
+ /* Copy out the data in the packet... */
+ memcpy (buf, &ibuf [bufix], length);
+ return length;
+}
+
+int can_unicast_without_arp ()
+{
+ return 1;
+}
+
+void maybe_setup_fallback ()
+{
+ struct interface_info *fbi;
+ fbi = setup_fallback ();
+ if (fbi) {
+ if_register_fallback (fbi);
+ add_protocol ("fallback", fallback_interface -> wfdesc,
+ fallback_discard, fallback_interface);
+ }
+}
+#endif
diff --git a/contrib/isc-dhcp/common/memory.c b/contrib/isc-dhcp/common/memory.c
index 59cbe5dafc01..871fe0772d4a 100644
--- a/contrib/isc-dhcp/common/memory.c
+++ b/contrib/isc-dhcp/common/memory.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: memory.c,v 1.35.2.2 1998/06/25 21:11:30 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: memory.c,v 1.35.2.3 1998/11/24 22:32:43 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -357,36 +357,59 @@ struct subnet *find_grouped_subnet (share, addr)
return (struct subnet *)0;
}
+int subnet_inner_than (subnet, scan, warnp)
+ struct subnet *subnet, *scan;
+ int warnp;
+{
+ if (addr_eq (subnet_number (subnet -> net, scan -> netmask),
+ scan -> net) ||
+ addr_eq (subnet_number (scan -> net, subnet -> netmask),
+ subnet -> net)) {
+ char n1buf [16];
+ int i, j;
+ for (i = 0; i < 32; i++)
+ if (subnet -> netmask.iabuf [3 - (i >> 3)]
+ & (1 << (i & 7)))
+ break;
+ for (j = 0; j < 32; j++)
+ if (scan -> netmask.iabuf [3 - (j >> 3)] &
+ (1 << (j & 7)))
+ break;
+ strcpy (n1buf, piaddr (subnet -> net));
+ if (warnp)
+ warn ("%ssubnet %s/%d conflicts with subnet %s/%d",
+ "Warning: ", n1buf, 32 - i,
+ piaddr (scan -> net), 32 - j);
+ if (i < j)
+ return 1;
+ }
+ return 0;
+}
+
/* Enter a new subnet into the subnet list. */
void enter_subnet (subnet)
struct subnet *subnet;
{
- struct subnet *scan;
+ struct subnet *scan, *prev = (struct subnet *)0;
/* Check for duplicates... */
for (scan = subnets; scan; scan = scan -> next_subnet) {
- if (addr_eq (subnet_number (subnet -> net, scan -> netmask),
- scan -> net) ||
- addr_eq (subnet_number (scan -> net, subnet -> netmask),
- subnet -> net)) {
- char n1buf [16];
- int i, j;
- for (i = 0; i < 32; i++)
- if (subnet -> netmask.iabuf [3 - (i >> 3)]
- & (1 << (i & 7)))
- break;
- for (j = 0; j < 32; j++)
- if (scan -> netmask.iabuf [3 - (j >> 3)]
- & (1 << (j & 7)))
- break;
- strcpy (n1buf, piaddr (subnet -> net));
- error ("subnet %s/%d conflicts with subnet %s/%d",
- n1buf, i, piaddr (scan -> net), j);
+ /* When we find a conflict, make sure that the
+ subnet with the narrowest subnet mask comes
+ first. */
+ if (subnet_inner_than (subnet, scan, 1)) {
+ if (prev) {
+ prev -> next_subnet = subnet;
+ } else
+ subnets = subnet;
+ subnet -> next_subnet = scan;
+ return;
}
+ prev = scan;
}
- /* XXX Sort the nets into a balanced tree to make searching quicker. */
+ /* XXX use the BSD radix tree code instead of a linked list. */
subnet -> next_subnet = subnets;
subnets = subnet;
}
@@ -626,8 +649,10 @@ void release_lease (lease)
struct lease lt;
lt = *lease;
- lt.ends = cur_time;
- supersede_lease (lease, &lt, 1);
+ if (lt.ends > cur_time) {
+ lt.ends = cur_time;
+ supersede_lease (lease, &lt, 1);
+ }
}
/* Abandon the specified lease (set its timeout to infinity and its
@@ -896,16 +921,21 @@ void dump_subnets ()
struct shared_network *s;
struct subnet *n;
+ note ("Subnets:");
+ for (n = subnets; n; n = n -> next_subnet) {
+ debug (" Subnet %s", piaddr (n -> net));
+ debug (" netmask %s",
+ piaddr (n -> netmask));
+ }
+ note ("Shared networks:");
for (s = shared_networks; s; s = s -> next) {
- for (n = subnets; n; n = n -> next_sibling) {
- debug ("Subnet %s", piaddr (n -> net));
- debug (" netmask %s",
- piaddr (n -> netmask));
- }
+ note (" %s", s -> name);
for (l = s -> leases; l; l = l -> next) {
print_lease (l);
}
- debug ("Last Lease:");
- print_lease (s -> last_lease);
+ if (s -> last_lease) {
+ debug (" Last Lease:");
+ print_lease (s -> last_lease);
+ }
}
}
diff --git a/contrib/isc-dhcp/common/nit.c b/contrib/isc-dhcp/common/nit.c
index 0633f1d393b0..1801bb9f3579 100644
--- a/contrib/isc-dhcp/common/nit.c
+++ b/contrib/isc-dhcp/common/nit.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: nit.c,v 1.15 1997/10/20 21:47:13 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: nit.c,v 1.15.2.1 1998/12/20 18:27:44 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -264,6 +264,10 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
int hw_end;
struct sockaddr_in foo;
+ if (!strcmp (interface -> name, "fallback"))
+ return send_fallback (interface, packet, raw,
+ len, from, to, hto);
+
/* Start with the sockaddr struct... */
junk = (struct sockaddr *)&buf [0];
bufp = ((unsigned char *)&junk -> sa_data [0]) - &buf [0];
@@ -344,4 +348,20 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
memcpy (buf, &ibuf [bufix], length);
return length;
}
+
+int can_unicast_without_arp ()
+{
+ return 1;
+}
+
+void maybe_setup_fallback ()
+{
+ struct interface_info *fbi;
+ fbi = setup_fallback ();
+ if (fbi) {
+ if_register_fallback (fbi);
+ add_protocol ("fallback", fallback_interface -> wfdesc,
+ fallback_discard, fallback_interface);
+ }
+}
#endif
diff --git a/contrib/isc-dhcp/common/parse.c b/contrib/isc-dhcp/common/parse.c
index 97bfa877b17e..d750ec53434d 100644
--- a/contrib/isc-dhcp/common/parse.c
+++ b/contrib/isc-dhcp/common/parse.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: parse.c,v 1.2.2.1 1998/06/25 21:11:31 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: parse.c,v 1.2.2.3 1998/12/22 22:43:22 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -222,6 +222,9 @@ void parse_hardware_param (cfile, hardware)
case TOKEN_RING:
hardware -> htype = HTYPE_IEEE802;
break;
+ case FDDI:
+ hardware -> htype = HTYPE_FDDI;
+ break;
default:
parse_warn ("expecting a network hardware type");
skip_to_semi (cfile);
@@ -247,6 +250,9 @@ void parse_hardware_param (cfile, hardware)
hardware -> hlen = hlen;
memcpy ((unsigned char *)&hardware -> haddr [0],
t, hardware -> hlen);
+ if (hlen < sizeof hardware -> haddr)
+ memset (&hardware -> haddr [hlen], 0,
+ (sizeof hardware -> haddr) - hlen);
free (t);
}
diff --git a/contrib/isc-dhcp/common/print.c b/contrib/isc-dhcp/common/print.c
index ed51b15841b1..4a2b464862d6 100644
--- a/contrib/isc-dhcp/common/print.c
+++ b/contrib/isc-dhcp/common/print.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: print.c,v 1.16.2.1 1998/06/25 21:11:31 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: print.c,v 1.16.2.2 1998/11/24 22:39:35 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -76,26 +76,26 @@ void print_lease (lease)
struct tm *t;
char tbuf [32];
- debug (" Lease %s",
+ debug (" Lease %s",
piaddr (lease -> ip_addr));
t = gmtime (&lease -> starts);
strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t);
- debug (" start %s", tbuf);
+ debug (" start %s", tbuf);
t = gmtime (&lease -> ends);
strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t);
- debug (" end %s", tbuf);
+ debug (" end %s", tbuf);
t = gmtime (&lease -> timestamp);
strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t);
- debug (" stamp %s", tbuf);
+ debug (" stamp %s", tbuf);
- debug (" hardware addr = %s",
+ debug (" hardware addr = %s",
print_hw_addr (lease -> hardware_addr.htype,
lease -> hardware_addr.hlen,
lease -> hardware_addr.haddr));
- debug (" host %s ",
+ debug (" host %s ",
lease -> host ? lease -> host -> name : "<none>");
}
diff --git a/contrib/isc-dhcp/common/socket.c b/contrib/isc-dhcp/common/socket.c
index b317ff2ba255..b2ae5b4cae97 100644
--- a/contrib/isc-dhcp/common/socket.c
+++ b/contrib/isc-dhcp/common/socket.c
@@ -3,8 +3,8 @@
BSD socket interface code... */
/*
- * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium.
- * All rights reserved.
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999
+ * The Internet Software Consortium. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -50,7 +50,7 @@
#ifndef lint
static char copyright[] =
-"$Id: socket.c,v 1.26.2.2 1998/06/25 21:11:32 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: socket.c,v 1.26.2.6 1999/02/03 19:46:04 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -102,7 +102,7 @@ int if_register_socket (info)
int sock;
int flag;
-#ifndef SO_BINDTODEVICE
+#if !defined (SO_BINDTODEVICE) && !defined (USE_FALLBACK)
/* Make sure only one interface is registered. */
if (once)
error ("The standard socket API can only support %s",
@@ -136,9 +136,10 @@ int if_register_socket (info)
if (bind (sock, (struct sockaddr *)&name, sizeof name) < 0)
error ("Can't bind to dhcp address: %m");
-#ifdef SO_BINDTODEVICE
+#if defined (SO_BINDTODEVICE)
/* Bind this socket to this interface. */
- if (setsockopt (sock, SOL_SOCKET, SO_BINDTODEVICE,
+ if (info -> ifp &&
+ setsockopt (sock, SOL_SOCKET, SO_BINDTODEVICE,
(char *)(info -> ifp), sizeof *(info -> ifp)) < 0) {
error("setting SO_BINDTODEVICE");
}
@@ -236,7 +237,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
}
#endif /* USE_SOCKET_RECEIVE */
-#ifdef USE_SOCKET_FALLBACK
+#ifdef USE_SOCKET_SEND
/* This just reads in a packet and silently discards it. */
void fallback_discard (protocol)
@@ -253,4 +254,27 @@ void fallback_discard (protocol)
if (status < 0)
warn ("fallback_discard: %m");
}
-#endif /* USE_SOCKET_RECEIVE */
+#endif /* USE_SOCKET_SEND */
+
+#if defined (USE_SOCKET_SEND) && !defined (USE_SOCKET_FALLBACK)
+int can_unicast_without_arp ()
+{
+ return 0;
+}
+
+/* If we have SO_BINDTODEVICE, set up a fallback interface; otherwise,
+ do not. */
+
+void maybe_setup_fallback ()
+{
+#if defined (SO_BINDTODEVICE)
+ struct interface_info *fbi;
+ fbi = setup_fallback ();
+ if (fbi) {
+ fbi -> wfdesc = if_register_socket (fbi);
+ add_protocol ("fallback",
+ fbi -> wfdesc, fallback_discard, fbi);
+ }
+#endif
+}
+#endif /* USE_SOCKET_SEND && !USE_SOCKET_FALLBACK */
diff --git a/contrib/isc-dhcp/common/tables.c b/contrib/isc-dhcp/common/tables.c
index bdbba1b78d14..abbff6f4cbe7 100644
--- a/contrib/isc-dhcp/common/tables.c
+++ b/contrib/isc-dhcp/common/tables.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: tables.c,v 1.13.2.1 1998/06/25 21:11:32 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: tables.c,v 1.13.2.3 1998/12/22 22:45:44 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -78,7 +78,7 @@ struct option dhcp_options [256] = {
{ "lpr-servers", "IA", &dhcp_universe, 9 },
{ "impress-servers", "IA", &dhcp_universe, 10 },
{ "resource-location-servers", "IA", &dhcp_universe, 11 },
- { "host-name", "t", &dhcp_universe, 12 },
+ { "host-name", "X", &dhcp_universe, 12 },
{ "boot-size", "S", &dhcp_universe, 13 },
{ "merit-dump", "t", &dhcp_universe, 14 },
{ "domain-name", "t", &dhcp_universe, 15 },
@@ -418,7 +418,7 @@ char *hardware_types [] = {
"unknown-5",
"token-ring",
"unknown-7",
- "unknown-8",
+ "fddi",
"unknown-9",
"unknown-10",
"unknown-11",
diff --git a/contrib/isc-dhcp/common/upf.c b/contrib/isc-dhcp/common/upf.c
index 498b6e6cde1b..7da9aff62ee8 100644
--- a/contrib/isc-dhcp/common/upf.c
+++ b/contrib/isc-dhcp/common/upf.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: upf.c,v 1.3 1997/10/20 21:47:15 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: upf.c,v 1.3.2.1 1998/12/20 18:29:48 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -232,6 +232,10 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
unsigned char buf [256];
struct iovec iov [2];
+ if (!strcmp (interface -> name, "fallback"))
+ return send_fallback (interface, packet, raw,
+ len, from, to, hto);
+
/* Assemble the headers... */
assemble_hw_header (interface, buf, &bufp, hto);
assemble_udp_ip_header (interface, buf, &bufp, from.s_addr,
@@ -295,4 +299,20 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
memcpy (buf, &ibuf [bufix], length);
return length;
}
+
+int can_unicast_without_arp ()
+{
+ return 1;
+}
+
+void maybe_setup_fallback ()
+{
+ struct interface_info *fbi;
+ fbi = setup_fallback ();
+ if (fbi) {
+ if_register_fallback (fbi);
+ add_protocol ("fallback", fallback_interface -> wfdesc,
+ fallback_discard, fallback_interface);
+ }
+}
#endif
diff --git a/contrib/isc-dhcp/includes/cf/freebsd.h b/contrib/isc-dhcp/includes/cf/freebsd.h
index 965d33236f23..032d52c2b002 100644
--- a/contrib/isc-dhcp/includes/cf/freebsd.h
+++ b/contrib/isc-dhcp/includes/cf/freebsd.h
@@ -3,7 +3,8 @@
System dependencies for FreeBSD... */
/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
+ * Copyright (c) 1996, 1998 The Internet Software Consortium.
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -53,7 +54,10 @@ extern int h_errno;
#include <net/if.h>
#include <net/if_dl.h>
-#define INADDR_LOOPBACK ((u_int32_t)0x7f000001)
+#include <net/if_arp.h>
+#if !defined (INADDR_LOOPBACK)
+# define INADDR_LOOPBACK ((u_int32_t)0x7f000001)
+#endif
/* Varargs stuff... */
#include <stdarg.h>
diff --git a/contrib/isc-dhcp/includes/dhcp.h b/contrib/isc-dhcp/includes/dhcp.h
index 181277579527..b96ec3d096df 100644
--- a/contrib/isc-dhcp/includes/dhcp.h
+++ b/contrib/isc-dhcp/includes/dhcp.h
@@ -84,6 +84,7 @@ struct dhcp_packet {
/* Possible values for hardware type (htype) field... */
#define HTYPE_ETHER 1 /* Ethernet 10Mbps */
#define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring... */
+#define HTYPE_FDDI 8 /* FDDI... */
/* Magic cookie validating dhcp options field (and bootp vendor
extensions field). */
diff --git a/contrib/isc-dhcp/includes/dhcpd.h b/contrib/isc-dhcp/includes/dhcpd.h
index cf82132bc74b..a1059e94eb59 100644
--- a/contrib/isc-dhcp/includes/dhcpd.h
+++ b/contrib/isc-dhcp/includes/dhcpd.h
@@ -3,8 +3,8 @@
Definitions for dhcpd... */
/*
- * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium.
- * All rights reserved.
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999
+ * The Internet Software Consortium. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -155,7 +155,10 @@ struct lease_state {
struct tree_cache *options [256];
u_int32_t expiry, renewal, rebind;
- char *filename, *server_name;
+ char filename [DHCP_FILE_LEN];
+ char *server_name;
+
+ struct iaddr from;
u_int32_t xid;
u_int16_t secs;
@@ -204,6 +207,8 @@ struct group {
int one_lease_per_client;
int get_lease_hostnames;
int use_host_decl_names;
+ int use_lease_addr_for_default_route;
+ int authoritative;
struct tree_cache *options [256];
};
@@ -479,10 +484,6 @@ extern u_int16_t remote_port;
extern int log_priority;
extern int log_perror;
-#ifdef USE_FALLBACK
-extern struct interface_info fallback_interface;
-#endif
-
extern char *path_dhcpd_conf;
extern char *path_dhcpd_db;
extern char *path_dhcpd_pid;
@@ -577,6 +578,7 @@ extern struct subnet *find_grouped_subnet PROTO ((struct shared_network *,
struct iaddr));
extern struct subnet *find_subnet PROTO ((struct iaddr));
void enter_shared_network PROTO ((struct shared_network *));
+int subnet_inner_than PROTO ((struct subnet *, struct subnet *, int));
void enter_subnet PROTO ((struct subnet *));
void enter_lease PROTO ((struct lease *));
int supersede_lease PROTO ((struct lease *, struct lease *, int));
@@ -650,7 +652,6 @@ ssize_t send_fallback PROTO ((struct interface_info *,
struct packet *, struct dhcp_packet *, size_t,
struct in_addr,
struct sockaddr_in *, struct hardware *));
-void fallback_discard PROTO ((struct protocol *));
#endif
#ifdef USE_SOCKET_SEND
@@ -661,6 +662,9 @@ ssize_t send_packet PROTO ((struct interface_info *,
struct in_addr,
struct sockaddr_in *, struct hardware *));
#endif
+#if defined (USE_SOCKET_FALLBACK)
+void fallback_discard PROTO ((struct protocol *));
+#endif
#ifdef USE_SOCKET_RECEIVE
void if_reinitialize_receive PROTO ((struct interface_info *));
void if_register_receive PROTO ((struct interface_info *));
@@ -669,7 +673,8 @@ ssize_t receive_packet PROTO ((struct interface_info *,
struct sockaddr_in *, struct hardware *));
#endif
#if defined (USE_SOCKET_SEND) && !defined (USE_SOCKET_FALLBACK)
-void if_enable PROTO ((struct interface_info *));
+int can_unicast_without_arp PROTO ((void));
+void maybe_setup_fallback PROTO ((void));
#endif
/* bpf.c */
@@ -692,7 +697,32 @@ ssize_t receive_packet PROTO ((struct interface_info *,
struct sockaddr_in *, struct hardware *));
#endif
#if defined (USE_BPF_SEND)
-void if_enable PROTO ((struct interface_info *));
+int can_unicast_without_arp PROTO ((void));
+void maybe_setup_fallback PROTO ((void));
+#endif
+
+/* lpf.c */
+#if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
+int if_register_lpf PROTO ( (struct interface_info *));
+#endif
+#ifdef USE_LPF_SEND
+void if_reinitialize_send PROTO ((struct interface_info *));
+void if_register_send PROTO ((struct interface_info *));
+ssize_t send_packet PROTO ((struct interface_info *,
+ struct packet *, struct dhcp_packet *, size_t,
+ struct in_addr,
+ struct sockaddr_in *, struct hardware *));
+#endif
+#ifdef USE_LPF_RECEIVE
+void if_reinitialize_receive PROTO ((struct interface_info *));
+void if_register_receive PROTO ((struct interface_info *));
+ssize_t receive_packet PROTO ((struct interface_info *,
+ unsigned char *, size_t,
+ struct sockaddr_in *, struct hardware *));
+#endif
+#if defined (USE_LPF_SEND)
+int can_unicast_without_arp PROTO ((void));
+void maybe_setup_fallback PROTO ((void));
#endif
/* nit.c */
@@ -715,8 +745,29 @@ ssize_t receive_packet PROTO ((struct interface_info *,
unsigned char *, size_t,
struct sockaddr_in *, struct hardware *));
#endif
-#if defined (USE_BPF_SEND)
-void if_enable PROTO ((struct interface_info *));
+#if defined (USE_NIT_SEND)
+int can_unicast_without_arp PROTO ((void));
+void maybe_setup_fallback PROTO ((void));
+#endif
+
+#ifdef USE_DLPI_SEND
+void if_reinitialize_send PROTO ((struct interface_info *));
+void if_register_send PROTO ((struct interface_info *));
+ssize_t send_packet PROTO ((struct interface_info *,
+ struct packet *, struct dhcp_packet *, size_t,
+ struct in_addr,
+ struct sockaddr_in *, struct hardware *));
+#endif
+#ifdef USE_DLPI_RECEIVE
+void if_reinitialize_receive PROTO ((struct interface_info *));
+void if_register_receive PROTO ((struct interface_info *));
+ssize_t receive_packet PROTO ((struct interface_info *,
+ unsigned char *, size_t,
+ struct sockaddr_in *, struct hardware *));
+#endif
+#if defined (USE_DLPI_SEND)
+int can_unicast_without_arp PROTO ((void));
+void maybe_setup_fallback PROTO ((void));
#endif
/* raw.c */
@@ -727,10 +778,13 @@ ssize_t send_packet PROTO ((struct interface_info *,
struct packet *, struct dhcp_packet *, size_t,
struct in_addr,
struct sockaddr_in *, struct hardware *));
+int can_unicast_without_arp PROTO ((void));
+void maybe_setup_fallback PROTO ((void));
#endif
/* dispatch.c */
-extern struct interface_info *interfaces, *dummy_interfaces;
+extern struct interface_info *interfaces,
+ *dummy_interfaces, *fallback_interface;
extern struct protocol *protocols;
extern int quiet_interface_discovery;
extern void (*bootp_packet_handler) PROTO ((struct interface_info *,
@@ -739,13 +793,12 @@ extern void (*bootp_packet_handler) PROTO ((struct interface_info *,
struct iaddr, struct hardware *));
extern struct timeout *timeouts;
void discover_interfaces PROTO ((int));
+struct interface_info *setup_fallback PROTO ((void));
void reinitialize_interfaces PROTO ((void));
void dispatch PROTO ((void));
int locate_network PROTO ((struct packet *));
+void got_one PROTO ((struct protocol *));
void add_timeout PROTO ((TIME, void (*) PROTO ((void *)), void *));
-#if 0
-void add_fast_timeout PROTO ((UTIME, void (*) PROTO ((void *)), void *));
-#endif
void cancel_timeout PROTO ((void (*) PROTO ((void *)), void *));
void add_protocol PROTO ((char *, int,
void (*) PROTO ((struct protocol *)), void *));
@@ -820,7 +873,7 @@ void make_release PROTO ((struct interface_info *, struct client_lease *));
void free_client_lease PROTO ((struct client_lease *));
void rewrite_client_leases PROTO ((void));
void write_client_lease PROTO ((struct interface_info *,
- struct client_lease *));
+ struct client_lease *, int));
char *dhcp_option_ev_name PROTO ((struct option *));
void script_init PROTO ((struct interface_info *, char *,
diff --git a/contrib/isc-dhcp/includes/dhctoken.h b/contrib/isc-dhcp/includes/dhctoken.h
index 88acd1622983..73f6879e3ddf 100644
--- a/contrib/isc-dhcp/includes/dhctoken.h
+++ b/contrib/isc-dhcp/includes/dhctoken.h
@@ -3,8 +3,8 @@
Tokens for config file lexer and parser. */
/*
- * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
- * All rights reserved.
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999
+ * The Internet Software Consortium. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -124,6 +124,10 @@
#define HOSTNAME 328
#define CLIENT_HOSTNAME 329
#define REJECT 330
+#define FDDI 331
+#define USE_LEASE_ADDR_FOR_DEFAULT_ROUTE 332
+#define AUTHORITATIVE 333
+#define TOKEN_NOT 334
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
(x) != STRING && \
diff --git a/contrib/isc-dhcp/includes/osdep.h b/contrib/isc-dhcp/includes/osdep.h
index 4ea4cd863d75..ca40e8a75bba 100644
--- a/contrib/isc-dhcp/includes/osdep.h
+++ b/contrib/isc-dhcp/includes/osdep.h
@@ -51,6 +51,9 @@
!defined (USE_BPF) && \
!defined (USE_BPF_SEND) && \
!defined (USE_BPF_RECEIVE) && \
+ !defined (USE_LPF) && \
+ !defined (USE_LPF_SEND) && \
+ !defined (USE_LPF_RECEIVE) && \
!defined (USE_NIT) && \
!defined (USE_NIT_SEND) && \
!defined (USE_NIT_RECEIVE) && \
@@ -141,6 +144,11 @@
# define USE_BPF_RECEIVE
#endif
+#ifdef USE_LPF
+# define USE_LPF_SEND
+# define USE_LPF_RECEIVE
+#endif
+
#ifdef USE_NIT
# define USE_NIT_SEND
# define USE_NIT_RECEIVE
@@ -165,7 +173,7 @@
fallback. */
#if defined (USE_BPF_SEND) || defined (USE_NIT_SEND) || \
- defined (USE_DLPI_SEND) || defined (USE_UPF_SEND)
+ defined (USE_DLPI_SEND) || defined (USE_UPF_SEND) || defined (USE_LPF_SEND)
# define USE_SOCKET_FALLBACK
# define USE_FALLBACK
#endif
@@ -178,7 +186,7 @@
#if defined (USE_RAW_SEND) || defined (USE_BPF_SEND) || \
defined (USE_NIT_SEND) || defined (USE_UPF_SEND) || \
- defined (USE_DLPI_SEND)
+ defined (USE_DLPI_SEND) || defined (USE_LPF_SEND)
# define PACKET_ASSEMBLY
#endif
@@ -190,7 +198,7 @@
#if defined (USE_RAW_RECEIVE) || defined (USE_BPF_SEND) || \
defined (USE_NIT_RECEIVE) || defined (USE_UPF_RECEIVE) || \
- defined (USE_DLPI_RECEIVE)
+ defined (USE_DLPI_RECEIVE) || defined (USE_LPF_RECEIVE)
# define PACKET_DECODING
#endif