contrib/dhcp-3.0/LICENSE | 20 - contrib/dhcp-3.0/README | 656 --- contrib/dhcp-3.0/README.DELETED | 41 - contrib/dhcp-3.0/README.DRAGONFLY | 5 - contrib/dhcp-3.0/RELNOTES | 1441 ------ contrib/dhcp-3.0/client/clparse.c | 1170 ----- contrib/dhcp-3.0/client/dhclient-script.8 | 221 - contrib/dhcp-3.0/client/dhclient.8 | 319 -- contrib/dhcp-3.0/client/dhclient.c | 3162 ------------ contrib/dhcp-3.0/client/dhclient.conf | 36 - contrib/dhcp-3.0/client/dhclient.conf.5 | 623 --- contrib/dhcp-3.0/client/dhclient.leases.5 | 53 - contrib/dhcp-3.0/client/scripts/freebsd | 242 - contrib/dhcp-3.0/common/alloc.c | 1317 ----- contrib/dhcp-3.0/common/bpf.c | 547 --- contrib/dhcp-3.0/common/comapi.c | 949 ---- contrib/dhcp-3.0/common/conflex.c | 1078 ---- contrib/dhcp-3.0/common/ctrace.c | 295 -- contrib/dhcp-3.0/common/dhcp-eval.5 | 478 -- contrib/dhcp-3.0/common/dhcp-options.5 | 1515 ------ contrib/dhcp-3.0/common/discover.c | 1138 ----- contrib/dhcp-3.0/common/dispatch.c | 219 - contrib/dhcp-3.0/common/dlpi.c | 1336 ----- contrib/dhcp-3.0/common/dns.c | 953 ---- contrib/dhcp-3.0/common/ethernet.c | 98 - contrib/dhcp-3.0/common/execute.c | 1054 ---- contrib/dhcp-3.0/common/fddi.c | 97 - contrib/dhcp-3.0/common/icmp.c | 317 -- contrib/dhcp-3.0/common/inet.c | 233 - contrib/dhcp-3.0/common/lpf.c | 410 -- contrib/dhcp-3.0/common/memory.c | 161 - contrib/dhcp-3.0/common/nit.c | 420 -- contrib/dhcp-3.0/common/options.c | 2332 --------- contrib/dhcp-3.0/common/packet.c | 337 -- contrib/dhcp-3.0/common/parse.c | 4853 ------------------ contrib/dhcp-3.0/common/print.c | 1405 ------ contrib/dhcp-3.0/common/raw.c | 144 - contrib/dhcp-3.0/common/resolv.c | 203 - contrib/dhcp-3.0/common/socket.c | 371 -- contrib/dhcp-3.0/common/tables.c | 1240 ----- contrib/dhcp-3.0/common/tr.c | 335 -- contrib/dhcp-3.0/common/tree.c | 4100 ---------------- contrib/dhcp-3.0/common/upf.c | 371 -- contrib/dhcp-3.0/dhcpctl/callback.c | 175 - contrib/dhcp-3.0/dhcpctl/dhcpctl.3 | 488 -- contrib/dhcp-3.0/dhcpctl/dhcpctl.c | 595 --- contrib/dhcp-3.0/dhcpctl/dhcpctl.h | 125 - contrib/dhcp-3.0/dhcpctl/omshell.1 | 334 -- contrib/dhcp-3.0/dhcpctl/omshell.c | 725 --- contrib/dhcp-3.0/dhcpctl/remote.c | 367 -- contrib/dhcp-3.0/dst/base64.c | 325 -- contrib/dhcp-3.0/dst/dst_api.c | 1081 ----- contrib/dhcp-3.0/dst/dst_internal.h | 160 - contrib/dhcp-3.0/dst/dst_support.c | 463 -- contrib/dhcp-3.0/dst/hmac_link.c | 494 -- contrib/dhcp-3.0/dst/md5.h | 101 - contrib/dhcp-3.0/dst/md5_dgst.c | 373 -- contrib/dhcp-3.0/dst/md5_locl.h | 189 - contrib/dhcp-3.0/dst/prandom.c | 862 ---- contrib/dhcp-3.0/includes/arpa/nameser.h | 467 -- contrib/dhcp-3.0/includes/arpa/nameser_compat.h | 183 - contrib/dhcp-3.0/includes/cdefs.h | 57 - contrib/dhcp-3.0/includes/cf/freebsd.h | 142 - contrib/dhcp-3.0/includes/ctrace.h | 77 - contrib/dhcp-3.0/includes/dhcp.h | 186 - contrib/dhcp-3.0/includes/dhcpd.h | 2624 ---------- contrib/dhcp-3.0/includes/dhctoken.h | 317 -- contrib/dhcp-3.0/includes/failover.h | 313 -- contrib/dhcp-3.0/includes/inet.h | 45 - contrib/dhcp-3.0/includes/isc-dhcp/boolean.h | 38 - contrib/dhcp-3.0/includes/isc-dhcp/dst.h | 142 - contrib/dhcp-3.0/includes/isc-dhcp/int.h | 42 - contrib/dhcp-3.0/includes/isc-dhcp/lang.h | 35 - contrib/dhcp-3.0/includes/isc-dhcp/list.h | 122 - contrib/dhcp-3.0/includes/isc-dhcp/result.h | 119 - contrib/dhcp-3.0/includes/isc-dhcp/types.h | 46 - contrib/dhcp-3.0/includes/minires/minires.h | 230 - contrib/dhcp-3.0/includes/minires/res_update.h | 57 - contrib/dhcp-3.0/includes/minires/resolv.h | 320 -- contrib/dhcp-3.0/includes/netinet/if_ether.h | 61 - contrib/dhcp-3.0/includes/netinet/ip.h | 163 - contrib/dhcp-3.0/includes/netinet/ip_icmp.h | 182 - contrib/dhcp-3.0/includes/netinet/udp.h | 70 - contrib/dhcp-3.0/includes/omapip/alloc.h | 111 - contrib/dhcp-3.0/includes/omapip/buffer.h | 83 - contrib/dhcp-3.0/includes/omapip/convert.h | 52 - contrib/dhcp-3.0/includes/omapip/hash.h | 150 - contrib/dhcp-3.0/includes/omapip/omapip.h | 611 --- contrib/dhcp-3.0/includes/omapip/omapip_p.h | 293 -- contrib/dhcp-3.0/includes/omapip/trace.h | 115 - contrib/dhcp-3.0/includes/osdep.h | 319 -- contrib/dhcp-3.0/includes/site.h | 179 - contrib/dhcp-3.0/includes/statement.h | 104 - contrib/dhcp-3.0/includes/tree.h | 337 -- contrib/dhcp-3.0/includes/version.h | 3 - contrib/dhcp-3.0/minires/ns_date.c | 135 - contrib/dhcp-3.0/minires/ns_name.c | 651 --- contrib/dhcp-3.0/minires/ns_parse.c | 214 - contrib/dhcp-3.0/minires/ns_samedomain.c | 216 - contrib/dhcp-3.0/minires/ns_sign.c | 362 -- contrib/dhcp-3.0/minires/ns_verify.c | 482 -- contrib/dhcp-3.0/minires/res_comp.c | 242 - contrib/dhcp-3.0/minires/res_findzonecut.c | 614 --- contrib/dhcp-3.0/minires/res_init.c | 492 -- contrib/dhcp-3.0/minires/res_mkquery.c | 199 - contrib/dhcp-3.0/minires/res_mkupdate.c | 1142 ----- contrib/dhcp-3.0/minires/res_query.c | 419 -- contrib/dhcp-3.0/minires/res_send.c | 877 ---- contrib/dhcp-3.0/minires/res_sendsigned.c | 139 - contrib/dhcp-3.0/minires/res_update.c | 225 - contrib/dhcp-3.0/omapip/alloc.c | 1147 ----- contrib/dhcp-3.0/omapip/array.c | 163 - contrib/dhcp-3.0/omapip/auth.c | 264 - contrib/dhcp-3.0/omapip/buffer.c | 709 --- contrib/dhcp-3.0/omapip/connection.c | 1017 ---- contrib/dhcp-3.0/omapip/convert.c | 188 - contrib/dhcp-3.0/omapip/dispatch.c | 609 --- contrib/dhcp-3.0/omapip/errwarn.c | 366 -- contrib/dhcp-3.0/omapip/generic.c | 304 -- contrib/dhcp-3.0/omapip/handle.c | 295 -- contrib/dhcp-3.0/omapip/hash.c | 416 -- contrib/dhcp-3.0/omapip/inet_addr.c | 150 - contrib/dhcp-3.0/omapip/iscprint.c | 539 -- contrib/dhcp-3.0/omapip/listener.c | 468 -- contrib/dhcp-3.0/omapip/message.c | 770 --- contrib/dhcp-3.0/omapip/mrtrace.c | 479 -- contrib/dhcp-3.0/omapip/omapi.3 | 248 - contrib/dhcp-3.0/omapip/protocol.c | 1310 ----- contrib/dhcp-3.0/omapip/result.c | 119 - contrib/dhcp-3.0/omapip/support.c | 863 ---- contrib/dhcp-3.0/omapip/toisc.c | 315 -- contrib/dhcp-3.0/omapip/trace.c | 709 --- contrib/dhcp-3.0/relay/dhcrelay.8 | 245 - contrib/dhcp-3.0/relay/dhcrelay.c | 862 ---- contrib/dhcp-3.0/server/bootp.c | 411 -- contrib/dhcp-3.0/server/class.c | 283 -- contrib/dhcp-3.0/server/confpars.c | 3322 ------------- contrib/dhcp-3.0/server/db.c | 887 ---- contrib/dhcp-3.0/server/ddns.c | 747 --- contrib/dhcp-3.0/server/dhcp.c | 3832 --------------- contrib/dhcp-3.0/server/dhcpd.8 | 734 --- contrib/dhcp-3.0/server/dhcpd.c | 1165 ----- contrib/dhcp-3.0/server/dhcpd.conf | 101 - contrib/dhcp-3.0/server/dhcpd.conf.5 | 2387 --------- contrib/dhcp-3.0/server/dhcpd.leases.5 | 256 - contrib/dhcp-3.0/server/failover.c | 5401 --------------------- contrib/dhcp-3.0/server/mdb.c | 2325 --------- contrib/dhcp-3.0/server/omapi.c | 2236 --------- contrib/dhcp-3.0/server/salloc.c | 258 - contrib/dhcp-3.0/server/stables.c | 846 ---- etc/ftpusers | 1 + etc/group | 1 + etc/mail/aliases | 1 + etc/master.passwd | 1 + include/paths.h | 1 + sbin/dhclient/Makefile | 52 +- sbin/dhclient/Makefile.common | 7 - sbin/dhclient/Makefile.inc | 38 - sbin/dhclient/bpf.c | 406 ++ sbin/dhclient/client/Makefile | 23 - sbin/dhclient/client/clparse.c.patch | 12 - sbin/dhclient/client/dhclient.8.no_obj.patch | 93 - sbin/dhclient/client/dhclient.c.patch | 538 -- sbin/dhclient/client/scripts,freebsd.no_obj.patch | 54 - sbin/dhclient/clparse.c | 801 +++ sbin/dhclient/common/Makefile | 27 - sbin/dhclient/common/ctrace.c.patch | 18 - sbin/dhclient/common/dhcp-options.5.no_obj.patch | 33 - sbin/dhclient/common/discover.c.patch | 239 - sbin/dhclient/common/dispatch.c.patch | 30 - sbin/dhclient/common/icmp.c.patch | 18 - sbin/dhclient/common/parse.c.patch | 23 - sbin/dhclient/conflex.c | 371 ++ sbin/dhclient/convert.c | 115 + sbin/dhclient/dhclient-script | 219 + sbin/dhclient/dhclient-script.8 | 265 + sbin/dhclient/dhclient.8 | 184 + sbin/dhclient/dhclient.c | 2164 +++++++++ sbin/dhclient/dhclient.conf.5 | 548 +++ sbin/dhclient/dhclient.leases.5 | 89 + sbin/dhclient/dhcp-options.5 | 592 +++ sbin/dhclient/dhcp.h | 167 + sbin/dhclient/dhcpd.h | 348 ++ sbin/dhclient/dhctoken.h | 87 + sbin/dhclient/dispatch.c | 452 ++ sbin/dhclient/dst/Makefile | 14 - sbin/dhclient/errwarn.c | 250 + sbin/dhclient/includes/Makefile | 13 - sbin/dhclient/includes/dhcpd.h.patch | 89 - sbin/dhclient/includes/osdep.h.patch | 12 - sbin/dhclient/inet.c | 119 + sbin/dhclient/minires/Makefile | 24 - sbin/dhclient/omapip/Makefile | 20 - sbin/dhclient/options.c | 506 ++ sbin/dhclient/packet.c | 248 + sbin/dhclient/parse.c | 504 ++ sbin/dhclient/privsep.c | 224 + sbin/dhclient/privsep.h | 46 + sbin/dhclient/tables.c | 321 ++ sys/net/if.h | 1 + usr.sbin/Makefile | 4 - usr.sbin/dhcp/Makefile | 12 - usr.sbin/dhcp/Makefile.common | 8 - usr.sbin/dhcp/Makefile.inc | 22 - usr.sbin/dhcp/dhcpctl/Makefile | 5 - usr.sbin/dhcp/dhcpctl/Makefile.bin | 11 - usr.sbin/dhcp/dhcpctl/Makefile.lib | 13 - usr.sbin/dhcp/dhcpctl/omshell.1.no_obj.patch | 14 - usr.sbin/dhcp/relay/Makefile | 11 - usr.sbin/dhcp/server/Makefile | 12 - 210 files changed, 9079 insertions(+), 97144 deletions(-) diff --git a/contrib/dhcp-3.0/LICENSE b/contrib/dhcp-3.0/LICENSE deleted file mode 100644 index ef2536b..0000000 --- a/contrib/dhcp-3.0/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") -# Copyright (c) 1995-2003 by Internet Software Consortium -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# -# Internet Systems Consortium, Inc. -# 950 Charter Street -# Redwood City, CA 94063 -# -# http://www.isc.org/ diff --git a/contrib/dhcp-3.0/README b/contrib/dhcp-3.0/README deleted file mode 100644 index a487a2c..0000000 --- a/contrib/dhcp-3.0/README +++ /dev/null @@ -1,656 +0,0 @@ - Internet Systems Consortium DHCP Distribution - Version 3.0.2rc3 - December 3, 2004 - - README FILE - -You should read this file carefully before trying to install or use -the ISC DHCP Distribution. - - TABLE OF CONTENTS - - 1 WHERE TO FIND DOCUMENTATION - 2 RELEASE STATUS - 3 BUILDING THE DHCP DISTRIBUTION - 3.1 UNPACKING IT - 3.2 CONFIGURING IT - 3.2.1 DYNAMIC DNS UPDATES - 3.2.2 LOCALLY DEFINED OPTIONS - 3.3 BUILDING IT - 4 INSTALLING THE DHCP DISTRIBUTION - 5 USING THE DHCP DISTRIBUTION - 5.1 FIREWALL RULES - 5.2 LINUX - 5.2.1 IF_TR.H NOT FOUND - 5.2.2 SO_ATTACH_FILTER UNDECLARED - 5.2.3 PROTOCOL NOT CONFIGURED - 5.2.4 BROADCAST - 5.2.6 IP BOOTP AGENT - 5.2.7 MULTIPLE INTERFACES - 5.3 SCO - 5.4 HP-UX - 5.5 ULTRIX - 5.6 FreeBSD - 5.7 NeXTSTEP - 5.8 SOLARIS - 6 SUPPORT - 6.1 HOW TO REPORT BUGS - - WHERE TO FIND DOCUMENTATION - -Documentation for this software includes this README file, the -RELNOTES file, and the manual pages, which are in the server, common, -client and relay subdirectories. The README file (this file) includes -late-breaking operational and system-specific information that you -should read even if you don't want to read the manual pages, and that -you should *certainly* read if you run into trouble. Internet -standards relating to the DHCP protocol are stored in the doc -subdirectory. You will have the best luck reading the manual pages if -you build this software and then install it, although you can read -them directly out of the distribution if you need to. - -DHCP server documentation is in the dhcpd man page. Information about -the DHCP server lease database is in the dhcpd.leases man page. -Server configuration documentation is in the dhcpd.conf man page as -well as the dhcp-options man page. A sample DHCP server -configuration is in the file server/dhcpd.conf. The source for the -dhcpd, dhcpd.leases and dhcpd.conf man pages is in the server/ sub- -directory in the distribution. The source for the dhcp-options.5 -man page is in the common/ subdirectory. - -DHCP Client documentation is in the dhclient man page. DHCP client -configuration documentation is in the dhclient.conf man page and the -dhcp-options man page. The DHCP client configuration script is -documented in the dhclient-script man page. The format of the DHCP -client lease database is documented in the dhclient.leases man page. -The source for all these man pages is in the client/ subdirectory in -the distribution. In addition, the dhcp-options man page should be -referred to for information about DHCP options. - -DHCP relay agent documentation is in the dhcrelay man page, the source -for which is distributed in the relay/ subdirectory. - -To read installed manual pages, use the man command. Type "man page" -where page is the name of the manual page. This will only work if -you have installed the ISC DHCP distribution using the ``make install'' -command (described later). - -If you want to read manual pages that aren't installed, you can type -``nroff -man page |more'' where page is the filename of the -unformatted manual page. The filename of an unformatted manual page -is the name of the manual page, followed by '.', followed by some -number - 5 for documentation about files, and 8 for documentation -about programs. For example, to read the dhcp-options man page, -you would type ``nroff -man common/dhcp-options.5 |more'', assuming -your current working directory is the top level directory of the ISC -DHCP Distribution. - -If you do not have the nroff command, you can type ``more catpage'' -where catpage is the filename of the catted man page. Catted man -pages names are the name of the manual page followed by ".cat" -followed by 5 or 8, as with unformatted manual pages. - -Please note that until you install the manual pages, the pathnames of -files to which they refer will not be correct for your operating -system. - - RELEASE STATUS - -This is the second release candidate of ISC DHCP 3.0.2. This is a -maintenance release which seeks only to fix bugs present in versions -3.0.1 and earlier. No new features have or will be added in subsequent -release candidates of this release. - -In this release, the server and relay agent are currently fully -functional on NetBSD, Linux systems with kernel version 2.2 or later, -FreeBSD, OpenBSD, BSD/OS, Digital Tru64 Unix and Solaris. The software -will also run on AIX and HP-UX, but only supports a single network -interface. Ports also exist for QNX, SCO, NeXTStep, and MacOS X, but -are not in wide use, with all that implies. We are not aware of an -easy way to get this software running on HP-UX. - -The DHCP client currently only knows how to configure the network on -NetBSD, FreeBSD, OpenBSD, BSD/os, Linux, Solaris and NextStep. The -client depends on a system-dependent shell script to do network -configuration - support for other operating systems is simply a matter -of porting this shell script to the new platform. - -If you are running the DHCP distribution on a machine which is a -firewall, or if there is a firewall between your DHCP server(s) and -DHCP clients, please read the section on firewalls which appears later -in this document. - -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 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 -2.2, please read the note on FreeBSD. If you are running HP-UX or -Ultrix, please read the notes for those operating systems below. If -you are running NeXTSTEP, please see the notes on NeXTSTEP below. - -If you start dhcpd and get a message, "no free bpf", that means you -need to configure the Berkeley Packet Filter into your operating -system kernel. On NetBSD, FreeBSD and BSD/os, type ``man bpf'' for -information. On Digital Unix, type ``man pfilt''. - - - BUILDING THE DHCP DISTRIBUTION - - UNPACKING IT - -To build the DHCP Distribution, unpack the compressed tar file using -the tar utility and the gzip command - type something like: - - zcat dhcp-3.0.2rc3.tar.gz |tar xvf - - -On BSD/OS, you have to type gzcat, not zcat, and you may run into -similar problems on other operating systems. - - CONFIGURING IT - -Now, cd to the dhcp-3.0.2rc3 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. - - DYNAMIC DNS UPDATES - -A fully-featured implementation of dynamic DNS updates is included in -this release. There are no build dependencies with any BIND version -- this version can and should just use the resolver in your C library. - -There is documentation for the DDNS support in the dhcpd.conf manual -page - see the beginning of this document for information on finding -manual pages. - - LOCALLY DEFINED OPTIONS - -In previous versions of the DHCP server there was a mechanism whereby -options that were not known by the server could be configured using -a name made up of the option code number and an identifier: -"option-nnn" This is no longer supported, because it is not future- -proof. Instead, if you want to use an option that the server doesn't -know about, you must explicitly define it using the method described -in the dhcp-options man page under the DEFINING NEW OPTIONS heading. - - BUILDING IT - -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. - - INSTALLING THE DHCP DISTRIBUTION - -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''. - - USING THE DHCP DISTRIBUTION - - FIREWALL RULES - -If you are running the DHCP server or client on a computer that's also -acting as a firewall, you must be sure to allow DHCP packets through -the firewall. In particular, your firewall rules _must_ allow packets -from IP address 0.0.0.0 to IP address 255.255.255.255 from UDP port 68 -to UDP port 67 through. They must also allow packets from your local -firewall's IP address and UDP port 67 through to any address your DHCP -server might serve on UDP port 68. Finally, packets from relay agents -on port 67 to the DHCP server on port 67, and vice versa, must be -permitted. - -We have noticed that on some systems where we are using a packet -filter, if you set up a firewall that blocks UDP port 67 and 68 -entirely, packets sent through the packet filter will not be blocked. -However, unicast packets will be blocked. This can result in strange -behaviour, particularly on DHCP clients, where the initial packet -exchange is broadcast, but renewals are unicast - the client will -appear to be unable to renew until it starts broadcasting its -renewals, and then suddenly it'll work. The fix is to fix the -firewall rules as described above. - - PARTIAL SERVERS - -If you have a server that is connected to two networks, and you only -want to provide DHCP service on one of those networks (e.g., you are -using a cable modem and have set up a NAT router), if you don't write -any subnet declaration for the network you aren't supporting, the DHCP -server will ignore input on that network interface if it can. If it -can't, it will refuse to run - some operating systems do not have the -capability of supporting DHCP on machines with more than one -interface, and ironically this is the case even if you don't want to -provide DHCP service on one of those interfaces. - - 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. 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.) - -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 or raw -packet socket configured: - - Make sure CONFIG_PACKET (Packet socket) and CONFIG_FILTER (Socket - Filtering) are enabled in your kernel configuration - -If this happens, you need to configure your Linux kernel to support -Socket Filtering and the Packet socket. You can do this by typing -``make config'', ``make menuconfig'' or ``make xconfig'', and then -enabling the Packet socket and Socket Filtering options that you'll -see displayed on the menu or in the questionnaire. You can also edit -your linux kernel .config file directly: set CONFIG_FILTER=y and -CONFIG_PACKET=y. If you do this, make sure you run ``make oldconfig'' -afterwards, so that the changes you've made are propogated to the -kernel header files. After you've reconfigured, you need to type -``make'' to build a new Linux kernel, and then install it in the -appropriate place (probably /linux). Make sure to save a copy of your -old /linux. - -If the preceding paragraph made no sense to you, ask your Linux -vendor/guru for help - please don't ask us. - -If you set CONFIG_PACKET=m or CONFIG_FILTER=m, then you must tell the -kernel module loader to load the appropriate modules. If this doesn't -make sense to you, don't use CONFIG_whatever=m - use CONFIG_whatever=y. -Don't ask for help with this on the DHCP mailing list - it's a Linux -kernel issue. This is probably not a problem with the most recent -Linux 2.2.x kernels. - - LINUX: BROADCAST - -If you are running a recent version of Linux, this won't be a problem, -but on older versions of Linux (kernel versions prior to 2.2), there -is a potential problem with the broadcast address being sent -incorrectly. - -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 -address of 255.255.255.255. Unfortunately, Linux changes an IP -destination of 255.255.255.255 into the local subnet broadcast address -(here, that's 192.5.5.223). - -This isn't generally a problem on Linux 2.2 and later kernels, since -we completely bypass the Linux IP stack, but on old versions of Linux -2.1 and all versions of Linux prior to 2.1, it is a problem - pickier -DHCP clients connected to the same network as the ISC DHCP server or -ISC relay agent will not see messages from the DHCP server. It *is* -possible to run into trouble with this on Linux 2.2 and later if you -are running a verson of the DHCP server that was compiled on a Linux -2.0 system, though. - -It is possible to work around this problem on some versions of Linux -by creating a host route from your network interface address to -255.255.255.255. The command you need to use to do this on Linux -varies from version to version. The easiest version is: - - route add -host 255.255.255.255 dev eth0 - -On some older Linux systems, you will get an error if you try to do -this. On those systems, try adding the following entry to your -/etc/hosts file: - -255.255.255.255 all-ones - -Then, try: - - route add -host all-ones dev eth0 - -Another route that has worked for some users is: - - route add -net 255.255.255.0 dev eth0 - -If you are not using eth0 as your network interface, you should -specify the network interface you *are* using in your route command. - - 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: - - echo 1 >/proc/sys/net/ipv4/ip_bootp_agent - - - LINUX: MULTIPLE INTERFACES - -Very old versions of the Linux kernel do not provide a networking API -that allows dhcpd to operate correctly if the system has more than one -broadcast network interface. However, Linux 2.0 kernels with 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 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. -In fact, you now need to add a route for each interface. Hopefully -the Linux kernel gurus will get this straight eventually. - -Linux 2.1 and later kernels do not use SO_BINDTODEVICE or require the -broadcast address hack, but do support multiple interfaces, using the -Linux Packet Filter. - - SCO - -SCO has the same problem as Linux (described earlier). The thing is, -SCO *really* doesn't want to let you add a host route to the all-ones -broadcast address. - -On more recent versions of SCO, you can do this: - - ifconfig net0 xxx.xxx.xxx.xxx netmask 0xNNNNNNNN broadcast 255.255.255.255 - -If this doesn't work, you can also try the following strange hack: - - ifconfig net0 alias 10.1.1.1 netmask 8.0.0.0 - -Apparently this works because of an interaction between SCO's support -for network classes and the weird netmask. The 10.* network is just a -dummy that can generally be assumed to be safe. Don't ask why this -works. Just try it. If it works for you, great. SCO has added -support for doing DHCP in a more sensible way, but I have not had the -time or cause to implement them. If you are interested in this, and -are able to hack your way out of a wet paper back without assistance, -we'd appreciate it if you'd give it a try, but don't expect too much -support from us (sorry!). - - HP-UX - -HP-UX has the same problem with the all-ones broadcast address that -SCO and Linux have. One user reported that adding the following to -/etc/rc.config.d/netconf helped (you may have to modify this to suit -your local configuration): - -INTERFACE_NAME[0]=lan0 -IP_ADDRESS[0]=1.1.1.1 -SUBNET_MASK[0]=255.255.255.0 -BROADCAST_ADDRESS[0]="255.255.255.255" -LANCONFIG_ARGS[0]="ether" -DHCP_ENABLE[0]=0 - - ULTRIX - -Now that we have Ultrix packet filter support, the DHCP Distribution -on Ultrix should be pretty trouble-free. However, one thing you do -need to be aware of is that it now requires that the pfilt device be -configured into your kernel and present in /dev. If you type ``man -packetfilter'', you will get some information on how to configure your -kernel for the packet filter (if it isn't already) and how to make an -entry for it in /dev. - - FreeBSD - -Versions of FreeBSD prior to 2.2 have a bug in BPF support in that the -ethernet driver swaps the ethertype field in the ethernet header -downstream from BPF, which corrupts the output packet. If you are -running a version of FreeBSD prior to 2.2, and you find that dhcpd -can't communicate with its clients, you should #define BROKEN_FREEBSD_BPF -in site.h and recompile. - -Modern versions of FreeBSD include the ISC DHCP 3.0 client as part of -the base system, and the full distribution (for the DHCP server and -relay agent) is available from the Ports Collection in -/usr/ports/net/isc-dhcp3, or as a package on FreeBSD installation -CDROMs. - - NeXTSTEP - -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 machines. The symptom -of this problem is that the DHCP server never receives any requests. -This has been observed with Solaris 2.6 and Solaris 7 on Intel x86 -systems, although it may occur with other systems as well. If 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''. - -The DHCP client on Solaris will only work with DLPI. If you run it -and it just keeps saying it's sending DHCPREQUEST packets, but never -gets a response, you may be having DLPI trouble as described above. -If so, we have no solution to offer at this time. Also, because -Solaris requires you to "plumb" an interface before it can be detected -by the DHCP client, you must either specify the name(s) of the -interface(s) you want to configure on the command line, or must plumb -the interfaces prior to invoking the DHCP client. This can be done -with ``ifconfig iface plumb'', where iface is the name of the -interface (e.g., ``ifconfig hme0 plumb''). - -It should be noted that Solaris versions from 2.6 onward include a -DHCP client that you can run with ``/sbin/ifconfig iface dhcp start'' -rather than using the ISC DHCP client. The feature set of the Solaris -client is different (not necessarily better or worse) than that of the -ISC client, but in most cases it will be a lot easier for you to just -use that. Please do not ask for help in using the Solaris DHCP client -on Internet Systems Consortium mailing lists - that's why you're -paying Sun the big bucks. If you're having a problem with the -Solaris client interoperating with the ISC dhcp server, that's another -matter, but please check with Sun first. - - AIX - -The AIX support uses the BSD socket API, which cannot differentiate on -which network interface a broadcast packet was received; thus the DHCP -server and relay will work only on a single interface. (They do work -on multi-interface machines if configured to listen on only one of the -interfaces.) - -The ISC DHCP distribution does not include a dhclient-script for AIX-- -AIX comes with a DHCP client. Contribution of a working dhclient-script -for AIX would be welcome. - - SUPPORT - -The Internet Systems Consortium DHCP server is not a commercial -product, and is not supported by the ISC. However, it has attracted a -fairly sizable following on the Internet, which means that there are a -lot of knowledgable users who may be able to help you if you get -stuck. These people generally read the dhcp-server@isc.org mailing -list. - -If you are going to use dhcpd, you should probably subscribe to the -dhcp-server and dhcp-announce mailing lists. If you will be using -dhclient, you should subscribe to the dhcp-client mailing list. - -If you need help, you should ask on the dhcp-server or dhcp-client -mailing list - whichever is appropriate to your application. Support -requests for the ISC DHCP client should go to dhcp-client@isc.org. -Support requests for the DHCP server should go to dhcp-server@isc.org. -If you are having trouble with a combination of the client and server, -send the request to dhcp-server@isc.org. Please do not cross-post to -both lists under any circumstances. - -WHERE TO REPORT BUGS: If you want the act of sending in a bug report -to result in you getting help in the form of a fixed piece of -software, you are asking for help. Your bug report is helpful to us, -but fundamentally you are making a support request, so please use the -addresses described in the previous paragraphs. If you are _sure_ that -your problem is a bug, and not user error, or if your bug report -includes a patch, you can send it to dhcp-bugs@isc.org without -subscribing. This mailing list goes into a bug tracking system, so -you don't need to check periodically to see if we still remember the -bug - if you haven't been notified that the bug has been closed, we -still consider it a bug, and still have it in the system. - -PLEASE DO NOT REPORT BUGS IN OLD SOFTWARE RELEASES! Fetch the latest -release and see if the bug is still in that version of the software, -and if it's not, _then_ report it. It's okay to report bugs in the -latest patchlevel of a major version that's not the most recent major -version, though - for example, if you're running 3.0.1, you don't have -to upgrade to a 3.0.2rc (release candidate) before you can report bugs. - -PLEASE DO NOT REPORT BUGS IF YOU ARE RUNNING A VERSION OF THE ISC -DHCP DISTRIBUTION THAT YOU DIDN'T GET FROM THE ISC! Free operating -system distributions are notorious for including outdated versions of -software, and also versions of software that were not compiled on your -particular version of the operating system. These versions -frequently do not work. Getting a source distribution from the ISC -and installing it frequently *does* work. Please try this *before* -asking for help. - -PLEASE READ THIS README FILE CAREFULLY BEFORE REPORTING BUGS, -PARTICULARLY THE SECTION BELOW ON WHAT TO INCLUDE IN A BUG REPORT OR -HELP REQUEST. - -PLEASE DO NOT SEND REQUESTS FOR SUPPORT DIRECTLY TO THE ENGINEERS WHO -WORK ON THE ISC DHCP DISTRIBUTION! *PARTICULARLY*, DO NOT SEND MAIL -TO THE ENGINEERS BECAUSE YOU AREN'T SURE TO WHOM YOU SHOULD SEND MAIL -- if you aren't sure, *ask* on the dhcp-server@isc.org or -dhcp-client@isc.org mailing list. - -The number of people using the DHCP Distribution is sufficiently large -that if we take interrupts every time any one of those people runs -into trouble, we will never get any more coding done. If you send a -support request directly to any ISC or Nominum engineer, we will -forward it to the mailing list, or possibly ignore it, depending on -how much stress we are under at the time. - -Please do not Cc: us on mail you send to these lists - we read both -mailing lists, so this just means we get two copies! - -If your question can only be answered by one of the engineers, send it -to the appropriate public mailing list anyway - we will answer it -there. When we have time. - -Please do not think "Oh, I don't want to bother the whole mailing list -with this question." If you are too embarrassed to ask publically, -get a support contract. - -If you are concerned about bothering everybody on the list, that's -great, but that's what the list is there for. When you send mail to -one of the engineers, you are taking resources away from everybody on -the mailing list *anyway* - they just don't know it. - -We're not writing this because we don't respect you - we really do -want to help you, and we appreciate your bug reports and comments. -But please use the mechanisms we have in place to provide you with -help, because otherwise you are almost certainly depriving someone -else of our help. - -PLEASE DO NOT CALL US ON THE PHONE FOR HELP! Answering the phone -takes a lot more of our time and attention than answering email. If -you do call us on the phone, we will tell you to send email to the -mailing list or buy a support contract, so please don't waste your -time or ours. If you have a support contract, please use the support -channel mentioned in the support contract - otherwise you probably -won't get timely support unless you happen to ask an interesting -question and we happen to have some time to kill, because we can't -tell you're a support customer if you send mail to the public mailing -lists. - - HOW TO REPORT BUGS OR REQUEST HELP - -When you report bugs or ask for help, please provide us complete -information. A list of information we need follows. Please read it -carefully, and put all the information you can into your initial bug -report, so that we don't have to ask you any questions in order to -figure out your problem. If you need handholding support, please -consider contacting a commercial provider of the ISC DHCP -Distribution. - - 1. The specific operating system name and version of the - machine on which the DHCP server or client is running. - 2. The specific operating system name and version of the - machine on which the client is running, if you are having - trouble getting a client working with the server. - 3. If you're running Linux, the version number we care about is - the kernel version and maybe the library version, not the - distribution version - e.g., while we don't mind knowing - that you're running Redhat version mumble.foo, we must know - what kernel version you're running, and it helps if you can - tell us what version of the C library you're running, - although if you don't know that off the top of your head it - may be hard for you to figure it out, so don't go crazy - trying. - 4. The specific version of the DHCP distribution you're - running, for example "2.0b1pl19", not "2.0". - 5. Please explain the problem carefully, thinking through what - you're saying to ensure that you don't assume we know - something about your situation that we don't know. - 6. Include your dhcpd.conf and dhcpd.leases file if they're not - huge (if they are huge, we may need them anyway, but don't - send them until you're asked). Huge means more than 100 - kilobytes each. - 7. Include a log of your server or client running until it - encounters the problem - for example, if you are having - trouble getting some client to get an address, restart the - server with the -d flag and then restart the client, and - send us what the server prints. Likewise, with the client, - include the output of the client as it fails to get an - address or otherwise does the wrong thing. Do not leave - out parts of the output that you think aren't interesting. - 8. If the client or server is dumping core, please run the - debugger and get a stack trace, and include that in your - bug report. For example, if your debugger is gdb, do the - following: - - gdb dhcpd dhcpd.core - (gdb) where - [...] - (gdb) quit - - This assumes that it's the dhcp server you're debugging, and - that the core file is in dhcpd.core. - 9. If you know that the problem is an actual bug, and you can - reproduce the bug, you can skip steps 6 through 8 and instead - capture a trace file using the -tf flag (see the man page for - details). If you do this, and there is anything in your - dhcp configuration that you are not willing to make public, - please send the trace file to dhcp-bugs@isc.org and NOT to - dhcp-server@isc.org, because the tracefile contains your entire - dhcp configuration. - -PLEASE DO NOT send queries about non-isc clients to the dhcp-client -mailing list. If you're asking about them on an ISC mailing list, -it's probably because you're using the ISC DHCP server, so ask there. -If you are having problems with a client whose executable is called -dhcpcd, this is _not_ the ISC DHCP client, and we probably can't help -you with it. - -Please see http://www.isc.org/sw/dhcp/ for details on how to subscribe -to the ISC DHCP mailing lists. - - diff --git a/contrib/dhcp-3.0/README.DELETED b/contrib/dhcp-3.0/README.DELETED deleted file mode 100644 index 786887d..0000000 --- a/contrib/dhcp-3.0/README.DELETED +++ /dev/null @@ -1,41 +0,0 @@ -Makefile -Makefile.conf -Makefile.dist -client/Makefile.dist -client/scripts/bsdos -client/scripts/linux -client/scripts/netbsd -client/scripts/nextstep -client/scripts/openbsd -client/scripts/solaris -common/Makefile.dist -configure -contrib -dhcpctl/Makefile.dist -dhcpctl/cltest.c -doc -dst/Makefile.dist -includes/cf/aix.h -includes/cf/alphaosf.h -includes/cf/bsdos.h -includes/cf/cygwin32.h -includes/cf/hpux.h -includes/cf/irix.h -includes/cf/linux.h -includes/cf/netbsd.h -includes/cf/nextstep.h -includes/cf/openbsd.h -includes/cf/qnx.h -includes/cf/rhapsody.h -includes/cf/sample.h -includes/cf/sco.h -includes/cf/sunos4.h -includes/cf/sunos5-5.h -includes/cf/ultrix.h -minires/Makefile.dist -omapip/Makefile.dist -omapip/test.c -relay/Makefile.dist -server/Makefile.dist -site.conf -tests diff --git a/contrib/dhcp-3.0/README.DRAGONFLY b/contrib/dhcp-3.0/README.DRAGONFLY deleted file mode 100644 index f02023b..0000000 --- a/contrib/dhcp-3.0/README.DRAGONFLY +++ /dev/null @@ -1,5 +0,0 @@ -Original Source can be downloaded from: -ftp://ftp.isc.org/isc/dhcp/dhcp-3.0.2rc3.tar.gz -MD5 (dhcp-3.0.2rc3.tar.gz) = 7c5dd4587d0236275ddf026750513131 - -A list of files and directories removed is in README.DELETED. diff --git a/contrib/dhcp-3.0/RELNOTES b/contrib/dhcp-3.0/RELNOTES deleted file mode 100644 index 2200102..0000000 --- a/contrib/dhcp-3.0/RELNOTES +++ /dev/null @@ -1,1441 +0,0 @@ - Internet Systems Consortium DHCP Distribution - Version 3.0.2rc3 - December 3, 2004 - - Release Notes - - NEW FEATURES - -Version 3 of the ISC DHCP Distribution includes the following features -that are new since version 2.0: - - - DHCP Failover Protocol support - - OMAPI, an API for accessing and modifying the DHCP server and - client state. - - Conditional behaviour - - Storing arbitrary information on leases - - Address pools with access control - - Client classing - - Address allocation restriction by class - - Relay agent information option support - - Dynamic DNS updates - - Many bug fixes, performance enhancements, and minor new DHCP - protocol features. - -The main bug fixed here is a bug in the subclass allocation code that -could result in a memory smash. Any users of the ISC DHCP server who -are using subclasses should seriously consider upgrading to 3.0.1. - -If you are running 3.0 beta 1 and are doing dynamic DNS updates, the -lease file is no longer forward-compatible to 3.0 final. A script -has been provided to convert 3.0b1 lease files. This is in -contrib/3.0b1-lease-convert. - -For information on how to install, configure and run this software, -as well as how to find documentation and report bugs, please consult -the README file. - -The Dynamic DNS Update support is a descendent of an implementation -done by Lans Carstensen and Brian Dols at Rose-Hulman Institute of -Technology, Jim Watt at Applied Biosystems, Irina Goble at Integrated -Measurement Systems, Igor Sharfmesser at Kazakh Telecom, and Brian -Murrell at BC Tel Advanced Communications. I'd like to express my -thanks to all of these good people here, both for working on the code -and for prodding me into improving it. - - Changes since 3.0.2rc2 - -- Two varaibles introduced in 3.0.2b1 were used without being initialized - in the case where neither the FILE nor SNAME fields were available for - overloading. This was repaired. - -- A heretofore believed to be impossible corner case of the option - overloading implementation turned out to be possible ("Unable to sort - overloaded options after 10 tries."). The implementation was reworked - to consider the case of an option so large it would require more than - three chunks to fit. - -- Many other instances of variables being used without being initialized - were repaired. - -- An uninitialized variable in omapi_io_destroy() led to the discovery - that this function may result in orphaned pointers (and hence, a memory - leak). - - Changes since 3.0.2rc1 - -- allocate_lease() was rewritten to repair a bug in which the server would - try to allocate an ABANDONED lease when FREE leases were available. - - Changes since 3.0.2b1 - -- Some dhcp-eval.5 manpage formatting was repaired. - - Changes since 3.0.1 - -- A bug was fixed in the server's 'option overloading' implementation, - where options loaded into the 'file' and 'sname' packet fields were - not aligned precisely as rfc2131 dictates. - -- The FreeBSD client script was changed to support the case where a domain - name was not provided by the server. - -- A memory leak in 'omshell' per each command line parsed was - repaired, thanks to a patch from Jarkko Torppa. - -- Log functions writing to stderr were adjusted to use the STDERR_FILENO - system definition rather than '2'. This is a no-op for 90% of platforms. - -- One call to trace_write_packet_iov() counted the number of io vectors - incorrectly, causing inconsistent tracefiles. This was fixed. - -- Some expression parse failure memory leaks were closed. - -- A host byte order problem in tracefiles was repaired. - -- Pools configured in DHCPD for failover possessing permission lists that - previously were assumed to not include dyanmic bootp clients are now - a little more pessimistic. The result is, dhcpd will nag you about just - about most pools that possess a 'allow' statement with no 'deny' that - would definitely match a dynamic bootp client. - -- The 'ddns-update-style' configuration warning bit now insists that - the configuration be globally scoped. - -- Two memory leaks in dhclient were closed thanks to a patch from Felix - Farkas. - -- Some minor but excellently pedantic documentation errors were fixed - thanks to a patch from Thomas Klausner. - -- Bugs in operator precedence in executable statements have been repaired - once again. More legal syntaxes should be parsed legally. - -- Failing to initialize a tracefile for any reason if a tracefile was - specified is now a fatal error. Thanks to a patch from Albert Herranz. - -- Corrected a bug in which the number of leases transferred as calculated - by the failover primary and sent to peers in POOLRESP responses may be - incorrect. This value is not believed to be used by other failover - implementations, excepting perhaps as logged information. - -- Corrected a bug in which 'dhcp_failover_send_poolresp()' was in fact - sending POOLREQ messages instead of POOLRESP mesasges. This message - was essentially ignored since failover secondaries effectively do not - respond to POOLREQ messages. - -- Type definitions for various bitwidths of integers in the sunos5-5 - build of ISC DHCP have been fixed. It should compile and run more - easily when built in 64-bit for this platform. - -- "allow known-clients;" is now a legal syntax, to avoid confusion. - -- If one dhcp server chooses to 'load balance' a request to its failover - peer, it first checks to see if it believes said peer has a free - lease to allocate before ignoring the DISCOVER. - -- log() was logging a work buffer, rather than the value returned by - executing the statements configured by the user. In some cases, - the work buffer and the intended results were the same. In some other - cases, they were not. This was fixed thanks to a patch from Gunnar - Fjone and directconnect.no. - -- Compiler warnings for some string type conversions was fixed, thanks - to Andreas Gustafsson. - -- The netbsd build environments were simplified to one, in which - -Wconversion is not used, thanks to Andreas Gustafsson. - -- How randomness in the backoff-cutoff dhclient configuration variable - is implemented was better documented in the manpage, and the behaviour - of dhclient in REQUEST timeout handling was changed to match that of - DISCOVER timeout handling. - -- Omapi was hardened against clients that pass in null values, thanks - to a patch from Mark Jason Dominus. - -- A bug was fixed in dhclient that kept it from doing client-side - ddns updates. Thanks to a patch from Andreas Gustafsson, which - underwent some modification after review by Jason Vas Dias. - -- Failover implementations disconnected due to the network between - them (rather than one of the two shutting down) will now try to - re-establish the failover connection every 5 seconds, rather than - to simply try once and give up until one of them is restarted. - Thanks to a patch from Ulf Ekberg from Infoblox, and field testing - by Greger V. Teigre which led to an enhancement to it. - -- A problem that kept DHCP Failover secondaries from tearing down - ddns records was repaired. Thanks to a patch from Ulf Ekberg from - Infoblox. - -- 64bit pointer sizes are detected properly on FreeBSD now. - -- A bug was repaired where the DHCP server would leave stale references - to host records on leases it once thought about offering to certain - clients. The result would be to apply host and 'known' scopes to the - wrong clients (possibly denying booting). NOTE: The 'mis-host' patch - that was being circulated as a workaround is not the way this bug was - fixed. If you were a victim of this bug in 3.0.1, you are cautioned - to proceed carefully and see if it fixes your problem. - -- A bug was repaired in the server's DHCPINFORM handling, where it - tried to divine the client's address from the source packet and - would get it wrong. Thanks to Anshuman Singh Rawat. - -- A log message was introduced to help illuminate the case where the - server was unable to find a lease to assign to any BOOTP client. - Thanks to Daniel Baker. - -- A minor dhcpd.conf.5 manpage error was fixed. - - Changes since 3.0.1rc14 - -- The global variable 'cur_time' was centralized and is now uniformly of a - type #defined in system-dependent headers. It had previously been defined - in one of many places as a 32-bit value, and this causes mayhem on 64-bit - big endian systems. It probably wasn't too healthy on little endian - systems either. - -- A printf format string error introduced in rc14 was repaired. - -- AIX system-dependent header file was altered to only define NO_SNPRINTF - if the condition used to #ifdef in vsnprintf in AIX' header files - is false. - -- The Alpha/OSF system-dependent header file was altered to define - NO_SNPRINTF on OS revisions older than 4.0G. - -- omapip/test.c had string.h added to its includes. - - Changes since 3.0.1rc13 - -! CAN-2004-0460 - CERT VU#317350: Five stack overflow exploits were closed - in logging messages with excessively long hostnames provided by the - clients. It is highly probable that these could have been used by - attackers to gain arbitrary root access on systems using ISC DHCP 3.0.1 - release candidates 12 or 13. Special thanks to Gregory Duchemin for - both finding and solving the problem. - -! CAN-2004-0461 - CERT VU#654390: Once the above was closed, an opening - in log_*() functions was evidented, on some specific platforms where - vsnprintf() was not believed to be available and calls were wrapped to - sprintf() instead. Again, credit goes to Gregory Duchemin for finding - the problem. Calls to snprintf() are now linked to a distribution-local - snprintf implementation, only in those cases where the architecture is - not known to provide one (see includes/cf/[arch].h). If you experience - linking problems with snprintf/vsnprintf or 'isc_print_' functions, this - is where to look. This vulnerability did not exist in any previously - published version of ISC DHCP. - -- Compilation on hpux 11.11 was repaired. - -- 'The cross-compile bug fix' was backed out. - - Changes since 3.0.1rc12 - -- Fixed a bug in omapi lease lookup function, to form the hardware - address for the hash lookup correctly, thanks to a patch from - Richard Hirst. - -- Fixed a bug where dhcrelay was sending relayed responses back to the - broadcast address, but with the source's unicast mac address. Should - now conform to rfc2131 section 4.1. - -- Cross-compile bug fix; use $(AR) instead of ar. Thanks to Morten Brorup. - -- Fixed a crash bug in dhclient where dhcpd servers that do not provide - renewal times results in an FPE. As a side effect, dhclient can now - properly handle 0xFFFFFFFF (-1) expiry times supplied by servers. Thanks - to a patch from Burt Silverman. - -- The 'ping timeout' debugs from rc12 were removed to -DDEBUG only, - and reformatted to correct a compilation error on solaris platforms. - -- A patch was applied which fixes a case where leases read from the - leases database do not properly over-ride previously read leases. - -- dhcpctl.3 manpage was tweaked. - - Changes since 3.0.1rc11 - -- A patch from Steve Campbell was applied with minor modifications to - permit reverse dns PTR record updates with values containing spaces. - -- A patch from Florian Lohoff was applied with some modifications to - dhcrelay. It now discards packets whose hop count exceeds 10 by default, - and a command-line option (-c) can be used to set this threshold. - -- A failover bug relating to identifying peers by name length instead of - by name was fixed. - -- Delcaring failover configs within shared-network statements should no - longer result in error. - -- The -nw command line option to dhclient now works. - -- Thanks to a patch from Michael Richardson: - - Some problems with long option processing have been fixed. - - Some fixes to minires so that updates of KEY records will work. - -- contrib/ms2isc was updated by Shu-Min Chang of the Intel Corporation. - see contrib/ms2isc/readme.txt for revision notes. - -- Dhclient no longer uses shell commands to kill another instance of - itself, it sends the signal directly. Thanks to a patch from Martin - Blapp. - -- The FreeBSD dhclient-script was changed so that a failure to write to - /etc/resolv.conf does not prematurely end the script. This keeps dhclient - from looping infinitely when this is the case. Thanks to a patch from - Martin Blapp. - -- A patch from Bill Stephens was applied which resolves a problem with lease - expiry times in failover configurations. - -- A memory leak in configuration parsing was closed thanks to a patch from - Steve G. - -- The function which discovers interfaces will now skip non-broadcast or - point-to-point interfaces, thanks to a patch from David Brownlee. - -- Options not yet known by the dhcpd or dhclient have had their names - changed such that they do not contain # symbols, in case they should ever - appear in a lease file. An option that might have been named "#144" is - now "unknown-144". - -- Another patch from Bill Stephens which allows the ping-check timeout to - be configured as 'ping-timeout'. Defaults to 1. - - Changes since 3.0.1rc10 - -- Potential buffer overflows in minires repaired. - -- A change to the linux client script to use /bin/bash, since /bin/sh may - not be bash. - -- Some missing va_end cleanups thanks to a patch from Thomas Klausner. - -- A correction of boolean parsing syntax validation - some illegal syntaxes - that worked before are now detected and produce errs, some legal syntaxes - that errored before will now work properly. - -- Some search-and-replace errors that caused some options to change their - names was repaired. - -- Shu-min Chang of the Intel corporation has contributed a perl script and - module that converts the MS NT4 DHCP configuration to a ISC DHCP3 - configuration file. - -- Applied the remainder of the dhcpctl memory leak patch provided by Bill - Squier at ReefEdge, Inc. (groo@reefedge.com). - -- Missing non-optional failover peer configurations will now result in a soft - error rather than a null dereference. - - Changes since 3.0.1rc9 - -- A format string was corrected to fix compiler warnings. - -- A number of spelling corrections were made in the man pages. - -- The dhclient.conf.5 man page was changed to refer to do-forward-updates - rather than a configuration option that doesn't exist. - -- A FreeBSD-specific bug in the interface removal handling was fixed. - -- A Linux-specific Token Ring detection problem was fixed. - -- Hashes removed from as-yet-unknown agent options, having those options - appear in reality before we know about them will no longer produce - self-corrupting lease databases. - -- dhclient will use the proper port numbers now when using the -g option. - -- A order-of-operations bug with 2 match clauses in 1 class statement is - fixed thanks to a patch from Andrew Matheson. - -- Compilation problems on Solaris were fixed. - -- Compilation problems when built with DEBUG or DEBUG_PACKET were repaired. - -- A fix to the dhcp ack process which makes certain group options will be - included in the first DHCPOFFER message was made thanks to a patch from - Ling Gou. - -- A few memory leaks were repaired thanks to patches from Bill Squier at - ReefEdge, Inc. (groo@reefedge.com). - -- A fix for shared-networks that sometimes give clients options for the - wrong subnets (in particular, 'option routers') was applied, thanks to - Ted Lemon for the patch. - -- Omshell's handling of dotted octets as values was changed such that dots - one after the other produce zero values in the integer string. - - Changes since 3.0.1rc8 - -- Fix a format string vulnerability in the server that could lead to a - remote root compromise (discovered by NGSEC Research Team, www.ngsec.com). - -- Add additional support for NetBSD/sparc64. - -- Fix a bug in the command-line parsing of the client. Also, resolve - a memory leak. - -- Add better support for shells other than bash in the Linux client - script. - -- Various build fixes for modern versions of FreeBSD and Linux. - -- Fix a bad bounds check when printing binding state names. - -- Clarify documentation about fixed-address and multiple addresses. - -- Fix a typo in the authoritative error message. - -- Make a log entry when we can't write a billing class. - -- Use conversion targets that are the right size on all architectures. - -- Increment the hop count when relaying. - -- Log a message when lease state is changed through OMAPI. - -- Don't rerun the shared_network when evaluating the pool. - -- Fix a reversed test in the parser. - -- Change the type of rbuf_max. - -- Make FTS_LAST a manifest constant to quiet warnings. - - Changes since 3.0.1rc7 - -- Fix two compiler warnings that are generated when compiling on Solaris - with gcc. These stop the build, even though they weren't actually - errors, because we prefer that our builds generate no warnings. - - Changes since 3.0.1rc6 - -- Don't allow a lease that's in the EXPIRED, RELEASED or RESET state - to be renewed. - -- Implement lease stealing for cases where the primary has fewer leases - than the secondary, as called for by the standard. - -- Add a fudge factor to the lease expiry acceptance code, (suggested - by Kevin Miller of CMU). - -- Fix a bug in permit_list_match that made it much too willing to say - that two permit lists matched. - -- Unless DEBUG_DNS_UPDATES is defined, print more user-friendly (and - also more compact) messages about DNS updates. - -- Fix a bug in generating wire-format domain names for the FQDN option. - -- Fix a bug where the FQDN option would not be returned if the client - requested it, contrary to the standard. - -- On Darwin, use the FreeBSD DHCP client script. - -- On NetBSD/sparc, don't check for casting warnings. - -- Add a flag in the DHCP client to disable updating the client's A - record when sending an FQDN option indicating that the client is - going to update its A record. - -- In the client, don't attempt a DNS update until one second after - configuring the new IP address, and if the update times out, keep - trying until a response, positive or negative, is received from the - DNS server. - -- Fix an uninitialized memory bug in the DHCP client. - -- Apply some FreeBSD-specific bug fixes suggested by Murray Stokely. - -- Fix a bug in ns_parserr(), where it was returning the wrong sort - of result code in some cases (suggested by Ben Harris of the - NetBSD project). - -- Fix a bug in is_identifier(), where it was checking against EOF - instead of the END_OF_FILE token (also suggested by Ben Harris). - -- Fix a bug where if an option universe contained no options, the - DHCP server could dump core (Walter Steiner). - -- Fix a bug in the handling of encapsulated options. - -- Fix a bug that prevented NWIP suboptions from being processed. - -- Delete the FTS_BOOTP and FTS_RESERVED states and implement them - as modifier flags to the FTS_ACTIVE state, as called for in the - failover protocol standard. - -- Fix bugs in the pool merging code that resulted in references and - dereferences of null pointers. This bug had no impact unless the - POINTER_DEBUG flag was defined. - -- In the server, added a do-forward-updates flag that can be used to - disable forward updates in all cases, so that sites that want the - clients to take sole responsibility for updating their A record can - do so. - -- Make it possible to disable optimization of PTR record updates. - - Changes since 3.0.1rc5 - -- Include some new documentation and changes provided by Karl Auer. - -- Add a workaround for some Lexmark printers that send a double-NUL- - terminated host-name option, which would break DNS updates. - -- Fix an off-by-one error in the MAC-address checking code for - DHCPRELEASE that was added in 3.0.1rc5. - -- Fix a bug where client-specific information was not being discarded - from the lease when it expired or was released, resulting in - problems if the lease was reallocated to a different client. - -- If more than one allocation pool is specified that has the same set - of constraints as another allocation pool on the same shared - network, merge the two pools. - -- Don't print an error in fallback_discard, since this just causes - confusion and does not appear to be helping to encourage anyone to - fix this bug. - - Changes since 3.0.1rc4 - -- Fix a bug that would cause the DHCP server to spin if asked to parse - a certain kind of incorrect statement. - -- Fix a related bug that would prevent an error from being reported in - the same case. - -- Additional documentation. - -- Make sure that the hardware address matches the lease when - processing a DHCPRELEASE message. - - Changes since 3.0.1rc3 - -- A minor bug fix in the arguments to a logging function call. -- Documentation update for dhcpd.conf. - - Changes since 3.0.1rc2 - -- Allow the primary to send a POOLREQ message. This isn't what the current - failover draft says to do, so we may have to back it out if I can't get the - authors to relent, but the scheme for balancing that's specified in the - current draft seems needlessly hairy, so I'm floating a trial balloon. - The rc1 code did not implement the method described in the draft either. - - Changes since 3.0.1rc1 - -- Treat NXDOMAIN and NXRRSET as success when we are trying to delete a - domain or RRSET. This allows the DHCP server to forget about a name - it added to the DNS once it's been removed, even if the DHCP server - wasn't the one that removed it. - -- Install defaults for failover maximum outstanding updates and maximum - silent time. This prevents problems that might occur if these values - were not configured. - -- Don't do DDNS deletes if ddns-update-style is none. - -- Return relay agent information options in DHCPNAK. This prevents DHCPNAK - messages from being dropped when the relay agent information option contains - routing information. - -- Fix a problem where coming up in recover wouldn't result in an update - request being sent. - -- Add some more chatty messages when we start a recovery update and when it's - done. - -- Fix a possible problem where some state might have been left around - after the peer lost contact and regained contact about how many updates - were pending. - -- Don't nix a lease update because of a lease conflict. This test has - never (as far as I know) prevented a mistake, and it appears to cause - problems with failover. - -- Add support in rc history code for keeping a selective history, rather - than a history of all references and dereferences. This code is only used - when extensive additional debugging is enabled. - - Changes since 3.0 - -- Make allocators for hash tables. As a side effect, this fixes a memory - smash in the subclass allocation code. - -- Fix a small bug in omshell where if you try to close an object when - no object is open, it dumps core. - -- Fix an obscure coredump that could occur on shutdown. - -- Fix a bug in the recording of host declaration rubouts in the lease file. - -- Fix two potential spins in the host deletion code. - -- Fix a core dump that would happen if an application tried to update - a host object attribute with a null value. - - Changes since 3.0 Release Candidate 12 - -- Fix a memory leak in the evaluation code. - -- Fix an obscure core dump. - -- Print a couple of new warnings when parsing the configuration file - when crucial information is left out. - -- Log "no free leases" as an error. - -- Documentation updates. - - Changes since 3.0 Release Candidate 11 - -- Always return a subnet selection option if one is sent. - -- Fix a warning that was being printed because an automatic data - structure wasn't zeroed. - -- Fix some failover state transitions that were being handled - incorrectly. - -- When supersede_lease is called on a lease whose end time has already - expired, but for which a state transition has not yet been done, do - a state transition. This fixes the case where if the secondary - allocated a lease to a client and the lease "expired" while the - secondary was in partner-down, no expiry event would actually - happen, so the lease would remain active until the primary was - restarted. - - Changes since 3.0 Release Candidate 10 - -- Fix a bug that was preventing released leases from changing state - in failover-enabled pools. - -- Fix a core dump in the client identifier finder code (for host - declarations). - -- Finish fixing a bug where bogus data would sometimes get logged to - the dhclient.leases file because it was opened as descriptor 2. - -- Fix the Linux dhclient-script according to suggestions made by - several people on the dhcp-client mailing list. - -- Log successful DNS updates at LOG_INFO, not LOG_ERROR. - -- Print an error message and refuse to run if a failover peer is - defined but not referenced by any pools. - -- Correct a confusing error message in failover. - - Changes since 3.0 Release Candidate 9 - -- Fix a bug in lease allocation for Dynamic BOOTP clients. - - Changes since 3.0 Release Candidate 8 Patchlevel 2 - -- Fix a bug that prevented update-static-leases from working. - -- Document failover-state OMAPI object. - -- Fix a compilation error on SunOS 4. - - Changes since 3.0 Release Candidate 8 Patchlevel 1 - -- Fix a parsing bug that broke dns updates (both interim and ad-hoc). - This was introduced in rc8pl1 as an unintended result of the memory - leakage fixes that were in pl1. - -- Fix a long-standing bug where the server would record that an update - had been done for a client with no name, even though no update had - been done, and then when the client's lease expired the deletion of - that nonexistant record would time out because the name was the null - string. - -- Clean up the omshell, dhcpctl and omapi man pages a bit. - - Changes since 3.0 Release Candidate 8 - -- Fix a bug that could cause the DHCP server to spin if - one-lease-per-client was enabled. - -- Fix a bug that was causing core dumps on BSD/os in the presence of - malformed packets. - -- In partner-down state, don't restrict lease lengths to MCLT. - -- On the failover secondary, record the MCLT received from the primary - so that if we come up without a connection to the primary we don't - wind up giving out zero-length leases. - -- Fix some compilation problems on BSD/os. - -- Fix a bunch of memory leaks. - -- Fix a couple of bugs in the option printer. - -- Fix an obscure error reporting bug in the dns update code, and also - make the message clearer when a key algorithm isn't supported. - -- Fix a bug in the tracing code that prevented trace runs that used - tcp connections from being played back. - -- Add some additional debugging capability for catching memory leaks - on exit. - -- Make the client release the lease correctly on shutdown. - -- Add some configurability to the build system. - -- Install omshell manual page in man1, not man8. - -- Craig Gwydir sent in a patch that fixes a long-standing bug in the - DHCP client that could cause core dumps, but that for some reason - hadn't been noticed until now. - - Changes since 3.0 Release Candidate 7 - -- Fix a bug in failover where we weren't sending updates after a - transition from communications-interrupted to normal. - -- Handle expired/released/reset -> free transition according to the - protocol specification (this works - the other way not only wasn't - conformant, but also didn't work). - -- Add a control object in both client and server that allows either - daemon to be shut down cleanly. - -- When writing a lease, if we run out of disk space, shut down the - output file and insist on writing a new one before proceeding. - -- In the server, if the OMAPI listener port is occupied, keep trying - to get it, rather than simply giving up and exiting. - -- Support fetching variables from leases and also updating and adding - variables to leases via OMAPI. - -- If two failover peers have wildly different clocks, refuse to start - doing failover. - -- Fix a bug in the DNS update code that could cause core dumps when - running on alpha processors. - -- Fixed a bug in ddns updates for static lease entries, thanks to a - patch from Andrey M Linkevitch. - -- Add support for Darwin/MacOS X - -- Install omshell (including new documentation). - -- Support DNS updates in the client (this is a very obscure feature - that most DHCP client users probably will not be able to use). - -- Somewhat cleaner status logging in the client. - -- Make OMAPI key naming syntax compatible with the way keys are - actually named (key names are domain names). - -- Fix a bug in the lease file writer. - -- Install DHCP ISC headers in a different place than BIND 9 ISC - headers, to avoid causing trouble in BIND 9 builds. - -- Don't send updates for attributes on an object when the attributes - haven't changed. Support deleting attributes on remote objects. - -- Fix a number of bugs in omshell, and add the unset and refresh - statements. - -- Handle disconnects in OMAPI a little bit more intelligently (so that - the caller gets ECONNRESET instead of EINVAL). - -- Fix a bunch of bugs in the handling of clients that have existing - leases when the try to renew their leases while failover is - operating. - - Changes since 3.0 Release Candidate 6 - -- Fix a core dump that could happen when processing a DHCPREQUEST from - a client that had a host declaration that contained both a - fixed-address declaration and a dhcp-client-identifier option - declaration, if the client identifier was longer than nine bytes. - -- Fix a memory leak that could happen in certain obscure cases when - using omapi to manipulate leases. - -- Fix some bugs and omissions in omshell. - - - Changes since 3.0 Release Candidate 5 - -- Fix a bug in omapi_object_dereference that prevented objects in - chains from having their reference counts decreased on dereference. - -- Fix a bug in omapi_object_dereference that would prevent object - chains from being freed upon removal of the last reference external - to the chain. - -- Fix a number of other memory leaks in the OMAPI protocol subsystem. - -- Add code in the OMAPI protocol handler to trace memory leakage. - -- Clean up the memory allocation/reference history printer. - -- Support input of dotted quads and colon-separated hex lists as - attribute values in omshell. - -- Fix a typo in the Linux interface discovery code. - -- Conditionalize a piece of trace code that wasn't conditional. - - Changes since 3.0 Release Candidate 4 - -- Fix a bug that would prevent leases from being abandoned properly on - DHCPDECLINE. - -- Fix failover peer OMAPI support. - -- In failover, correctly handle expiration of leases. Previously, - leases would never be reclaimed because they couldn't make the - transition from EXPIRED to FREE. - -- Fix some broken failover state transitions. - -- Documentation fixes. - -- Take out an unnecessary check in DHCP relay agent information option - stashing code that was preventing REBINDING clients from rebinding. - -- Prevent failover peers from allocating leases in DHCPREQUEST - processing if the lease belongs to the other server. - -- Record server version in lease file introductory comment. - -- Correctly report connection errors in OMAPI and failover. - -- Make authentication signature algorithm name comparisons in OMAPI - case-insensitive. - -- Fix compile problem on SunOS 4.x - -- If a signature algorithm is not terminated with '.', terminate it so - that comparisons between fully-qualified names will work - consistently. - -- Different SIOCGIFCONF probe code, may "fix" problem on some Linux - systems with the probe not working correctly. - -- Don't allow user to type omapi key on command line of omshell. - - Changes since 3.0 Release Candidate 3 - -- Do lease billing on startup in a way that I *think* will finally do - the billing correctly - the previous method could overbill as a - result of duplicate leases. - -- Document OMAPI server objects. - - Changes since 3.0 Release Candidate 2 Patchlevel 1 - -- Fix some problems in the DDNS update code. Thanks to Albert - Herranz for figuring out the main problem. - -- Fix some reference counting errors on host entries that were causing - core dumps. - -- Fix a byte-swap bug in the token ring code, thanks to Jochen - Friedrich. - -- Fix a bug in lease billing, thanks to Jonas Bulow. - - Changes since 3.0 Release Candidate 2 - -- Change the conditions under which a DHCPRELEASE is actually - committed to be consistent with lease binding states rather than - using the lease end time. This may fix some problems with the - billing class code. - -- Fix a bug where lease updates would fail on Digital Unix (and maybe - others) because malloc was called with a size of zero. - -- Fix a core dump that happens when the DHCP server can't create its - trace file. - - Changes since 3.0 Release Candidate 1 Patchlevel 1 - -- Fix the dhcp_failover_put_message to not attempt to allocate a - zero-length buffer. Some versions of malloc() fail if you try to - allocate a zero-length buffer, and this was causing problems on, - e.g., Digital Unix. - -- Fix a case where the failover code was printing an error message - when no error had occurred. - -- Fix a problem where when a server went down and back up again, the - peer would not see a state transition and so would stay in the - non-communicating state. - -- Be smart about going into recover_wait. - -- Fix a problem in the failover implementation where peers would fail - to come into sync if interrupted in the RECOVER state. This could - have been the cause of some problems people have reported recently. - -- Fix a problem with billing classes where they would not be unbilled - when the client lease expired. - -- If select fails, figure out which descriptor is bad, and cut it out - of the I/O loop. This prevents a potentially nasty spin. I - haven't heard any report it in a while, but it came up consistently - in testing. - -- Fix a bug in the relay agent where if you specified interfaces on - the command line, it would fail. - -- Fix a couple of small bugs in the omapi connection object (no known - user impact). - -- Add the missing 3.0 Beta 1 lease conversion script. - -- Read dhcp client script hooks if they exist, rather than only if - they're executable. - - Changes since 3.0 Release Candidate 1 - -- Fix a memory smash that happens when fixed-address leases are used. - ANY SITE AT WHICH FIXED-ADDRESS STATEMENTS ARE BEING USED SHOULD - UPGRADE IMMEDIATELY. This has been a long-standing bug - thanks to - Alvise Nobile for discovering it and helping me to find it! - -- Fix a small bug in binary-to-ascii, thanks to H. Peter Anvin of - Transmeta. - -- There is a known problem with the DHCP server doing failover on - Compaq Alpha systems. This patchlevel is not a release candidate - because of this bug. The bug should be straightforward to fix, so - a new release candidate is expected shortly. - -- There is a known problem in the DDNS update code that is probably a - bug, and is not, as far as we know, fixed in this patchlevel. - - Changes since 3.0 Beta 2 Patchlevel 24 - -- Went over problematic failover state transitions and made them all - work, so that failover should now much less fragile. - -- Add some dhcpctl and omapi documentation - -- Fix compile errors when compiling with unusual predefines. - -- Make Token Ring work on Linux 2.4 - -- Fix the Digital Unix BPF_WORDALIGN bug. - -- Fix some dhcp client documentation errors. - -- Update some parts of the README file. - -- Support GCC on SCO. - - Changes since 3.0 Beta 2 Patchlevel 23 - -- Fix a bug in the DNS update code where a status code was not being - checked. This may have been causing core dumps. - -- When parsing the lease file, if a lease declaration includes a - billing class statement, and the lease already has a billing class, - unbill the old class. - -- When processing failover transactions, where acks will be deferred, - process the state transition immediately. - -- Don't try to use the new SIOCGIFCONF buffer size detection code on - Linux 2.0, which doesn't provide this functionality. - -- Apply a patch suggested by Tuan Uong for a problem in dlpi.c. - -- Fix a problem in using the which command in the configure script. - -- Fix a parse error in the client when setting up an omapi listener. - -- Document the -n and -g flags to the client. - -- Make sure there is always a stdin and stdout on startup. This - prevents shell scripts from accidentally writing error messages into - configuration files that happen to be opened as stderr. - -- If an interface is removed, the client will now notice that it is - gone rather than spinning. This has only been tested on NetBSD. - -- The client will attempt to get an address even if it can't create a - lease file. - -- Don't overwrite tracefiles. - -- Fix some memory allocation bugs in failover. - - Changes since 3.0 Beta 2 Patchlevel 22 - -- Apply some patches suggested by Cyrille Lefevre, who is maintaining - the FreeBSD ISC DHCP Distribution port. - -- Fix a core dump in DHCPRELEASE. - - Changes since 3.0 Beta 2 Patchlevel 21 - -- This time for sure: fix the spin described in the changes for pl20. - - Changes since 3.0 Beta 2 Patchlevel 20 - -- Fix a problem with Linux detecting large numbers of interfaces (Ben) - -- Fix a memory smash in the quotify code, which was introduced in - pl19. - -- Actually fix the spin described in the changes for pl20. The - previous fix only partially fixed the problem - enough to get it - past the regression test. - - Changes since 3.0 Beta 2 Patchlevel 19 - -- Fix a bug that could cause the server to abort if compiled with - POINTER_DEBUG enabled. - -- Fix a bug that could cause the server to spin when responding to a - DHCPREQUEST. - -- Apply Joost Mulders' suggested patches for DLPI on x86. - -- Support NUL characters in quoted strings. - -- Install unformatted man pages on SunOS. - - Changes since 3.0 Beta 2 Patchlevel 18 - -- Allow the server to be placed in partner-down state using OMAPI. - (Damien Neil) - -- Implement omshell, which can be used to do arbitrary things to the - server (in theory). (Damien Neil) - -- Fix a case where if a client had two different leases the server could - actually dereference the second one when it hadn't been referenced, - leading to memory corruption and a core dump. (James Brister) - -- Fix a case where a client could request the address of another client's - lease, but find_lease wouldn't detect that the other client had it, and - would attempt to allocate it to the client, resulting in a lease conflict - message. - -- Fix a case where a client with more than one client identifier could be - given a lease where the hardware address was correct but the client - identifier was not, resulting in a lease conflict message. - -- Fix a problem where the server could write out a colon-separated - hex list as a value for a variable, which would then not parse. - The fix is to always write strings as quoted strings, with any - non-printable characters quoted as octal escape sequences. So - a file written the old way still won't work, but new files written - this way will work. - -- Fix documentation for sending non-standard options. - -- Use unparsable names for unknown options. WARNING: this will - break any configuration files that use the option-nnn convention. - If you want to continue to use this convention for some options, - please be sure to write a definition, like this: - - option option-nnn code nnn = string; - - You can use a descriptive name instead of option-nnn if you like. - -- Fix a problem where we would see a DHCPDISCOVER/DHCPOFFER/ - DHCPREQUEST/DHCPACK/DHCPREQUEST/DHCPNAK sequence. This was the - result of a deceptively silly bug in supersede_lease. - -- Fix client script exit status check, according to a fix supplied by - Hermann Lauer. - -- Fix an endianness bug in the tracefile support, regarding ICMP - messages. - -- Fix a bug in the client where the medium would not work correctly if - it contained quoted strings. - - ** there was no pl17 ** - - Changes since 3.0 Beta 2 Patchlevel 16 - -- Add support for transaction tracing. This allows the state of the - DHCP server on startup, and all the subsequent transactions, to be - recorded in a file which can then be played back to reproduce the - behaviour of the DHCP server. This can be used to quickly - reproduce bugs that cause core dumps or corruption, and also for - tracking down memory leaks. - -- Incorporate some bug fixes provided by Joost Mulders for the DLPI - package which should clear up problems people have been seeing on - Solaris. - -- Fix bugs in the handling of options stored as linked lists (agent - options, fqdn options and nwip options) that could cause memory - corruption and core dumps. - -- Fix a bug in DHCPREQUEST handling that resulted in DHCPNAK messages - not being send in some cases when they were needed. - -- Make the lease structure somewhat more compact. - -- Make initial failover startup *much* faster. This was researched - and implemented by Damien Neil. - -- Add a --version flag to all executables, which prints the program - name and version to standard output. - -- Don't rewrite the lease file every thousand leases. - -- A bug in nit.c for older SunOS machines was fixed by a patch sent in - by Takeshi Hagiwara. - -- Fix a memory corruption bug in the DHCP client. - -- Lots of documentation updates. - -- Add a feature allowing environment variables to be passed to the - DHCP client script on the DHCP client command line. - -- Fix client medium support, which had been broken for some time. - -- Fix a bug in the DHCP client initial startup backoff interval, which - would cause two DHCPDISCOVERS to be sent back-to-back on startup. - - - Changes since 3.0 Beta 2 Patchlevel 15 - -- Some documentation tweaks. - -- Maybe fix a problem in the DLPI code. - -- Fix some error code space inconsistencies in ddns update code. - -- Support relay agents that intercept unicast DHCP messages to stuff - agent options into them. - -- Fix a small memory leak in the relay agent option support code. - -- Fix a core dump that would occur if a packet was sent with no - options. - - Changes since 3.0 Beta 2 Patchlevel 14 - -- Finish fixing a long-standing bug in the agent options code. This - was causing core dumps and failing to operate correctly - in - particular, agent option stashing wasn't working. Agent option - stashing should now be working, meaning that agent options can be - used in class statements to control address allocation. - -- Fix up documentation. - -- Fix a couple of small memory leaks that would have added up - significantly in a high-demand situation. - -- Add a log-facility configuration parameter. - -- Fix a compile error on some older operating systems. - -- Add the ability in the client to execute certain statements before - transmitting packets to the server. Handy for debugging; not much - practical use otherwise. - -- Don't send faked-out giaddr when renewing or bound - again, useful - for debugging. - - Changes since 3.0 Beta 2 Patchlevel 13 - -- Fixed a problem where the fqdn decoder would sometimes try to store - an option with an (unsigned) negative length, resulting in a core - dump on some systems. - -- Work around the Win98 DHCP client, which NUL-terminates the FQDN - option. - -- Work around Win98 and Win2k clients that will claim they want to do - the update even when they don't have any way to do it. - -- Fix some log messages that can be printed when failover is operating - that were not printing enough information. - -- It was possible for a DHCPDISCOVER to get an allocation even when - the state machine said the server shouldn't be responding. - -- Don't load balance DHCPREQUESTs from clients in RENEWING and - REBINDING, since in RENEWING, if we heard it, it's for us, and in - REBINDING, the client wouldn't have got to REBINDING if its primary - were answering. - -- When we get a bogus state lease binding state transition, don't do - the transition. - - - Changes since 3.0 Beta 2 Patchlevel 12 - -- Fixed a couple of silly compile errors. - - Changes since 3.0 Beta 2 Patchlevel 11 - -- Albert Herranz tracked down and fixed a subtle bug in the base64 - decoder that would prevent any key with an 'x' in its base64 - representation from working correctly. - -- Thanks to Chris Cheney and Michael Sanders, we have a fix for the - hang that they both spotted in the DHCP server - when - one-lease-per-client was set, the code to release the "other" lease - could spin. - -- Fix a problem with alignment of the input buffer in bpf in cases - where two packets arrive in the same bpf read. - -- Fix a problem where the relay agent would crash if you specified an - interface name on the command line. - -- Add the ability to conditionalize client behaviour based on the - client state. - -- Add support for the FQDN option, and added support for a new way of - doing ddns updates (ddns update style interim) that allows more than - one DHCP server to update the DNS for the same network(s). This - was implemented by Damien Neil with some additional functionality - added by Ted Lemon. - -- Damien added a "log" statement, so that the configuration file can - be made to log debugging information and other information. - -- Fixed a bug that caused option buffers not to be terminated with an - end option. - -- Fixed a long-standing bug in the support for option spaces where the - options are stored as an ordered list rather than in a hash table, - which could theoretically result in memory pool corruption. - -- Prevent hardware declarations with no actual hardware address from - being written as something unparsable, and behave correctly in the - face of a null hardware address on input. - -- Allow key names to be FQDNs, and qualify the algorithm name if it is - specified unqualified. - -- Modify the DDNS update code so that it never prints the "resolver - failed" message, but instead says *why* the resolver failed. - -- Officially support the subnet selection option, which now has an - RFC. - -- Fix a build bug on MacOS X. - -- Allow administrator to disable ping checking. - -- Clean up dhcpd.conf documentation and add more information about how - it works. - - Changes since 3.0 Beta 2 Patchlevel 10 - -- Fix a bug introduced during debugging (!) and accidentally committed - to CVS. - - Changes since 3.0 Beta 2 Patchlevel 9 - -- Fix DHCP client handling of vendor encapsulated options. - -- Fix a bug in the handling of relay agent information options introduced - in patchlevel 9. - -- Stash agent options on client leases by default, and use the stashed - options at renewal time. - -- Add the ability to test the client's binding state in the client - configuration language. - -- Fix a core dump in the DNS update code. - -- Fix some expression evaluation bugs that were causing updates to be - done when no client hostname was received. - -- Fix expression evaluation debugging printfs. - -- Teach pretty_print_option to print options in option spaces other than - the DHCP option space. - -- Add a warning message if the RHS of a not is not boolean. - -- Never select for more than a day, because some implementations of - select will just fail if the timeout is too long (!). - -- Fix a case where a DHCPDISCOVER from an unknown network would be - silently dropped. - -- Fix a bug where if a client requested an IP address for which a different - client had the lease, the DHCP server would reallocate it anyway. - -- Fix the DNS update code so that if the client changes its name, the DNS - will be correctly updated. - - Changes since 3.0 Beta 2 Patchlevel 8 - -- Oops, there was another subtle math error in the header-length - bounds-checking. - - Changes since 3.0 Beta 2 Patchlevel 7 - -- Oops, forgot to byte-swap udp header length before bounds-checking it. - - Changes since 3.0 Beta 2 Patchlevel 6 - -- Fix a possible DoS attack where a client could cause the checksummer - to dump core. This was a read, not a write, so it shouldn't be - possible to exploit it any further than that. - -- Implement client- and server-side support for using the Client FQDN - option. - -- Support for other option spaces in the client has been added. This - means that it is now possible to define a vendor option space on the - client, request options in that space from the server (which must - define the same option space), and then use those options in the - client. This also allows NWIP and Client FQDN options to be used - meaningfully. - -- Add object initializer support. This means that objects can now be - initialized to something other than all-zeros when allocated, which - makes, e.g., the interface object support code a little more robust. - -- Fix an off-by-one bug in the host stuffer. This was causing host - deletes not the work, and may also have been causing OMAPI - connections to get dropped. Thanks to James Brister for tracking - this one down! - -- Fixed a core dump in the interface discovery code that is triggered - when there is no subnet declaration for an interface, but the server - decides to continue running. Thanks to Shane Kerr for tracking - down and fixing this problem. - - Changes since 3.0 Beta 2 Patchlevel 5 - -- Fix a bug in the recent enhancement to the interface discovery code - to support arbitrary-length interface lists. - -- Support NUL-terminated DHCP options when initializing client-script - environment. - -- Fix suffix operator. - -- Fix NetWare/IP option parsing. - -- Better error/status checking in dhcpctl initialization and omapi - connection code. - -- Fix a potential memory smash in dhcpctl code. - -- Fix SunOS4 and (maybe) Ultrix builds. - -- Fix a bug where a certain sort of incoming packet could cause a core - dump on Solaris (and probably elsewhere). - -- Add some more safety checks in error logging code. - -- Add support for ISC_R_INCOMPLETE in OMAPI protocol connection code. - -- Fix relay agent so that if an interface is specified on the command - line, the relay agent does not dump core. - -- Fix class matching so that match if can be combined with match or - spawn with. - -- Do not allow spurious leases in the lease database to introduce - potentially bogus leases into the in-memory database. - -- Fix a byte-order problem in the client hardware address type code - for OMAPI. - -- Be slightly less picky about what sort of hardware addresses OMAPI - can install in host declarations. - - Changes since 3.0 Beta 2 Patchlevel 4 - -- Incorporated Peter Marschall's proposed change to array/record - parsing, which allows things like the slp-agent option to be encoded - correctly. Thanks very much to Peter for taking the initiative to - do this, and for doing such a careful job of it (e.g., updating the - comments)! - -- Added an encoding for the slp-agent option. :') - -- Fixed SunOS 4 build. Thanks to Robert Elz for responding to my - request for help on this with patches! - -- Incorporated a change that should fix a problem reported by Philippe - Jumelle where when the network connection between two servers is - lost, they never reconnect. - -- Fix client script files other than that for NetBSD to actually use - make_resolv_conf as documented in the manual page. - -- Fix a bug in the packet handling code that could result in a core - dump. - -- Fix a bug in the bootp code where responses on the local net would - be sent to the wrong MAC address. Thanks to Jerry Schave for - catching this one. - - Changes since 3.0 Beta 2 Patchlevel 3 - -- In the DHCP client, execute client statements prior to using the values - of options, so that the client configuration can overried, e.g., the - lease renewal time. - -- Fix a reference counting error that would result in very reproducible - failures in updates, as well as occasional core dumps, if a zone was - declared without a key. - -- Fix some Linux 2.0 compilation problems. - -- Fix a bug in scope evaluation during execution of "on" statements that - caused values not to be recorded on leases. - -- If the dhcp-max-message-size option is specified in scope, and the - client didn't send this option, use the one specified in scope to - determine the maximum size of the response. - - Changes since 3.0 Beta 2 Patchlevel 2 - -- Fix a case where spawning subclasses were being allocated - incorrectly, resulting in a core dump. - -- Fix a case where the DHCP server might inappropriately NAK a - RENEWING client. - -- Fix a place dhcprequest() where static leases could leak. - -- Include memory.h in omapip_p.h so that we don't get warnings about - using memcmp(). - - Changes since 3.0 Beta 2 Patchlevel 1 - -- Notice when SIOCFIGCONF returns more data than fit in the buffer - - allocate a larger buffer, and retry. Thanks to Greg Fausak for - pointing this out. - -- In the server, if no interfaces were configured, report an error and - exit. - -- Don't ever record a state of 'startup'. - -- Don't try to evaluate the local failover binding address if none was - specified. Thanks to Joseph Breu for finding this. diff --git a/contrib/dhcp-3.0/client/clparse.c b/contrib/dhcp-3.0/client/clparse.c deleted file mode 100644 index e5079a1..0000000 --- a/contrib/dhcp-3.0/client/clparse.c +++ /dev/null @@ -1,1170 +0,0 @@ -/* clparse.c - - Parser for dhclient config and lease files... */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996-2003 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Internet Systems Consortium, Inc. - * 950 Charter Street - * Redwood City, CA 94063 - * - * http://www.isc.org/ - * - * This software has been written for Internet Systems Consortium - * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. - * To learn more about Internet Systems Consortium, see - * ``http://www.isc.org/''. To learn more about Vixie Enterprises, - * see ``http://www.vix.com''. To learn more about Nominum, Inc., see - * ``http://www.nominum.com''. - */ - -#ifndef lint -static char copyright[] = -"$Id: clparse.c,v 1.62.2.7 2004/11/24 17:39:14 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" - -static TIME parsed_time; - -struct client_config top_level_config; - -u_int32_t default_requested_options [] = { - DHO_SUBNET_MASK, - DHO_BROADCAST_ADDRESS, - DHO_TIME_OFFSET, - DHO_ROUTERS, - DHO_DOMAIN_NAME, - DHO_DOMAIN_NAME_SERVERS, - DHO_HOST_NAME, - 0 -}; - -/* client-conf-file :== client-declarations END_OF_FILE - client-declarations :== - | client-declaration - | client-declarations client-declaration */ - -isc_result_t read_client_conf () -{ - struct client_config *config; - struct client_state *state; - struct interface_info *ip; - isc_result_t status; - - /* Set up the initial dhcp option universe. */ - initialize_common_option_spaces (); - - /* Initialize the top level client configuration. */ - memset (&top_level_config, 0, sizeof top_level_config); - - /* Set some defaults... */ - top_level_config.timeout = 60; - top_level_config.select_interval = 0; - top_level_config.reboot_timeout = 10; - top_level_config.retry_interval = 300; - top_level_config.backoff_cutoff = 15; - top_level_config.initial_interval = 3; - top_level_config.bootp_policy = P_ACCEPT; - top_level_config.script_name = path_dhclient_script; - top_level_config.requested_options = default_requested_options; - top_level_config.omapi_port = -1; - top_level_config.do_forward_update = 1; - - group_allocate (&top_level_config.on_receipt, MDL); - if (!top_level_config.on_receipt) - log_fatal ("no memory for top-level on_receipt group"); - - group_allocate (&top_level_config.on_transmission, MDL); - if (!top_level_config.on_transmission) - log_fatal ("no memory for top-level on_transmission group"); - - status = read_client_conf_file (path_dhclient_conf, - (struct interface_info *)0, - &top_level_config); - if (status != ISC_R_SUCCESS) { - ; -#ifdef LATER - /* Set up the standard name service updater routine. */ - parse = (struct parse *)0; - status = new_parse (&parse, -1, default_client_config, - (sizeof default_client_config) - 1, - "default client configuration", 0); - if (status != ISC_R_SUCCESS) - log_fatal ("can't begin default client config!"); - - do { - token = peek_token (&val, (unsigned *)0, cfile); - if (token == END_OF_FILE) - break; - parse_client_statement (cfile, - (struct interface_info *)0, - &top_level_config); - } while (1); - end_parse (&parse); -#endif - } - - /* Set up state and config structures for clients that don't - have per-interface configuration statements. */ - config = (struct client_config *)0; - for (ip = interfaces; ip; ip = ip -> next) { - if (!ip -> client) { - ip -> client = (struct client_state *) - dmalloc (sizeof (struct client_state), MDL); - if (!ip -> client) - log_fatal ("no memory for client state."); - memset (ip -> client, 0, sizeof *(ip -> client)); - ip -> client -> interface = ip; - } - - if (!ip -> client -> config) { - if (!config) { - config = (struct client_config *) - dmalloc (sizeof (struct client_config), - MDL); - if (!config) - log_fatal ("no memory for client config."); - memcpy (config, &top_level_config, - sizeof top_level_config); - } - ip -> client -> config = config; - } - } - return status; -} - -int read_client_conf_file (const char *name, struct interface_info *ip, - struct client_config *client) -{ - int file; - struct parse *cfile; - const char *val; - int token; - isc_result_t status; - - if ((file = open (name, O_RDONLY)) < 0) - return uerr2isc (errno); - - cfile = (struct parse *)0; - new_parse (&cfile, file, (char *)0, 0, path_dhclient_conf, 0); - - do { - token = peek_token (&val, (unsigned *)0, cfile); - if (token == END_OF_FILE) - break; - parse_client_statement (cfile, ip, client); - } while (1); - token = next_token (&val, (unsigned *)0, cfile); - status = (cfile -> warnings_occurred - ? ISC_R_BADPARSE - : ISC_R_SUCCESS); - close (file); - end_parse (&cfile); - return status; -} - - -/* lease-file :== client-lease-statements END_OF_FILE - client-lease-statements :== - | client-lease-statements LEASE client-lease-statement */ - -void read_client_leases () -{ - int file; - struct parse *cfile; - const char *val; - int token; - - /* Open the lease file. If we can't open it, just return - - we can safely trust the server to remember our state. */ - if ((file = open (path_dhclient_db, O_RDONLY)) < 0) - return; - cfile = (struct parse *)0; - new_parse (&cfile, file, (char *)0, 0, path_dhclient_db, 0); - - do { - token = next_token (&val, (unsigned *)0, cfile); - if (token == END_OF_FILE) - break; - if (token != LEASE) { - log_error ("Corrupt lease file - possible data loss!"); - skip_to_semi (cfile); - break; - } else - parse_client_lease_statement (cfile, 0); - - } while (1); - - close (file); - end_parse (&cfile); -} - -/* client-declaration :== - SEND option-decl | - DEFAULT option-decl | - SUPERSEDE option-decl | - PREPEND option-decl | - APPEND option-decl | - hardware-declaration | - REQUEST option-list | - REQUIRE option-list | - TIMEOUT number | - RETRY number | - REBOOT number | - SELECT_TIMEOUT number | - SCRIPT string | - VENDOR_SPACE string | - interface-declaration | - LEASE client-lease-statement | - ALIAS client-lease-statement | - KEY key-definition */ - -void parse_client_statement (cfile, ip, config) - struct parse *cfile; - struct interface_info *ip; - struct client_config *config; -{ - int token; - const char *val; - struct option *option; - struct executable_statement *stmt, **p; - enum statement_op op; - int lose; - char *name; - struct data_string key_id; - enum policy policy; - int known; - int tmp, i; - isc_result_t status; - - switch (peek_token (&val, (unsigned *)0, cfile)) { - case INCLUDE: - next_token (&val, (unsigned *)0, cfile); - token = next_token (&val, (unsigned *)0, cfile); - if (token != STRING) { - parse_warn (cfile, "filename string expected."); - skip_to_semi (cfile); - } else { - status = read_client_conf_file (val, ip, config); - if (status != ISC_R_SUCCESS) - parse_warn (cfile, "%s: bad parse.", val); - parse_semi (cfile); - } - return; - - case KEY: - next_token (&val, (unsigned *)0, cfile); - if (ip) { - /* This may seem arbitrary, but there's a reason for - doing it: the authentication key database is not - scoped. If we allow the user to declare a key other - than in the outer scope, the user is very likely to - believe that the key will only be used in that - scope. If the user only wants the key to be used on - one interface, because it's known that the other - interface may be connected to an insecure net and - the secret key is considered sensitive, we don't - want to lull them into believing they've gotten - their way. This is a bit contrived, but people - tend not to be entirely rational about security. */ - parse_warn (cfile, "key definition not allowed here."); - skip_to_semi (cfile); - break; - } - parse_key (cfile); - return; - - /* REQUIRE can either start a policy statement or a - comma-seperated list of names of required options. */ - case REQUIRE: - next_token (&val, (unsigned *)0, cfile); - token = peek_token (&val, (unsigned *)0, cfile); - if (token == AUTHENTICATION) { - policy = P_REQUIRE; - goto do_policy; - } - parse_option_list (cfile, &config -> required_options); - return; - - case IGNORE: - next_token (&val, (unsigned *)0, cfile); - policy = P_IGNORE; - goto do_policy; - - case ACCEPT: - next_token (&val, (unsigned *)0, cfile); - policy = P_ACCEPT; - goto do_policy; - - case PREFER: - next_token (&val, (unsigned *)0, cfile); - policy = P_PREFER; - goto do_policy; - - case DONT: - next_token (&val, (unsigned *)0, cfile); - policy = P_DONT; - goto do_policy; - - do_policy: - token = next_token (&val, (unsigned *)0, cfile); - if (token == AUTHENTICATION) { - if (policy != P_PREFER && - policy != P_REQUIRE && - policy != P_DONT) { - parse_warn (cfile, - "invalid authentication policy."); - skip_to_semi (cfile); - return; - } - config -> auth_policy = policy; - } else if (token != TOKEN_BOOTP) { - if (policy != P_PREFER && - policy != P_IGNORE && - policy != P_ACCEPT) { - parse_warn (cfile, "invalid bootp policy."); - skip_to_semi (cfile); - return; - } - config -> bootp_policy = policy; - } else { - parse_warn (cfile, "expecting a policy type."); - skip_to_semi (cfile); - return; - } - break; - - case OPTION: - token = next_token (&val, (unsigned *)0, cfile); - - token = peek_token (&val, (unsigned *)0, cfile); - if (token == SPACE) { - if (ip) { - parse_warn (cfile, - "option space definitions %s", - " may not be scoped."); - skip_to_semi (cfile); - break; - } - parse_option_space_decl (cfile); - return; - } - - option = parse_option_name (cfile, 1, &known); - if (!option) - return; - - token = next_token (&val, (unsigned *)0, cfile); - if (token != CODE) { - parse_warn (cfile, "expecting \"code\" keyword."); - skip_to_semi (cfile); - free_option (option, MDL); - return; - } - if (ip) { - parse_warn (cfile, - "option definitions may only appear in %s", - "the outermost scope."); - skip_to_semi (cfile); - free_option (option, MDL); - return; - } - if (!parse_option_code_definition (cfile, option)) - free_option (option, MDL); - return; - - case MEDIA: - token = next_token (&val, (unsigned *)0, cfile); - parse_string_list (cfile, &config -> media, 1); - return; - - case HARDWARE: - token = next_token (&val, (unsigned *)0, cfile); - if (ip) { - parse_hardware_param (cfile, &ip -> hw_address); - } else { - parse_warn (cfile, "hardware address parameter %s", - "not allowed here."); - skip_to_semi (cfile); - } - return; - - case REQUEST: - token = next_token (&val, (unsigned *)0, cfile); - if (config -> requested_options == default_requested_options) - config -> requested_options = (u_int32_t *)0; - parse_option_list (cfile, &config -> requested_options); - return; - - case TIMEOUT: - token = next_token (&val, (unsigned *)0, cfile); - parse_lease_time (cfile, &config -> timeout); - return; - - case RETRY: - token = next_token (&val, (unsigned *)0, cfile); - parse_lease_time (cfile, &config -> retry_interval); - return; - - case SELECT_TIMEOUT: - token = next_token (&val, (unsigned *)0, cfile); - parse_lease_time (cfile, &config -> select_interval); - return; - - case OMAPI: - token = next_token (&val, (unsigned *)0, cfile); - token = next_token (&val, (unsigned *)0, cfile); - if (token != PORT) { - parse_warn (cfile, - "unexpected omapi subtype: %s", val); - skip_to_semi (cfile); - return; - } - token = next_token (&val, (unsigned *)0, cfile); - if (token != NUMBER) { - parse_warn (cfile, "invalid port number: `%s'", val); - skip_to_semi (cfile); - return; - } - tmp = atoi (val); - if (tmp < 0 || tmp > 65535) - parse_warn (cfile, "invalid omapi port %d.", tmp); - else if (config != &top_level_config) - parse_warn (cfile, - "omapi port only works at top level."); - else - config -> omapi_port = tmp; - parse_semi (cfile); - return; - - case DO_FORWARD_UPDATE: - token = next_token (&val, (unsigned *)0, cfile); - token = next_token (&val, (unsigned *)0, cfile); - if (!strcasecmp (val, "on") || - !strcasecmp (val, "true")) - config -> do_forward_update = 1; - else if (!strcasecmp (val, "off") || - !strcasecmp (val, "false")) - config -> do_forward_update = 0; - else { - parse_warn (cfile, "expecting boolean value."); - skip_to_semi (cfile); - return; - } - parse_semi (cfile); - return; - - case REBOOT: - token = next_token (&val, (unsigned *)0, cfile); - parse_lease_time (cfile, &config -> reboot_timeout); - return; - - case BACKOFF_CUTOFF: - token = next_token (&val, (unsigned *)0, cfile); - parse_lease_time (cfile, &config -> backoff_cutoff); - return; - - case INITIAL_INTERVAL: - token = next_token (&val, (unsigned *)0, cfile); - parse_lease_time (cfile, &config -> initial_interval); - return; - - case SCRIPT: - token = next_token (&val, (unsigned *)0, cfile); - parse_string (cfile, &config -> script_name, (unsigned *)0); - return; - - case VENDOR: - token = next_token (&val, (unsigned *)0, cfile); - token = next_token (&val, (unsigned *)0, cfile); - if (token != OPTION) { - parse_warn (cfile, "expecting 'vendor option space'"); - skip_to_semi (cfile); - return; - } - token = next_token (&val, (unsigned *)0, cfile); - if (token != SPACE) { - parse_warn (cfile, "expecting 'vendor option space'"); - skip_to_semi (cfile); - return; - } - token = next_token (&val, (unsigned *)0, cfile); - if (!is_identifier (token)) { - parse_warn (cfile, "expecting an identifier."); - skip_to_semi (cfile); - return; - } - config -> vendor_space_name = dmalloc (strlen (val) + 1, MDL); - if (!config -> vendor_space_name) - log_fatal ("no memory for vendor option space name."); - strcpy (config -> vendor_space_name, val); - for (i = 0; i < universe_count; i++) - if (!strcmp (universes [i] -> name, - config -> vendor_space_name)) - break; - if (i == universe_count) { - log_error ("vendor option space %s not found.", - config -> vendor_space_name); - } - parse_semi (cfile); - return; - - case INTERFACE: - token = next_token (&val, (unsigned *)0, cfile); - if (ip) - parse_warn (cfile, "nested interface declaration."); - parse_interface_declaration (cfile, config, (char *)0); - return; - - case PSEUDO: - token = next_token (&val, (unsigned *)0, cfile); - token = next_token (&val, (unsigned *)0, cfile); - name = dmalloc (strlen (val) + 1, MDL); - if (!name) - log_fatal ("no memory for pseudo interface name"); - strcpy (name, val); - parse_interface_declaration (cfile, config, name); - return; - - case LEASE: - token = next_token (&val, (unsigned *)0, cfile); - parse_client_lease_statement (cfile, 1); - return; - - case ALIAS: - token = next_token (&val, (unsigned *)0, cfile); - parse_client_lease_statement (cfile, 2); - return; - - case REJECT: - token = next_token (&val, (unsigned *)0, cfile); - parse_reject_statement (cfile, config); - return; - - default: - lose = 0; - stmt = (struct executable_statement *)0; - if (!parse_executable_statement (&stmt, - cfile, &lose, context_any)) { - if (!lose) { - parse_warn (cfile, "expecting a statement."); - skip_to_semi (cfile); - } - } else { - struct executable_statement **eptr, *sptr; - if (stmt && - (stmt -> op == send_option_statement || - (stmt -> op == on_statement && - (stmt -> data.on.evtypes & ON_TRANSMISSION)))) { - eptr = &config -> on_transmission -> statements; - if (stmt -> op == on_statement) { - sptr = (struct executable_statement *)0; - executable_statement_reference - (&sptr, - stmt -> data.on.statements, MDL); - executable_statement_dereference (&stmt, - MDL); - executable_statement_reference (&stmt, - sptr, - MDL); - executable_statement_dereference (&sptr, - MDL); - } - } else - eptr = &config -> on_receipt -> statements; - - if (stmt) { - for (; *eptr; eptr = &(*eptr) -> next) - ; - executable_statement_reference (eptr, - stmt, MDL); - } - return; - } - break; - } - parse_semi (cfile); -} - -/* option-list :== option_name | - option_list COMMA option_name */ - -void parse_option_list (cfile, list) - struct parse *cfile; - u_int32_t **list; -{ - int ix; - int token; - const char *val; - pair p = (pair)0, q = (pair)0, r; - struct option *option; - - ix = 0; - do { - token = peek_token (&val, (unsigned *)0, cfile); - if (token == SEMI) { - token = next_token (&val, (unsigned *)0, cfile); - break; - } - if (!is_identifier (token)) { - parse_warn (cfile, "%s: expected option name.", val); - token = next_token (&val, (unsigned *)0, cfile); - skip_to_semi (cfile); - return; - } - option = parse_option_name (cfile, 0, NULL); - if (!option) { - parse_warn (cfile, "%s: expected option name.", val); - return; - } - if (option -> universe != &dhcp_universe) { - parse_warn (cfile, - "%s.%s: Only global options allowed.", - option -> universe -> name, option->name ); - skip_to_semi (cfile); - return; - } - r = new_pair (MDL); - if (!r) - log_fatal ("can't allocate pair for option code."); - r -> car = (caddr_t)(long)option -> code; - r -> cdr = (pair)0; - if (p) - q -> cdr = r; - else - p = r; - q = r; - ++ix; - token = next_token (&val, (unsigned *)0, cfile); - } while (token == COMMA); - if (token != SEMI) { - parse_warn (cfile, "expecting semicolon."); - skip_to_semi (cfile); - return; - } - /* XXX we can't free the list here, because we may have copied - XXX it from an outer config state. */ - *list = (u_int32_t *)0; - if (ix) { - *list = dmalloc ((ix + 1) * sizeof **list, MDL); - if (!*list) - log_error ("no memory for option list."); - else { - ix = 0; - for (q = p; q; q = q -> cdr) - (*list) [ix++] = (u_int32_t)(long)q -> car; - (*list) [ix] = 0; - } - while (p) { - q = p -> cdr; - free_pair (p, MDL); - p = q; - } - } -} - -/* interface-declaration :== - INTERFACE string LBRACE client-declarations RBRACE */ - -void parse_interface_declaration (cfile, outer_config, name) - struct parse *cfile; - struct client_config *outer_config; - char *name; -{ - int token; - const char *val; - struct client_state *client, **cp; - struct interface_info *ip = (struct interface_info *)0; - - token = next_token (&val, (unsigned *)0, cfile); - if (token != STRING) { - parse_warn (cfile, "expecting interface name (in quotes)."); - skip_to_semi (cfile); - return; - } - - if (!interface_or_dummy (&ip, val)) - log_fatal ("Can't allocate interface %s.", val); - - /* If we were given a name, this is a pseudo-interface. */ - if (name) { - make_client_state (&client); - client -> name = name; - client -> interface = ip; - for (cp = &ip -> client; *cp; cp = &((*cp) -> next)) - ; - *cp = client; - } else { - if (!ip -> client) { - make_client_state (&ip -> client); - ip -> client -> interface = ip; - } - client = ip -> client; - } - - if (!client -> config) - make_client_config (client, outer_config); - - ip -> flags &= ~INTERFACE_AUTOMATIC; - interfaces_requested = 1; - - token = next_token (&val, (unsigned *)0, cfile); - if (token != LBRACE) { - parse_warn (cfile, "expecting left brace."); - skip_to_semi (cfile); - return; - } - - do { - token = peek_token (&val, (unsigned *)0, cfile); - if (token == END_OF_FILE) { - parse_warn (cfile, - "unterminated interface declaration."); - return; - } - if (token == RBRACE) - break; - parse_client_statement (cfile, ip, client -> config); - } while (1); - token = next_token (&val, (unsigned *)0, cfile); -} - -int interface_or_dummy (struct interface_info **pi, const char *name) -{ - struct interface_info *i; - struct interface_info *ip = (struct interface_info *)0; - isc_result_t status; - - /* Find the interface (if any) that matches the name. */ - for (i = interfaces; i; i = i -> next) { - if (!strcmp (i -> name, name)) { - interface_reference (&ip, i, MDL); - break; - } - } - - /* If it's not a real interface, see if it's on the dummy list. */ - if (!ip) { - for (ip = dummy_interfaces; ip; ip = ip -> next) { - if (!strcmp (ip -> name, name)) { - interface_reference (&ip, i, MDL); - break; - } - } - } - - /* If we didn't find an interface, make a dummy interface as - a placeholder. */ - if (!ip) { - if ((status = interface_allocate (&ip, MDL)) != ISC_R_SUCCESS) - log_fatal ("Can't record interface %s: %s", - name, isc_result_totext (status)); - strcpy (ip -> name, name); - if (dummy_interfaces) { - interface_reference (&ip -> next, - dummy_interfaces, MDL); - interface_dereference (&dummy_interfaces, MDL); - } - interface_reference (&dummy_interfaces, ip, MDL); - } - if (pi) - status = interface_reference (pi, ip, MDL); - else - status = ISC_R_FAILURE; - interface_dereference (&ip, MDL); - if (status != ISC_R_SUCCESS) - return 0; - return 1; -} - -void make_client_state (state) - struct client_state **state; -{ - *state = ((struct client_state *)dmalloc (sizeof **state, MDL)); - if (!*state) - log_fatal ("no memory for client state\n"); - memset (*state, 0, sizeof **state); -} - -void make_client_config (client, config) - struct client_state *client; - struct client_config *config; -{ - client -> config = (((struct client_config *) - dmalloc (sizeof (struct client_config), MDL))); - if (!client -> config) - log_fatal ("no memory for client config\n"); - memcpy (client -> config, config, sizeof *config); - if (!clone_group (&client -> config -> on_receipt, - config -> on_receipt, MDL) || - !clone_group (&client -> config -> on_transmission, - config -> on_transmission, MDL)) - log_fatal ("no memory for client state groups."); -} - -/* client-lease-statement :== - RBRACE client-lease-declarations LBRACE - - client-lease-declarations :== - | - client-lease-declaration | - client-lease-declarations client-lease-declaration */ - - -void parse_client_lease_statement (cfile, is_static) - struct parse *cfile; - int is_static; -{ - struct client_lease *lease, *lp, *pl, *next; - struct interface_info *ip = (struct interface_info *)0; - int token; - const char *val; - struct client_state *client = (struct client_state *)0; - - token = next_token (&val, (unsigned *)0, cfile); - if (token != LBRACE) { - parse_warn (cfile, "expecting left brace."); - skip_to_semi (cfile); - return; - } - - lease = ((struct client_lease *) - dmalloc (sizeof (struct client_lease), MDL)); - if (!lease) - log_fatal ("no memory for lease.\n"); - memset (lease, 0, sizeof *lease); - lease -> is_static = is_static; - if (!option_state_allocate (&lease -> options, MDL)) - log_fatal ("no memory for lease options.\n"); - - do { - token = peek_token (&val, (unsigned *)0, cfile); - if (token == END_OF_FILE) { - parse_warn (cfile, "unterminated lease declaration."); - return; - } - if (token == RBRACE) - break; - parse_client_lease_declaration (cfile, lease, &ip, &client); - } while (1); - token = next_token (&val, (unsigned *)0, cfile); - - /* If the lease declaration didn't include an interface - declaration that we recognized, it's of no use to us. */ - if (!ip) { - destroy_client_lease (lease); - return; - } - - /* Make sure there's a client state structure... */ - if (!ip -> client) { - make_client_state (&ip -> client); - ip -> client -> interface = ip; - } - if (!client) - client = ip -> client; - - /* If this is an alias lease, it doesn't need to be sorted in. */ - if (is_static == 2) { - ip -> client -> alias = lease; - return; - } - - /* The new lease may supersede a lease that's not the - active lease but is still on the lease list, so scan the - lease list looking for a lease with the same address, and - if we find it, toss it. */ - pl = (struct client_lease *)0; - for (lp = client -> leases; lp; lp = next) { - next = lp -> next; - if (lp -> address.len == lease -> address.len && - !memcmp (lp -> address.iabuf, lease -> address.iabuf, - lease -> address.len)) { - if (pl) - pl -> next = next; - else - client -> leases = next; - destroy_client_lease (lp); - break; - } else - pl = lp; - } - - /* If this is a preloaded lease, just put it on the list of recorded - leases - don't make it the active lease. */ - if (is_static) { - lease -> next = client -> leases; - client -> leases = lease; - return; - } - - /* The last lease in the lease file on a particular interface is - the active lease for that interface. Of course, we don't know - what the last lease in the file is until we've parsed the whole - file, so at this point, we assume that the lease we just parsed - is the active lease for its interface. If there's already - an active lease for the interface, and this lease is for the same - ip address, then we just toss the old active lease and replace - it with this one. If this lease is for a different address, - then if the old active lease has expired, we dump it; if not, - we put it on the list of leases for this interface which are - still valid but no longer active. */ - if (client -> active) { - if (client -> active -> expiry < cur_time) - destroy_client_lease (client -> active); - else if (client -> active -> address.len == - lease -> address.len && - !memcmp (client -> active -> address.iabuf, - lease -> address.iabuf, - lease -> address.len)) - destroy_client_lease (client -> active); - else { - client -> active -> next = client -> leases; - client -> leases = client -> active; - } - } - client -> active = lease; - - /* phew. */ -} - -/* client-lease-declaration :== - BOOTP | - INTERFACE string | - FIXED_ADDR ip_address | - FILENAME string | - SERVER_NAME string | - OPTION option-decl | - RENEW time-decl | - REBIND time-decl | - EXPIRE time-decl | - KEY id */ - -void parse_client_lease_declaration (cfile, lease, ipp, clientp) - struct parse *cfile; - struct client_lease *lease; - struct interface_info **ipp; - struct client_state **clientp; -{ - int token; - const char *val; - char *t, *n; - struct interface_info *ip; - struct option_cache *oc; - struct client_state *client = (struct client_state *)0; - struct data_string key_id; - - switch (next_token (&val, (unsigned *)0, cfile)) { - case KEY: - token = next_token (&val, (unsigned *)0, cfile); - if (token != STRING && !is_identifier (token)) { - parse_warn (cfile, "expecting key name."); - skip_to_semi (cfile); - break; - } - if (omapi_auth_key_lookup_name (&lease -> key, val) != - ISC_R_SUCCESS) - parse_warn (cfile, "unknown key %s", val); - parse_semi (cfile); - break; - case TOKEN_BOOTP: - lease -> is_bootp = 1; - break; - - case INTERFACE: - token = next_token (&val, (unsigned *)0, cfile); - if (token != STRING) { - parse_warn (cfile, - "expecting interface name (in quotes)."); - skip_to_semi (cfile); - break; - } - interface_or_dummy (ipp, val); - break; - - case NAME: - token = next_token (&val, (unsigned *)0, cfile); - ip = *ipp; - if (!ip) { - parse_warn (cfile, "state name precedes interface."); - break; - } - for (client = ip -> client; client; client = client -> next) - if (client -> name && !strcmp (client -> name, val)) - break; - if (!client) - parse_warn (cfile, - "lease specified for unknown pseudo."); - *clientp = client; - break; - - case FIXED_ADDR: - if (!parse_ip_addr (cfile, &lease -> address)) - return; - break; - - case MEDIUM: - parse_string_list (cfile, &lease -> medium, 0); - return; - - case FILENAME: - parse_string (cfile, &lease -> filename, (unsigned *)0); - return; - - case SERVER_NAME: - parse_string (cfile, &lease -> server_name, (unsigned *)0); - return; - - case RENEW: - lease -> renewal = parse_date (cfile); - return; - - case REBIND: - lease -> rebind = parse_date (cfile); - return; - - case EXPIRE: - lease -> expiry = parse_date (cfile); - return; - - case OPTION: - oc = (struct option_cache *)0; - if (parse_option_decl (&oc, cfile)) { - save_option (oc -> option -> universe, - lease -> options, oc); - option_cache_dereference (&oc, MDL); - } - return; - - default: - parse_warn (cfile, "expecting lease declaration."); - skip_to_semi (cfile); - break; - } - token = next_token (&val, (unsigned *)0, cfile); - if (token != SEMI) { - parse_warn (cfile, "expecting semicolon."); - skip_to_semi (cfile); - } -} - -void parse_string_list (cfile, lp, multiple) - struct parse *cfile; - struct string_list **lp; - int multiple; -{ - int token; - const char *val; - struct string_list *cur, *tmp; - - /* Find the last medium in the media list. */ - if (*lp) { - for (cur = *lp; cur -> next; cur = cur -> next) - ; - } else { - cur = (struct string_list *)0; - } - - do { - token = next_token (&val, (unsigned *)0, cfile); - if (token != STRING) { - parse_warn (cfile, "Expecting media options."); - skip_to_semi (cfile); - return; - } - - tmp = ((struct string_list *) - dmalloc (strlen (val) + sizeof (struct string_list), - MDL)); - if (!tmp) - log_fatal ("no memory for string list entry."); - - strcpy (tmp -> string, val); - tmp -> next = (struct string_list *)0; - - /* Store this medium at the end of the media list. */ - if (cur) - cur -> next = tmp; - else - *lp = tmp; - cur = tmp; - - token = next_token (&val, (unsigned *)0, cfile); - } while (multiple && token == COMMA); - - if (token != SEMI) { - parse_warn (cfile, "expecting semicolon."); - skip_to_semi (cfile); - } -} - -void parse_reject_statement (cfile, config) - struct parse *cfile; - struct client_config *config; -{ - int token; - const char *val; - struct iaddr addr; - struct iaddrlist *list; - - do { - if (!parse_ip_addr (cfile, &addr)) { - parse_warn (cfile, "expecting IP address."); - skip_to_semi (cfile); - return; - } - - list = (struct iaddrlist *)dmalloc (sizeof (struct iaddrlist), - MDL); - if (!list) - log_fatal ("no memory for reject list!"); - - list -> addr = addr; - list -> next = config -> reject_list; - config -> reject_list = list; - - token = next_token (&val, (unsigned *)0, cfile); - } while (token == COMMA); - - if (token != SEMI) { - parse_warn (cfile, "expecting semicolon."); - skip_to_semi (cfile); - } -} - -/* allow-deny-keyword :== BOOTP - | BOOTING - | DYNAMIC_BOOTP - | UNKNOWN_CLIENTS */ - -int parse_allow_deny (oc, cfile, flag) - struct option_cache **oc; - struct parse *cfile; - int flag; -{ - enum dhcp_token token; - const char *val; - unsigned char rf = flag; - struct expression *data = (struct expression *)0; - int status; - - parse_warn (cfile, "allow/deny/ignore not permitted here."); - skip_to_semi (cfile); - return 0; -} - diff --git a/contrib/dhcp-3.0/client/dhclient-script.8 b/contrib/dhcp-3.0/client/dhclient-script.8 deleted file mode 100644 index d81cf41..0000000 --- a/contrib/dhcp-3.0/client/dhclient-script.8 +++ /dev/null @@ -1,221 +0,0 @@ -.\" dhclient-script.8 -.\" -.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") -.\" Copyright (c) 1996-2003 by Internet Software Consortium -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.\" Internet Systems Consortium, Inc. -.\" 950 Charter Street -.\" Redwood City, CA 94063 -.\" -.\" http://www.isc.org/ -.\" -.\" This software has been written for Internet Systems Consortium -.\" by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. -.\" To learn more about Internet Systems Consortium, see -.\" ``http://www.isc.org/''. To learn more about Vixie Enterprises, -.\" see ``http://www.vix.com''. To learn more about Nominum, Inc., see -.\" ``http://www.nominum.com''. -.\" -.\" $Id: dhclient-script.8,v 1.8.2.5 2004/06/10 17:59:12 dhankins Exp $ -.\" -.TH dhclient-script 8 -.SH NAME -dhclient-script - DHCP client network configuration script -.SH DESCRIPTION -The DHCP client network configuration script is invoked from time to -time by \fBdhclient(8)\fR. This script is used by the dhcp client to -set each interface's initial configuration prior to requesting an -address, to test the address once it has been offered, and to set the -interface's final configuration once a lease has been acquired. If no -lease is acquired, the script is used to test predefined leases, if -any, and also called once if no valid lease can be identified. -.PP -This script is not meant to be customized by the end user. If local -customizations are needed, they should be possible using the enter and -exit hooks provided (see HOOKS for details). These hooks will allow the -user to override the default behaviour of the client in creating a -.B /etc/resolv.conf -file. -.PP -No standard client script exists for some operating systems, even though -the actual client may work, so a pioneering user may well need to create -a new script or modify an existing one. In general, customizations specific -to a particular computer should be done in the -.B ETCDIR/dhclient.conf -file. If you find that you can't make such a customization without -customizing -.B ETCDIR/dhclient.conf -or using the enter and exit hooks, please submit a bug report. -.SH HOOKS -When it starts, the client script first defines a shell function, -.B make_resolv_conf , -which is later used to create the -.B /etc/resolv.conf -file. To override the default behaviour, redefine this function in -the enter hook script. -.PP -On after defining the make_resolv_conf function, the client script checks -for the presence of an executable -.B ETCDIR/dhclient-enter-hooks -script, and if present, it invokes the script inline, using the Bourne -shell '.' command. The entire environment documented under OPERATION -is available to this script, which may modify the environment if needed -to change the behaviour of the script. If an error occurs during the -execution of the script, it can set the exit_status variable to a nonzero -value, and -.B CLIENTBINDIR/dhclient-script -will exit with that error code immediately after the client script exits. -.PP -After all processing has completed, -.B CLIENTBINDIR/dhclient-script -checks for the presence of an executable -.B ETCDIR/dhclient-exit-hooks -script, which if present is invoked using the '.' command. The exit -status of dhclient-script will be passed to dhclient-exit-hooks in the -exit_status shell variable, and will always be zero if the script -succeeded at the task for which it was invoked. The rest of the -environment as described previously for dhclient-enter-hooks is also -present. The -.B ETCDIR/dhclient-exit-hooks -script can modify the valid of exit_status to change the exit status -of dhclient-script. -.SH OPERATION -When dhclient needs to invoke the client configuration script, it -defines a set of variables in the environment, and then invokes -.B CLIENTBINDIR/dhclient-script. -In all cases, $reason is set to the name of the reason why the script -has been invoked. The following reasons are currently defined: -MEDIUM, PREINIT, BOUND, RENEW, REBIND, REBOOT, EXPIRE, FAIL and TIMEOUT. -.PP -.SH MEDIUM -The DHCP client is requesting that an interface's media type -be set. The interface name is passed in $interface, and the media -type is passed in $medium. -.SH PREINIT -The DHCP client is requesting that an interface be configured as -required in order to send packets prior to receiving an actual -address. For clients which use the BSD socket library, this means -configuring the interface with an IP address of 0.0.0.0 and a -broadcast address of 255.255.255.255. For other clients, it may be -possible to simply configure the interface up without actually giving -it an IP address at all. The interface name is passed in $interface, -and the media type in $medium. -.PP -If an IP alias has been declared in dhclient.conf, its address will be -passed in $alias_ip_address, and that ip alias should be deleted from -the interface, along with any routes to it. -.SH BOUND -The DHCP client has done an initial binding to a new address. The -new ip address is passed in $new_ip_address, and the interface name is -passed in $interface. The media type is passed in $medium. Any -options acquired from the server are passed using the option name -described in \fBdhcp-options\fR, except that dashes ('-') are replaced -by underscores ('_') in order to make valid shell variables, and the -variable names start with new_. So for example, the new subnet mask -would be passed in $new_subnet_mask. -.PP -Before actually configuring the address, dhclient-script should -somehow ARP for it and exit with a nonzero status if it receives a -reply. In this case, the client will send a DHCPDECLINE message to -the server and acquire a different address. This may also be done in -the RENEW, REBIND, or REBOOT states, but is not required, and indeed -may not be desirable. -.PP -When a binding has been completed, a lot of network parameters are -likely to need to be set up. A new /etc/resolv.conf needs to be -created, using the values of $new_domain_name and -$new_domain_name_servers (which may list more than one server, -separated by spaces). A default route should be set using -$new_routers, and static routes may need to be set up using -$new_static_routes. -.PP -If an IP alias has been declared, it must be set up here. The alias -IP address will be written as $alias_ip_address, and other DHCP -options that are set for the alias (e.g., subnet mask) will be passed -in variables named as described previously except starting with -$alias_ instead of $new_. Care should be taken that the alias IP -address not be used if it is identical to the bound IP address -($new_ip_address), since the other alias parameters may be incorrect -in this case. -.SH RENEW -When a binding has been renewed, the script is called as in BOUND, -except that in addition to all the variables starting with $new_, -there is another set of variables starting with $old_. Persistent -settings that may have changed need to be deleted - for example, if a -local route to the bound address is being configured, the old local -route should be deleted. If the default route has changed, the old default -route should be deleted. If the static routes have changed, the old -ones should be deleted. Otherwise, processing can be done as with -BOUND. -.SH REBIND -The DHCP client has rebound to a new DHCP server. This can be handled -as with RENEW, except that if the IP address has changed, the ARP -table should be cleared. -.SH REBOOT -The DHCP client has successfully reacquired its old address after a -reboot. This can be processed as with BOUND. -.SH EXPIRE -The DHCP client has failed to renew its lease or acquire a new one, -and the lease has expired. The IP address must be relinquished, and -all related parameters should be deleted, as in RENEW and REBIND. -.SH FAIL -The DHCP client has been unable to contact any DHCP servers, and any -leases that have been tested have not proved to be valid. The -parameters from the last lease tested should be deconfigured. This -can be handled in the same way as EXPIRE. -.SH TIMEOUT -The DHCP client has been unable to contact any DHCP servers. -However, an old lease has been identified, and its parameters have -been passed in as with BOUND. The client configuration script should -test these parameters and, if it has reason to believe they are valid, -should exit with a value of zero. If not, it should exit with a -nonzero value. -.PP -The usual way to test a lease is to set up the network as with REBIND -(since this may be called to test more than one lease) and then ping -the first router defined in $routers. If a response is received, the -lease must be valid for the network to which the interface is -currently connected. It would be more complete to try to ping all of -the routers listed in $new_routers, as well as those listed in -$new_static_routes, but current scripts do not do this. -.SH FILES -Each operating system should generally have its own script file, -although the script files for similar operating systems may be similar -or even identical. The script files included in Internet -Systems Consortium DHCP distribution appear in the distribution tree -under client/scripts, and bear the names of the operating systems on -which they are intended to work. -.SH BUGS -If more than one interface is being used, there's no obvious way to -avoid clashes between server-supplied configuration parameters - for -example, the stock dhclient-script rewrites /etc/resolv.conf. If -more than one interface is being configured, /etc/resolv.conf will be -repeatedly initialized to the values provided by one server, and then -the other. Assuming the information provided by both servers is -valid, this shouldn't cause any real problems, but it could be -confusing. -.SH SEE ALSO -dhclient(8), dhcpd(8), dhcrelay(8), dhclient.conf(5) and -dhclient.leases(5). -.SH AUTHOR -.B dhclient-script(8) -has been written for Internet Systems Consortium -by Ted Lemon in cooperation with Vixie -Enterprises. To learn more about Internet Systems Consortium, -see -.B http://www.isc.org. -To learn more about Vixie -Enterprises, see -.B http://www.vix.com. diff --git a/contrib/dhcp-3.0/client/dhclient.8 b/contrib/dhcp-3.0/client/dhclient.8 deleted file mode 100644 index 01d1368..0000000 --- a/contrib/dhcp-3.0/client/dhclient.8 +++ /dev/null @@ -1,319 +0,0 @@ -.\" dhclient.8 -.\" -.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") -.\" Copyright (c) 1996-2003 by Internet Software Consortium -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.\" Internet Systems Consortium, Inc. -.\" 950 Charter Street -.\" Redwood City, CA 94063 -.\" -.\" http://www.isc.org/ -.\" -.\" $Id: dhclient.8,v 1.12.2.9 2004/09/29 23:01:46 dhankins Exp $ -.\" -.TH dhclient 8 -.SH NAME -dhclient - Dynamic Host Configuration Protocol Client -.SH SYNOPSIS -.B dhclient -[ -.B -p -.I port -] -[ -.B -d -] -[ -.B -q -] -[ -.B -1 -] -[ -.B -r -] -[ -.B -lf -.I lease-file -] -[ -.B -pf -.I pid-file -] -[ -.B -cf -.I config-file -] -[ -.B -sf -.I script-file -] -[ -.B -s -server -] -[ -.B -g -relay -] -[ -.B -n -] -[ -.B -nw -] -[ -.B -w -] -[ -.I if0 -[ -.I ...ifN -] -] -.SH DESCRIPTION -The Internet Systems Consortium DHCP Client, dhclient, provides a -means for configuring one or more network interfaces using the Dynamic -Host Configuration Protocol, BOOTP protocol, or if these protocols -fail, by statically assigning an address. -.SH OPERATION -.PP -The DHCP protocol allows a host to contact a central server which -maintains a list of IP addresses which may be assigned on one or more -subnets. A DHCP client may request an address from this pool, and -then use it on a temporary basis for communication on network. The -DHCP protocol also provides a mechanism whereby a client can learn -important details about the network to which it is attached, such as -the location of a default router, the location of a name server, and -so on. -.PP -On startup, dhclient reads the -.IR dhclient.conf -for configuration instructions. It then gets a list of all the -network interfaces that are configured in the current system. For -each interface, it attempts to configure the interface using the DHCP -protocol. -.PP -In order to keep track of leases across system reboots and server -restarts, dhclient keeps a list of leases it has been assigned in the -dhclient.leases(5) file. On startup, after reading the dhclient.conf -file, dhclient reads the dhclient.leases file to refresh its memory -about what leases it has been assigned. -.PP -When a new lease is acquired, it is appended to the end of the -dhclient.leases file. In order to prevent the file from becoming -arbitrarily large, from time to time dhclient creates a new -dhclient.leases file from its in-core lease database. The old version -of the dhclient.leases file is retained under the name -.IR dhclient.leases~ -until the next time dhclient rewrites the database. -.PP -Old leases are kept around in case the DHCP server is unavailable when -dhclient is first invoked (generally during the initial system boot -process). In that event, old leases from the dhclient.leases file -which have not yet expired are tested, and if they are determined to -be valid, they are used until either they expire or the DHCP server -becomes available. -.PP -A mobile host which may sometimes need to access a network on which no -DHCP server exists may be preloaded with a lease for a fixed -address on that network. When all attempts to contact a DHCP server -have failed, dhclient will try to validate the static lease, and if it -succeeds, will use that lease until it is restarted. -.PP -A mobile host may also travel to some networks on which DHCP is not -available but BOOTP is. In that case, it may be advantageous to -arrange with the network administrator for an entry on the BOOTP -database, so that the host can boot quickly on that network rather -than cycling through the list of old leases. -.SH COMMAND LINE -.PP -The names of the network interfaces that dhclient should attempt to -configure may be specified on the command line. If no interface names -are specified on the command line dhclient will normally identify all -network interfaces, eliminating non-broadcast interfaces if -possible, and attempt to configure each interface. -.PP -It is also possible to specify interfaces by name in the -.B dhclient.conf(5) -file. If interfaces are specified in this way, then the client will -only configure interfaces that are either specified in the -configuration file or on the command line, and will ignore all other -interfaces. -.PP -If the DHCP client should listen and transmit on a port other than the -standard (port 68), the -.B -p -flag may used. It should be followed by the udp port number that -dhclient should use. This is mostly useful for debugging purposes. -If a different port is specified for the client to listen on and -transmit on, the client will also use a different destination port - -one greater than the specified destination port. -.PP -The DHCP client normally transmits any protocol messages it sends -before acquiring an IP address to, 255.255.255.255, the IP limited -broadcast address. For debugging purposes, it may be useful to have -the server transmit these messages to some other address. This can -be specified with the -.B -s -flag, followed by the IP address or domain name of the destination. -.PP -For testing purposes, the giaddr field of all packets that the client -sends can be set using the -.B -g -flag, followed by the IP address to send. This is only useful for testing, -and should not be expected to work in any consistent or useful way. -.PP -The DHCP client will normally run in the foreground until it has -configured an interface, and then will revert to running in the -background. To run force dhclient to always run as a foreground -process, the -.B -d -flag should be specified. This is useful when running the client -under a debugger, or when running it out of inittab on System V -systems. -.PP -The client normally prints a startup message and displays the -protocol sequence to the standard error descriptor until it has -acquired an address, and then only logs messages using the -.B syslog (3) -facility. The -.B -q -flag prevents any messages other than errors from being printed to the -standard error descriptor. -.PP -The client normally doesn't release the current lease as it is not -required by the DHCP protocol. Some cable ISPs require their clients -to notify the server if they wish to release an assigned IP address. -The -.B -r -flag explicitly releases the current lease, and once the lease has been -released, the client exits. -.PP -The -.B -1 -flag cause dhclient to try once to get a lease. If it fails, dhclient exits -with exit code two. -.PP -The DHCP client normally gets its configuration information from -.B ETCDIR/dhclient.conf, -its lease database from -.B DBDIR/dhclient.leases, -stores its process ID in a file called -.B RUNDIR/dhclient.pid, -and configures the network interface using -.B CLIENTBINDIR/dhclient-script -To specify different names and/or locations for these files, use the -.B -cf, -.B -lf, -.B -pf -and -.B -sf -flags, respectively, followed by the name of the file. This can be -particularly useful if, for example, -.B DBDIR -or -.B RUNDIR -has not yet been mounted when the DHCP client is started. -.PP -The DHCP client normally exits if it isn't able to identify any -network interfaces to configure. On laptop computers and other -computers with hot-swappable I/O buses, it is possible that a -broadcast interface may be added after system startup. The -.B -w -flag can be used to cause the client not to exit when it doesn't find -any such interfaces. The -.B omshell (8) -program can then be used to notify the client when a network interface -has been added or removed, so that the client can attempt to configure an IP -address on that interface. -.PP -The DHCP client can be directed not to attempt to configure any interfaces -using the -.B -n -flag. This is most likely to be useful in combination with the -.B -w -flag. -.PP -The client can also be instructed to become a daemon immediately, rather -than waiting until it has acquired an IP address. This can be done by -supplying the -.B -nw -flag. -.SH CONFIGURATION -The syntax of the dhclient.conf(5) file is discussed separately. -.SH OMAPI -The DHCP client provides some ability to control it while it is -running, without stopping it. This capability is provided using OMAPI, -an API for manipulating remote objects. OMAPI clients connect to the -client using TCP/IP, authenticate, and can then examine the client's -current status and make changes to it. -.PP -Rather than implementing the underlying OMAPI protocol directly, user -programs should use the dhcpctl API or OMAPI itself. Dhcpctl is a -wrapper that handles some of the housekeeping chores that OMAPI does -not do automatically. Dhcpctl and OMAPI are documented in \fBdhcpctl(3)\fR -and \fBomapi(3)\fR. Most things you'd want to do with the client can -be done directly using the \fBomshell(1)\fR command, rather than -having to write a special program. -.SH THE CONTROL OBJECT -The control object allows you to shut the client down, releasing all -leases that it holds and deleting any DNS records it may have added. -It also allows you to pause the client - this unconfigures any -interfaces the client is using. You can then restart it, which -causes it to reconfigure those interfaces. You would normally pause -the client prior to going into hibernation or sleep on a laptop -computer. You would then resume it after the power comes back. -This allows PC cards to be shut down while the computer is hibernating -or sleeping, and then reinitialized to their previous state once the -computer comes out of hibernation or sleep. -.PP -The control object has one attribute - the state attribute. To shut -the client down, set its state attribute to 2. It will automatically -do a DHCPRELEASE. To pause it, set its state attribute to 3. To -resume it, set its state attribute to 4. -.PP -.SH FILES -.B CLIENTBINDIR/dhclient-script, -.B ETCDIR/dhclient.conf, DBDIR/dhclient.leases, RUNDIR/dhclient.pid, -.B DBDIR/dhclient.leases~. -.SH SEE ALSO -dhcpd(8), dhcrelay(8), dhclient-script(8), dhclient.conf(5), -dhclient.leases(5). -.SH AUTHOR -.B dhclient(8) -has been written for Internet Systems Consortium -by Ted Lemon in cooperation with Vixie -Enterprises. To learn more about Internet Systems Consortium, -see -.B http://www.isc.org -To learn more about Vixie -Enterprises, see -.B http://www.vix.com. -.PP -This client was substantially modified and enhanced by Elliot Poger -for use on Linux while he was working on the MosquitoNet project at -Stanford. -.PP -The current version owes much to Elliot's Linux enhancements, but -was substantially reorganized and partially rewritten by Ted Lemon -so as to use the same networking framework that the Internet Systems -Consortium DHCP server uses. Much system-specific configuration code -was moved into a shell script so that as support for more operating -systems is added, it will not be necessary to port and maintain -system-specific configuration code to these operating systems - instead, -the shell script can invoke the native tools to accomplish the same -purpose. -.PP diff --git a/contrib/dhcp-3.0/client/dhclient.c b/contrib/dhcp-3.0/client/dhclient.c deleted file mode 100644 index 709c507..0000000 --- a/contrib/dhcp-3.0/client/dhclient.c +++ /dev/null @@ -1,3162 +0,0 @@ -/* dhclient.c - - DHCP Client. */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1995-2003 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Internet Systems Consortium, Inc. - * 950 Charter Street - * Redwood City, CA 94063 - * - * http://www.isc.org/ - * - * This code is based on the original client state machine that was - * written by Elliot Poger. The code has been extensively hacked on - * by Ted Lemon since then, so any mistakes you find are probably his - * fault and not Elliot's. - */ - -#ifndef lint -static char ocopyright[] = -"$Id: dhclient.c,v 1.129.2.23 2004/11/24 17:39:14 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" -#include "version.h" - -TIME default_lease_time = 43200; /* 12 hours... */ -TIME max_lease_time = 86400; /* 24 hours... */ - -const char *path_dhclient_conf = _PATH_DHCLIENT_CONF; -const char *path_dhclient_db = _PATH_DHCLIENT_DB; -const char *path_dhclient_pid = _PATH_DHCLIENT_PID; -static char path_dhclient_script_array [] = _PATH_DHCLIENT_SCRIPT; -char *path_dhclient_script = path_dhclient_script_array; - -int dhcp_max_agent_option_packet_length = 0; - -int interfaces_requested = 0; - -struct iaddr iaddr_broadcast = { 4, { 255, 255, 255, 255 } }; -struct iaddr iaddr_any = { 4, { 0, 0, 0, 0 } }; -struct in_addr inaddr_any; -struct sockaddr_in sockaddr_broadcast; -struct in_addr giaddr; - -/* ASSERT_STATE() does nothing now; it used to be - assert (state_is == state_shouldbe). */ -#define ASSERT_STATE(state_is, state_shouldbe) {} - -static char copyright[] = "Copyright 2004 Internet Systems Consortium."; -static char arr [] = "All rights reserved."; -static char message [] = "Internet Systems Consortium DHCP Client"; -static char url [] = "For info, please visit http://www.isc.org/products/DHCP"; - -u_int16_t local_port=0; -u_int16_t remote_port=0; -int no_daemon=0; -struct string_list *client_env=NULL; -int client_env_count=0; -int onetry=0; -int quiet=0; -int nowait=0; - -static void usage PROTO ((void)); - -void do_release(struct client_state *); - -int main (argc, argv, envp) - int argc; - char **argv, **envp; -{ - int i; - struct servent *ent; - struct interface_info *ip; - struct client_state *client; - unsigned seed; - char *server = (char *)0; - char *relay = (char *)0; - isc_result_t status; - int release_mode = 0; - omapi_object_t *listener; - isc_result_t result; - int persist = 0; - int omapi_port; - int no_dhclient_conf = 0; - int no_dhclient_db = 0; - int no_dhclient_pid = 0; - int no_dhclient_script = 0; - char *s; - - /* Make sure we have stdin, stdout and stderr. */ - i = open ("/dev/null", O_RDWR); - if (i == 0) - i = open ("/dev/null", O_RDWR); - if (i == 1) { - i = open ("/dev/null", O_RDWR); - log_perror = 0; /* No sense logging to /dev/null. */ - } else if (i != -1) - close (i); - -#ifdef SYSLOG_4_2 - openlog ("dhclient", LOG_NDELAY); - log_priority = LOG_DAEMON; -#else - openlog ("dhclient", LOG_NDELAY, LOG_DAEMON); -#endif - -#if !(defined (DEBUG) || defined (SYSLOG_4_2) || defined (__CYGWIN32__)) - setlogmask (LOG_UPTO (LOG_INFO)); -#endif - - /* Set up the OMAPI. */ - status = omapi_init (); - if (status != ISC_R_SUCCESS) - log_fatal ("Can't initialize OMAPI: %s", - isc_result_totext (status)); - - /* Set up the OMAPI wrappers for various server database internal - objects. */ - dhcp_common_objects_setup (); - - dhcp_interface_discovery_hook = dhclient_interface_discovery_hook; - dhcp_interface_shutdown_hook = dhclient_interface_shutdown_hook; - dhcp_interface_startup_hook = dhclient_interface_startup_hook; - - for (i = 1; i < argc; i++) { - if (!strcmp (argv [i], "-r")) { - release_mode = 1; - no_daemon = 1; - } else if (!strcmp (argv [i], "-p")) { - if (++i == argc) - usage (); - local_port = htons (atoi (argv [i])); - log_debug ("binding to user-specified port %d", - ntohs (local_port)); - } else if (!strcmp (argv [i], "-d")) { - no_daemon = 1; - } else if (!strcmp (argv [i], "-pf")) { - if (++i == argc) - usage (); - path_dhclient_pid = argv [i]; - no_dhclient_pid = 1; - } else if (!strcmp (argv [i], "-cf")) { - if (++i == argc) - usage (); - path_dhclient_conf = argv [i]; - no_dhclient_conf = 1; - } else if (!strcmp (argv [i], "-lf")) { - if (++i == argc) - usage (); - path_dhclient_db = argv [i]; - no_dhclient_db = 1; - } else if (!strcmp (argv [i], "-sf")) { - if (++i == argc) - usage (); - path_dhclient_script = argv [i]; - no_dhclient_script = 1; - } else if (!strcmp (argv [i], "-1")) { - onetry = 1; - } else if (!strcmp (argv [i], "-q")) { - quiet = 1; - quiet_interface_discovery = 1; - } else if (!strcmp (argv [i], "-s")) { - if (++i == argc) - usage (); - server = argv [i]; - } else if (!strcmp (argv [i], "-g")) { - if (++i == argc) - usage (); - relay = argv [i]; - } else if (!strcmp (argv [i], "-nw")) { - nowait = 1; - } else if (!strcmp (argv [i], "-n")) { - /* do not start up any interfaces */ - interfaces_requested = 1; - } else if (!strcmp (argv [i], "-w")) { - /* do not exit if there are no broadcast interfaces. */ - persist = 1; - } else if (!strcmp (argv [i], "-e")) { - struct string_list *tmp; - if (++i == argc) - usage (); - tmp = dmalloc (strlen (argv [i]) + sizeof *tmp, MDL); - if (!tmp) - log_fatal ("No memory for %s", argv [i]); - strcpy (tmp -> string, argv [i]); - tmp -> next = client_env; - client_env = tmp; - client_env_count++; - } else if (!strcmp (argv [i], "--version")) { - log_info ("isc-dhclient-%s", DHCP_VERSION); - exit (0); - } else if (argv [i][0] == '-') { - usage (); - } else { - struct interface_info *tmp = (struct interface_info *)0; - status = interface_allocate (&tmp, MDL); - if (status != ISC_R_SUCCESS) - log_fatal ("Can't record interface %s:%s", - argv [i], isc_result_totext (status)); - if (strlen (argv [i]) > sizeof tmp -> name) - log_fatal ("%s: interface name too long (max %ld)", - argv [i], (long)strlen (argv [i])); - strcpy (tmp -> name, argv [i]); - if (interfaces) { - interface_reference (&tmp -> next, - interfaces, MDL); - interface_dereference (&interfaces, MDL); - } - interface_reference (&interfaces, tmp, MDL); - tmp -> flags = INTERFACE_REQUESTED; - interfaces_requested = 1; - } - } - - if (!no_dhclient_conf && (s = getenv ("PATH_DHCLIENT_CONF"))) { - path_dhclient_conf = s; - } - if (!no_dhclient_db && (s = getenv ("PATH_DHCLIENT_DB"))) { - path_dhclient_db = s; - } - if (!no_dhclient_pid && (s = getenv ("PATH_DHCLIENT_PID"))) { - path_dhclient_pid = s; - } - if (!no_dhclient_script && (s = getenv ("PATH_DHCLIENT_SCRIPT"))) { - path_dhclient_script = s; - } - - /* first kill of any currently running client */ - if (release_mode) { - FILE *pidfd; - pid_t oldpid; - long temp; - int e; - - oldpid = 0; - if ((pidfd = fopen(path_dhclient_pid, "r")) != NULL) { - e = fscanf(pidfd, "%ld\n", &temp); - oldpid = (pid_t)temp; - - if (e != 0 && e != EOF) { - if (oldpid) { - if (kill(oldpid, SIGTERM) == 0) - unlink(path_dhclient_pid); - } - } - fclose(pidfd); - } - } - - if (!quiet) { - log_info ("%s %s", message, DHCP_VERSION); - log_info (copyright); - log_info (arr); - log_info (url); - log_info ("%s", ""); - } else - log_perror = 0; - - /* If we're given a relay agent address to insert, for testing - purposes, figure out what it is. */ - if (relay) { - if (!inet_aton (relay, &giaddr)) { - struct hostent *he; - he = gethostbyname (relay); - if (he) { - memcpy (&giaddr, he -> h_addr_list [0], - sizeof giaddr); - } else { - log_fatal ("%s: no such host", relay); - } - } - } - - /* Default to the DHCP/BOOTP port. */ - if (!local_port) { - /* If we're faking a relay agent, and we're not using loopback, - use the server port, not the client port. */ - if (relay && giaddr.s_addr != htonl (INADDR_LOOPBACK)) { - local_port = htons(67); - } else { - ent = getservbyname ("dhcpc", "udp"); - if (!ent) - local_port = htons (68); - else - local_port = ent -> s_port; -#ifndef __CYGWIN32__ - endservent (); -#endif - } - } - - /* If we're faking a relay agent, and we're not using loopback, - we're using the server port, not the client port. */ - if (relay && giaddr.s_addr != htonl (INADDR_LOOPBACK)) { - remote_port = local_port; - } else - remote_port = htons (ntohs (local_port) - 1); /* XXX */ - - /* Get the current time... */ - GET_TIME (&cur_time); - - sockaddr_broadcast.sin_family = AF_INET; - sockaddr_broadcast.sin_port = remote_port; - if (server) { - if (!inet_aton (server, &sockaddr_broadcast.sin_addr)) { - struct hostent *he; - he = gethostbyname (server); - if (he) { - memcpy (&sockaddr_broadcast.sin_addr, - he -> h_addr_list [0], - sizeof sockaddr_broadcast.sin_addr); - } else - sockaddr_broadcast.sin_addr.s_addr = - INADDR_BROADCAST; - } - } else { - sockaddr_broadcast.sin_addr.s_addr = INADDR_BROADCAST; - } - - inaddr_any.s_addr = INADDR_ANY; - - /* Discover all the network interfaces. */ - discover_interfaces (DISCOVER_UNCONFIGURED); - - /* Parse the dhclient.conf file. */ - read_client_conf (); - - /* Parse the lease database. */ - read_client_leases (); - - /* Rewrite the lease database... */ - rewrite_client_leases (); - - /* XXX */ -/* config_counter(&snd_counter, &rcv_counter); */ - - /* If no broadcast interfaces were discovered, call the script - and tell it so. */ - if (!interfaces) { - /* Call dhclient-script with the NBI flag, in case somebody - cares. */ - script_init ((struct client_state *)0, "NBI", - (struct string_list *)0); - script_go ((struct client_state *)0); - - /* If we haven't been asked to persist, waiting for new - interfaces, then just exit. */ - if (!persist) { - /* Nothing more to do. */ - log_info ("No broadcast interfaces found - exiting."); - exit (0); - } - } else if (!release_mode) { - /* 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 -> client, - "PREINIT", (struct string_list *)0); - if (ip -> client -> alias) - script_write_params (ip -> client, "alias_", - ip -> client -> alias); - script_go (ip -> client); - } - } - - /* At this point, all the interfaces that the script thinks - are relevant should be running, so now we once again call - discover_interfaces(), and this time ask it to actually set - up the interfaces. */ - discover_interfaces (interfaces_requested - ? DISCOVER_REQUESTED - : DISCOVER_RUNNING); - - /* Make up a seed for the random number generator from current - time plus the sum of the last four bytes of each - interface's hardware address interpreted as an integer. - Not much entropy, but we're booting, so we're not likely to - find anything better. */ - seed = 0; - for (ip = interfaces; ip; ip = ip -> next) { - int junk; - memcpy (&junk, - &ip -> hw_address.hbuf [ip -> hw_address.hlen - - sizeof seed], sizeof seed); - seed += junk; - } - srandom (seed + cur_time); - - /* Start a configuration state machine for each interface. */ - for (ip = interfaces; ip; ip = ip -> next) { - ip -> flags |= INTERFACE_RUNNING; - for (client = ip -> client; client; client = client -> next) { - if (release_mode) - do_release (client); - else { - client -> state = S_INIT; - /* Set up a timeout to start the initialization - process. */ - add_timeout (cur_time + random () % 5, - state_reboot, client, 0, 0); - } - } - } - - if (release_mode) - return 0; - - /* Start up a listener for the object management API protocol. */ - if (top_level_config.omapi_port != -1) { - listener = (omapi_object_t *)0; - result = omapi_generic_new (&listener, MDL); - if (result != ISC_R_SUCCESS) - log_fatal ("Can't allocate new generic object: %s\n", - isc_result_totext (result)); - result = omapi_protocol_listen (listener, - (unsigned) - top_level_config.omapi_port, - 1); - if (result != ISC_R_SUCCESS) - log_fatal ("Can't start OMAPI protocol: %s", - isc_result_totext (result)); - } - - /* Set up the bootp packet handler... */ - bootp_packet_handler = do_packet; - -#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \ - defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) - dmalloc_cutoff_generation = dmalloc_generation; - dmalloc_longterm = dmalloc_outstanding; - dmalloc_outstanding = 0; -#endif - - /* If we're not supposed to wait before getting the address, - don't. */ - if (nowait) - go_daemon (); - - /* If we're not going to daemonize, write the pid file - now. */ - if (no_daemon || nowait) - write_client_pid_file (); - - /* Start dispatching packets and timeouts... */ - dispatch (); - - /*NOTREACHED*/ - return 0; -} - -static void usage () -{ - log_info ("%s %s", message, DHCP_VERSION); - log_info (copyright); - log_info (arr); - log_info (url); - - log_error ("Usage: dhclient [-1dqr] [-nw] [-p ] %s", - "[-s server]"); - log_error (" [-cf config-file] [-lf lease-file]%s", - "[-pf pid-file] [-e VAR=val]"); - log_fatal (" [-sf script-file] [interface]"); -} - -isc_result_t find_class (struct class **c, - const char *s, const char *file, int line) -{ - return 0; -} - -int check_collection (packet, lease, collection) - struct packet *packet; - struct lease *lease; - struct collection *collection; -{ - return 0; -} - -void classify (packet, class) - struct packet *packet; - struct class *class; -{ -} - -int unbill_class (lease, class) - struct lease *lease; - struct class *class; -{ - return 0; -} - -int find_subnet (struct subnet **sp, - struct iaddr addr, const char *file, int line) -{ - return 0; -} - -/* Individual States: - * - * Each routine is called from the dhclient_state_machine() in one of - * these conditions: - * -> entering INIT state - * -> recvpacket_flag == 0: timeout in this state - * -> otherwise: received a packet in this state - * - * Return conditions as handled by dhclient_state_machine(): - * Returns 1, sendpacket_flag = 1: send packet, reset timer. - * Returns 1, sendpacket_flag = 0: just reset the timer (wait for a milestone). - * Returns 0: finish the nap which was interrupted for no good reason. - * - * Several per-interface variables are used to keep track of the process: - * active_lease: the lease that is being used on the interface - * (null pointer if not configured yet). - * offered_leases: leases corresponding to DHCPOFFER messages that have - * been sent to us by DHCP servers. - * acked_leases: leases corresponding to DHCPACK messages that have been - * sent to us by DHCP servers. - * sendpacket: DHCP packet we're trying to send. - * destination: IP address to send sendpacket to - * In addition, there are several relevant per-lease variables. - * T1_expiry, T2_expiry, lease_expiry: lease milestones - * In the active lease, these control the process of renewing the lease; - * In leases on the acked_leases list, this simply determines when we - * can no longer legitimately use the lease. - */ - -void state_reboot (cpp) - void *cpp; -{ - struct client_state *client = cpp; - - /* If we don't remember an active lease, go straight to INIT. */ - if (!client -> active || - client -> active -> is_bootp || - client -> active -> expiry <= cur_time) { - state_init (client); - return; - } - - /* We are in the rebooting state. */ - 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. */ - client -> xid = random (); - - /* Make a DHCPREQUEST packet, and set appropriate per-interface - flags. */ - make_request (client, client -> active); - client -> destination = iaddr_broadcast; - client -> first_sending = cur_time; - client -> interval = client -> config -> initial_interval; - - /* Zap the medium list... */ - client -> medium = (struct string_list *)0; - - /* Send out the first DHCPREQUEST packet. */ - send_request (client); -} - -/* Called when a lease has completely expired and we've been unable to - renew it. */ - -void state_init (cpp) - void *cpp; -{ - struct client_state *client = cpp; - - ASSERT_STATE(state, S_INIT); - - /* Make a DHCPDISCOVER packet, and set appropriate per-interface - flags. */ - make_discover (client, client -> active); - client -> xid = client -> packet.xid; - client -> destination = iaddr_broadcast; - client -> state = S_SELECTING; - client -> first_sending = cur_time; - client -> interval = client -> config -> initial_interval; - - /* Add an immediate timeout to cause the first DHCPDISCOVER packet - to go out. */ - send_discover (client); -} - -/* state_selecting is called when one or more DHCPOFFER packets have been - received and a configurable period of time has passed. */ - -void state_selecting (cpp) - void *cpp; -{ - struct client_state *client = cpp; - struct client_lease *lp, *next, *picked; - - - ASSERT_STATE(state, S_SELECTING); - - /* Cancel state_selecting and send_discover timeouts, since either - one could have got us here. */ - cancel_timeout (state_selecting, client); - cancel_timeout (send_discover, client); - - /* We have received one or more DHCPOFFER packets. Currently, - the only criterion by which we judge leases is whether or - not we get a response when we arp for them. */ - picked = (struct client_lease *)0; - for (lp = client -> offered_leases; lp; lp = next) { - next = lp -> next; - - /* Check to see if we got an ARPREPLY for the address - in this particular lease. */ - if (!picked) { - picked = lp; - picked -> next = (struct client_lease *)0; - } else { - freeit: - destroy_client_lease (lp); - } - } - client -> offered_leases = (struct client_lease *)0; - - /* If we just tossed all the leases we were offered, go back - to square one. */ - if (!picked) { - client -> state = S_INIT; - state_init (client); - return; - } - - /* If it was a BOOTREPLY, we can just take the address right now. */ - if (picked -> is_bootp) { - client -> new = picked; - - /* Make up some lease expiry times - XXX these should be configurable. */ - client -> new -> expiry = cur_time + 12000; - client -> new -> renewal += cur_time + 8000; - client -> new -> rebind += cur_time + 10000; - - client -> state = S_REQUESTING; - - /* Bind to the address we received. */ - bind_lease (client); - return; - } - - /* Go to the REQUESTING state. */ - client -> destination = iaddr_broadcast; - client -> state = S_REQUESTING; - client -> first_sending = cur_time; - client -> interval = client -> config -> initial_interval; - - /* Make a DHCPREQUEST packet from the lease we picked. */ - make_request (client, picked); - client -> xid = client -> packet.xid; - - /* Toss the lease we picked - we'll get it back in a DHCPACK. */ - destroy_client_lease (picked); - - /* Add an immediate timeout to send the first DHCPREQUEST packet. */ - send_request (client); -} - -/* state_requesting is called when we receive a DHCPACK message after - having sent out one or more DHCPREQUEST packets. */ - -void dhcpack (packet) - struct packet *packet; -{ - struct interface_info *ip = packet -> interface; - struct client_state *client; - struct client_lease *lease; - struct option_cache *oc; - struct data_string ds; - int i; - - /* If we're not receptive to an offer right now, or if the offer - has an unrecognizable transaction id, then just drop it. */ - for (client = ip -> client; client; client = client -> next) { - if (client -> xid == packet -> raw -> xid) - break; - } - if (!client || - (packet -> interface -> hw_address.hlen - 1 != - packet -> raw -> hlen) || - (memcmp (&packet -> interface -> hw_address.hbuf [1], - packet -> raw -> chaddr, packet -> raw -> hlen))) { -#if defined (DEBUG) - log_debug ("DHCPACK in wrong transaction."); -#endif - return; - } - - if (client -> state != S_REBOOTING && - client -> state != S_REQUESTING && - client -> state != S_RENEWING && - client -> state != S_REBINDING) { -#if defined (DEBUG) - log_debug ("DHCPACK in wrong state."); -#endif - return; - } - - log_info ("DHCPACK from %s", piaddr (packet -> client_addr)); - - lease = packet_to_lease (packet, client); - if (!lease) { - log_info ("packet_to_lease failed."); - return; - } - - client -> new = lease; - - /* Stop resending DHCPREQUEST. */ - cancel_timeout (send_request, client); - - /* Figure out the lease time. */ - oc = lookup_option (&dhcp_universe, client -> new -> options, - DHO_DHCP_LEASE_TIME); - memset (&ds, 0, sizeof ds); - if (oc && - evaluate_option_cache (&ds, packet, (struct lease *)0, client, - packet -> options, client -> new -> options, - &global_scope, oc, MDL)) { - if (ds.len > 3) - client -> new -> expiry = getULong (ds.data); - else - client -> new -> expiry = 0; - data_string_forget (&ds, MDL); - } else - client -> new -> expiry = 0; - - if (!client -> new -> expiry) { - log_error ("no expiry time on offered lease."); - /* XXX this is going to be bad - if this _does_ - XXX happen, we should probably dynamically - XXX disqualify the DHCP server that gave us the - XXX bad packet from future selections and - XXX then go back into the init state. */ - state_init (client); - return; - } - - /* A number that looks negative here is really just very large, - because the lease expiry offset is unsigned. */ - if (client -> new -> expiry < 0) - client -> new -> expiry = TIME_MAX; - /* Take the server-provided renewal time if there is one. */ - oc = lookup_option (&dhcp_universe, client -> new -> options, - DHO_DHCP_RENEWAL_TIME); - if (oc && - evaluate_option_cache (&ds, packet, (struct lease *)0, client, - packet -> options, client -> new -> options, - &global_scope, oc, MDL)) { - if (ds.len > 3) - client -> new -> renewal = getULong (ds.data); - else - client -> new -> renewal = 0; - data_string_forget (&ds, MDL); - } else - client -> new -> renewal = 0; - - /* If it wasn't specified by the server, calculate it. */ - if (!client -> new -> renewal) - client -> new -> renewal = client -> new -> expiry / 2 + 1; - - if (client -> new -> renewal <= 0) - client -> new -> renewal = TIME_MAX; - - /* Now introduce some randomness to the renewal time: */ - if (client -> new -> renewal <= TIME_MAX / 3 - 3) - client -> new -> renewal = - (((client -> new -> renewal + 3) * 3 / 4) + - (random () % /* XXX NUMS */ - ((client -> new -> renewal + 3) / 4))); - - /* Same deal with the rebind time. */ - oc = lookup_option (&dhcp_universe, client -> new -> options, - DHO_DHCP_REBINDING_TIME); - if (oc && - evaluate_option_cache (&ds, packet, (struct lease *)0, client, - packet -> options, client -> new -> options, - &global_scope, oc, MDL)) { - if (ds.len > 3) - client -> new -> rebind = getULong (ds.data); - else - client -> new -> rebind = 0; - data_string_forget (&ds, MDL); - } else - client -> new -> rebind = 0; - - if (client -> new -> rebind <= 0) { - if (client -> new -> expiry <= TIME_MAX / 7) - client -> new -> rebind = - client -> new -> expiry * 7 / 8; - else - client -> new -> rebind = - client -> new -> expiry / 8 * 7; - } - - /* Make sure our randomness didn't run the renewal time past the - rebind time. */ - if (client -> new -> renewal > client -> new -> rebind) { - if (client -> new -> rebind <= TIME_MAX / 3) - client -> new -> renewal = - client -> new -> rebind * 3 / 4; - else - client -> new -> renewal = - client -> new -> rebind / 4 * 3; - } - - client -> new -> expiry += cur_time; - /* Lease lengths can never be negative. */ - if (client -> new -> expiry < cur_time) - client -> new -> expiry = TIME_MAX; - client -> new -> renewal += cur_time; - if (client -> new -> renewal < cur_time) - client -> new -> renewal = TIME_MAX; - client -> new -> rebind += cur_time; - if (client -> new -> rebind < cur_time) - client -> new -> rebind = TIME_MAX; - - bind_lease (client); -} - -void bind_lease (client) - struct client_state *client; -{ - struct interface_info *ip = client -> interface; - - /* Remember the medium. */ - client -> new -> medium = client -> medium; - - /* Run the client script with the new parameters. */ - script_init (client, (client -> state == S_REQUESTING - ? "BOUND" - : (client -> state == S_RENEWING - ? "RENEW" - : (client -> state == S_REBOOTING - ? "REBOOT" : "REBIND"))), - client -> new -> medium); - if (client -> active && client -> state != S_REBOOTING) - script_write_params (client, "old_", client -> active); - script_write_params (client, "new_", client -> new); - if (client -> alias) - script_write_params (client, "alias_", client -> alias); - - /* If the BOUND/RENEW code detects another machine using the - offered address, it exits nonzero. We need to send a - DHCPDECLINE and toss the lease. */ - if (script_go (client)) { - make_decline (client, client -> new); - send_decline (client); - destroy_client_lease (client -> new); - client -> new = (struct client_lease *)0; - state_init (client); - return; - } - - /* Write out the new lease. */ - write_client_lease (client, client -> new, 0, 0); - - /* Replace the old active lease with the new one. */ - if (client -> active) - destroy_client_lease (client -> active); - client -> active = client -> new; - client -> new = (struct client_lease *)0; - - /* Set up a timeout to start the renewal process. */ - add_timeout (client -> active -> renewal, - state_bound, client, 0, 0); - - log_info ("bound to %s -- renewal in %ld seconds.", - piaddr (client -> active -> address), - (long)(client -> active -> renewal - cur_time)); - client -> state = S_BOUND; - reinitialize_interfaces (); - go_daemon (); - if (client -> config -> do_forward_update) { - client -> dns_update_timeout = 1; - add_timeout (cur_time + 1, client_dns_update_timeout, - client, 0, 0); - } -} - -/* state_bound is called when we've successfully bound to a particular - lease, but the renewal time on that lease has expired. We are - expected to unicast a DHCPREQUEST to the server that gave us our - original lease. */ - -void state_bound (cpp) - void *cpp; -{ - struct client_state *client = cpp; - int i; - struct option_cache *oc; - struct data_string ds; - - ASSERT_STATE(state, S_BOUND); - - /* T1 has expired. */ - make_request (client, client -> active); - client -> xid = client -> packet.xid; - - memset (&ds, 0, sizeof ds); - oc = lookup_option (&dhcp_universe, client -> active -> options, - DHO_DHCP_SERVER_IDENTIFIER); - if (oc && - evaluate_option_cache (&ds, (struct packet *)0, (struct lease *)0, - client, (struct option_state *)0, - client -> active -> options, - &global_scope, oc, MDL)) { - if (ds.len > 3) { - memcpy (client -> destination.iabuf, ds.data, 4); - client -> destination.len = 4; - } else - client -> destination = iaddr_broadcast; - - data_string_forget (&ds, MDL); - } else - client -> destination = iaddr_broadcast; - - client -> first_sending = cur_time; - client -> interval = client -> config -> initial_interval; - client -> state = S_RENEWING; - - /* Send the first packet immediately. */ - send_request (client); -} - -/* state_stop is called when we've been told to shut down. We unconfigure - the interfaces, and then stop operating until told otherwise. */ - -void state_stop (cpp) - void *cpp; -{ - struct client_state *client = cpp; - int i; - - /* Cancel all timeouts. */ - cancel_timeout (state_selecting, client); - cancel_timeout (send_discover, client); - cancel_timeout (send_request, client); - cancel_timeout (state_bound, client); - - /* If we have an address, unconfigure it. */ - if (client -> active) { - script_init (client, "STOP", client -> active -> medium); - script_write_params (client, "old_", client -> active); - if (client -> alias) - script_write_params (client, "alias_", - client -> alias); - script_go (client); - } -} - -int commit_leases () -{ - return 0; -} - -int write_lease (lease) - struct lease *lease; -{ - return 0; -} - -int write_host (host) - struct host_decl *host; -{ - return 0; -} - -void db_startup (testp) - int testp; -{ -} - -void bootp (packet) - struct packet *packet; -{ - struct iaddrlist *ap; - - if (packet -> raw -> op != BOOTREPLY) - return; - - /* If there's a reject list, make sure this packet's sender isn't - on it. */ - for (ap = packet -> interface -> client -> config -> reject_list; - ap; ap = ap -> next) { - if (addr_eq (packet -> client_addr, ap -> addr)) { - log_info ("BOOTREPLY from %s rejected.", - piaddr (ap -> addr)); - return; - } - } - - dhcpoffer (packet); - -} - -void dhcp (packet) - struct packet *packet; -{ - struct iaddrlist *ap; - void (*handler) PROTO ((struct packet *)); - const char *type; - - switch (packet -> packet_type) { - case DHCPOFFER: - handler = dhcpoffer; - type = "DHCPOFFER"; - break; - - case DHCPNAK: - handler = dhcpnak; - type = "DHCPNACK"; - break; - - case DHCPACK: - handler = dhcpack; - type = "DHCPACK"; - break; - - default: - return; - } - - /* If there's a reject list, make sure this packet's sender isn't - on it. */ - for (ap = packet -> interface -> client -> config -> reject_list; - ap; ap = ap -> next) { - if (addr_eq (packet -> client_addr, ap -> addr)) { - log_info ("%s from %s rejected.", - type, piaddr (ap -> addr)); - return; - } - } - (*handler) (packet); -} - -void dhcpoffer (packet) - struct packet *packet; -{ - struct interface_info *ip = packet -> interface; - struct client_state *client; - struct client_lease *lease, *lp; - int i; - int stop_selecting; - const char *name = packet -> packet_type ? "DHCPOFFER" : "BOOTREPLY"; - struct iaddrlist *ap; - struct option_cache *oc; - char obuf [1024]; - -#ifdef DEBUG_PACKET - dump_packet (packet); -#endif - - /* Find a client state that matches the xid... */ - for (client = ip -> client; client; client = client -> next) - if (client -> xid == packet -> raw -> xid) - break; - - /* If we're not receptive to an offer right now, or if the offer - has an unrecognizable transaction id, then just drop it. */ - if (!client || - client -> state != S_SELECTING || - (packet -> interface -> hw_address.hlen - 1 != - packet -> raw -> hlen) || - (memcmp (&packet -> interface -> hw_address.hbuf [1], - packet -> raw -> chaddr, packet -> raw -> hlen))) { -#if defined (DEBUG) - log_debug ("%s in wrong transaction.", name); -#endif - return; - } - - sprintf (obuf, "%s from %s", name, piaddr (packet -> client_addr)); - - - /* If this lease doesn't supply the minimum required parameters, - blow it off. */ - if (client -> config -> required_options) { - for (i = 0; client -> config -> required_options [i]; i++) { - if (!lookup_option - (&dhcp_universe, packet -> options, - client -> config -> required_options [i])) { - log_info ("%s: no %s option.", - obuf, (dhcp_universe.options - [client -> config -> required_options [i]] - -> name)); - return; - } - } - } - - /* If we've already seen this lease, don't record it again. */ - for (lease = client -> offered_leases; lease; lease = lease -> next) { - if (lease -> address.len == sizeof packet -> raw -> yiaddr && - !memcmp (lease -> address.iabuf, - &packet -> raw -> yiaddr, lease -> address.len)) { - log_debug ("%s: already seen.", obuf); - return; - } - } - - lease = packet_to_lease (packet, client); - if (!lease) { - log_info ("%s: packet_to_lease failed.", obuf); - return; - } - - /* If this lease was acquired through a BOOTREPLY, record that - fact. */ - if (!packet -> options_valid || !packet -> packet_type) - lease -> is_bootp = 1; - - /* Record the medium under which this lease was offered. */ - lease -> medium = client -> medium; - - /* Figure out when we're supposed to stop selecting. */ - stop_selecting = (client -> first_sending + - client -> config -> select_interval); - - /* If this is the lease we asked for, put it at the head of the - list, and don't mess with the arp request timeout. */ - if (lease -> address.len == client -> requested_address.len && - !memcmp (lease -> address.iabuf, - client -> requested_address.iabuf, - client -> requested_address.len)) { - lease -> next = client -> offered_leases; - client -> offered_leases = lease; - } else { - /* Put the lease at the end of the list. */ - lease -> next = (struct client_lease *)0; - if (!client -> offered_leases) - client -> offered_leases = lease; - else { - for (lp = client -> offered_leases; lp -> next; - lp = lp -> next) - ; - lp -> next = lease; - } - } - - /* If the selecting interval has expired, go immediately to - state_selecting(). Otherwise, time out into - state_selecting at the select interval. */ - if (stop_selecting <= 0) - state_selecting (client); - else { - add_timeout (stop_selecting, state_selecting, client, 0, 0); - cancel_timeout (send_discover, client); - } - log_info ("%s", obuf); -} - -/* Allocate a client_lease structure and initialize it from the parameters - in the specified packet. */ - -struct client_lease *packet_to_lease (packet, client) - struct packet *packet; - struct client_state *client; -{ - struct client_lease *lease; - unsigned i; - struct option_cache *oc; - struct data_string data; - - lease = (struct client_lease *)new_client_lease (MDL); - - if (!lease) { - log_error ("packet_to_lease: no memory to record lease.\n"); - return (struct client_lease *)0; - } - - memset (lease, 0, sizeof *lease); - - /* Copy the lease options. */ - option_state_reference (&lease -> options, packet -> options, MDL); - - lease -> address.len = sizeof (packet -> raw -> yiaddr); - memcpy (lease -> address.iabuf, &packet -> raw -> yiaddr, - lease -> address.len); - - memset (&data, 0, sizeof data); - - if (client -> config -> vendor_space_name) { - i = DHO_VENDOR_ENCAPSULATED_OPTIONS; - - /* See if there was a vendor encapsulation option. */ - oc = lookup_option (&dhcp_universe, lease -> options, i); - if (oc && - client -> config -> vendor_space_name && - evaluate_option_cache (&data, packet, - (struct lease *)0, client, - packet -> options, lease -> options, - &global_scope, oc, MDL)) { - if (data.len) { - parse_encapsulated_suboptions - (packet -> options, &dhcp_options [i], - data.data, data.len, &dhcp_universe, - client -> config -> vendor_space_name - ); - } - data_string_forget (&data, MDL); - } - } else - i = 0; - - /* Figure out the overload flag. */ - oc = lookup_option (&dhcp_universe, lease -> options, - DHO_DHCP_OPTION_OVERLOAD); - if (oc && - evaluate_option_cache (&data, packet, (struct lease *)0, client, - packet -> options, lease -> options, - &global_scope, oc, MDL)) { - if (data.len > 0) - i = data.data [0]; - else - i = 0; - data_string_forget (&data, MDL); - } else - i = 0; - - /* If the server name was filled out, copy it. */ - if (!(i & 2) && packet -> raw -> sname [0]) { - unsigned len; - /* Don't count on the NUL terminator. */ - for (len = 0; len < 64; len++) - if (!packet -> raw -> sname [len]) - break; - lease -> server_name = dmalloc (len + 1, MDL); - if (!lease -> server_name) { - log_error ("dhcpoffer: no memory for filename.\n"); - destroy_client_lease (lease); - return (struct client_lease *)0; - } else { - memcpy (lease -> server_name, - packet -> raw -> sname, len); - lease -> server_name [len] = 0; - } - } - - /* Ditto for the filename. */ - if (!(i & 1) && packet -> raw -> file [0]) { - unsigned len; - /* Don't count on the NUL terminator. */ - for (len = 0; len < 64; len++) - if (!packet -> raw -> file [len]) - break; - lease -> filename = dmalloc (len + 1, MDL); - if (!lease -> filename) { - log_error ("dhcpoffer: no memory for filename.\n"); - destroy_client_lease (lease); - return (struct client_lease *)0; - } else { - memcpy (lease -> filename, - packet -> raw -> file, len); - lease -> filename [len] = 0; - } - } - - execute_statements_in_scope ((struct binding_value **)0, - (struct packet *)packet, - (struct lease *)0, client, - lease -> options, lease -> options, - &global_scope, - client -> config -> on_receipt, - (struct group *)0); - - return lease; -} - -void dhcpnak (packet) - struct packet *packet; -{ - struct interface_info *ip = packet -> interface; - struct client_state *client; - - /* Find a client state that matches the xid... */ - for (client = ip -> client; client; client = client -> next) - if (client -> xid == packet -> raw -> xid) - break; - - /* If we're not receptive to an offer right now, or if the offer - has an unrecognizable transaction id, then just drop it. */ - if (!client || - (packet -> interface -> hw_address.hlen - 1 != - packet -> raw -> hlen) || - (memcmp (&packet -> interface -> hw_address.hbuf [1], - packet -> raw -> chaddr, packet -> raw -> hlen))) { -#if defined (DEBUG) - log_debug ("DHCPNAK in wrong transaction."); -#endif - return; - } - - if (client -> state != S_REBOOTING && - client -> state != S_REQUESTING && - client -> state != S_RENEWING && - client -> state != S_REBINDING) { -#if defined (DEBUG) - log_debug ("DHCPNAK in wrong state."); -#endif - return; - } - - log_info ("DHCPNAK from %s", piaddr (packet -> client_addr)); - - if (!client -> active) { -#if defined (DEBUG) - log_info ("DHCPNAK with no active lease.\n"); -#endif - return; - } - - destroy_client_lease (client -> active); - client -> active = (struct client_lease *)0; - - /* Stop sending DHCPREQUEST packets... */ - cancel_timeout (send_request, client); - - client -> state = S_INIT; - state_init (client); -} - -/* Send out a DHCPDISCOVER packet, and set a timeout to send out another - one after the right interval has expired. If we don't get an offer by - the time we reach the panic interval, call the panic function. */ - -void send_discover (cpp) - void *cpp; -{ - struct client_state *client = cpp; - - int result; - int interval; - int increase = 1; - - /* Figure out how long it's been since we started transmitting. */ - interval = cur_time - client -> first_sending; - - /* If we're past the panic timeout, call the script and tell it - we haven't found anything for this interface yet. */ - if (interval > client -> config -> timeout) { - state_panic (client); - return; - } - - /* If we're selecting media, try the whole list before doing - the exponential backoff, but if we've already received an - offer, stop looping, because we obviously have it right. */ - if (!client -> offered_leases && - client -> config -> media) { - int fail = 0; - again: - if (client -> medium) { - client -> medium = client -> medium -> next; - increase = 0; - } - if (!client -> medium) { - if (fail) - log_fatal ("No valid media types for %s!", - client -> interface -> name); - client -> medium = - client -> config -> media; - increase = 1; - } - - log_info ("Trying medium \"%s\" %d", - client -> medium -> string, increase); - script_init (client, "MEDIUM", client -> medium); - if (script_go (client)) { - fail = 1; - goto again; - } - } - - /* If we're supposed to increase the interval, do so. If it's - currently zero (i.e., we haven't sent any packets yet), set - it to initial_interval; otherwise, add to it a random number - between zero and two times itself. On average, this means - that it will double with every transmission. */ - if (increase) { - if (!client -> interval) - client -> interval = - client -> config -> initial_interval; - else - client -> interval += ((random () >> 2) % - (2 * client -> interval)); - - /* Don't backoff past cutoff. */ - if (client -> interval > - client -> config -> backoff_cutoff) - client -> interval = - ((client -> config -> backoff_cutoff / 2) - + ((random () >> 2) % - client -> config -> backoff_cutoff)); - } else if (!client -> interval) - client -> interval = client -> config -> initial_interval; - - /* If the backoff would take us to the panic timeout, just use that - as the interval. */ - if (cur_time + client -> interval > - client -> first_sending + client -> config -> timeout) - client -> interval = - (client -> first_sending + - client -> config -> timeout) - cur_time + 1; - - /* Record the number of seconds since we started sending. */ - if (interval < 65536) - client -> packet.secs = htons (interval); - else - client -> packet.secs = htons (65535); - client -> secs = client -> packet.secs; - - log_info ("DHCPDISCOVER on %s to %s port %d interval %ld", - client -> name ? client -> name : client -> interface -> name, - inet_ntoa (sockaddr_broadcast.sin_addr), - ntohs (sockaddr_broadcast.sin_port), (long)(client -> interval)); - - /* Send out a packet. */ - result = send_packet (client -> interface, (struct packet *)0, - &client -> packet, - client -> packet_length, - inaddr_any, &sockaddr_broadcast, - (struct hardware *)0); - - add_timeout (cur_time + client -> interval, - send_discover, client, 0, 0); -} - -/* state_panic gets called if we haven't received any offers in a preset - amount of time. When this happens, we try to use existing leases that - haven't yet expired, and failing that, we call the client script and - hope it can do something. */ - -void state_panic (cpp) - void *cpp; -{ - struct client_state *client = cpp; - struct client_lease *loop; - struct client_lease *lp; - - loop = lp = client -> active; - - log_info ("No DHCPOFFERS received."); - - /* We may not have an active lease, but we may have some - predefined leases that we can try. */ - if (!client -> active && client -> leases) - goto activate_next; - - /* Run through the list of leases and see if one can be used. */ - while (client -> active) { - if (client -> active -> expiry > cur_time) { - log_info ("Trying recorded lease %s", - piaddr (client -> active -> address)); - /* Run the client script with the existing - parameters. */ - script_init (client, "TIMEOUT", - client -> active -> medium); - script_write_params (client, "new_", client -> active); - if (client -> alias) - script_write_params (client, "alias_", - client -> alias); - - /* If the old lease is still good and doesn't - yet need renewal, go into BOUND state and - timeout at the renewal time. */ - if (!script_go (client)) { - if (cur_time < client -> active -> renewal) { - client -> state = S_BOUND; - log_info ("bound: renewal in %ld %s.", - (long)(client -> active -> renewal - - cur_time), "seconds"); - add_timeout (client -> active -> renewal, - state_bound, client, 0, 0); - } else { - client -> state = S_BOUND; - log_info ("bound: immediate renewal."); - state_bound (client); - } - reinitialize_interfaces (); - go_daemon (); - return; - } - } - - /* If there are no other leases, give up. */ - if (!client -> leases) { - client -> leases = client -> active; - client -> active = (struct client_lease *)0; - break; - } - - activate_next: - /* Otherwise, put the active lease at the end of the - lease list, and try another lease.. */ - for (lp = client -> leases; lp -> next; lp = lp -> next) - ; - lp -> next = client -> active; - if (lp -> next) { - lp -> next -> next = (struct client_lease *)0; - } - client -> active = client -> leases; - client -> leases = client -> leases -> next; - - /* If we already tried this lease, we've exhausted the - set of leases, so we might as well give up for - now. */ - if (client -> active == loop) - break; - else if (!loop) - loop = client -> active; - } - - /* No leases were available, or what was available didn't work, so - tell the shell script that we failed to allocate an address, - and try again later. */ - if (onetry) { - if (!quiet) - log_info ("Unable to obtain a lease on first try.%s", - " Exiting."); - exit (2); - } - - log_info ("No working leases in persistent database - sleeping."); - script_init (client, "FAIL", (struct string_list *)0); - if (client -> alias) - script_write_params (client, "alias_", client -> alias); - script_go (client); - client -> state = S_INIT; - add_timeout (cur_time + - ((client -> config -> retry_interval + 1) / 2 + - (random () % client -> config -> retry_interval)), - state_init, client, 0, 0); - go_daemon (); -} - -void send_request (cpp) - void *cpp; -{ - struct client_state *client = cpp; - - int result; - int interval; - struct sockaddr_in destination; - struct in_addr from; - - /* Figure out how long it's been since we started transmitting. */ - interval = cur_time - client -> first_sending; - - /* If we're in the INIT-REBOOT or REQUESTING state and we're - past the reboot timeout, go to INIT and see if we can - DISCOVER an address... */ - /* XXX In the INIT-REBOOT state, if we don't get an ACK, it - means either that we're on a network with no DHCP server, - or that our server is down. In the latter case, assuming - that there is a backup DHCP server, DHCPDISCOVER will get - us a new address, but we could also have successfully - reused our old address. In the former case, we're hosed - anyway. This is not a win-prone situation. */ - if ((client -> state == S_REBOOTING || - client -> state == S_REQUESTING) && - interval > client -> config -> reboot_timeout) { - cancel: - client -> state = S_INIT; - cancel_timeout (send_request, client); - state_init (client); - return; - } - - /* If we're in the reboot state, make sure the media is set up - correctly. */ - if (client -> state == S_REBOOTING && - !client -> medium && - client -> active -> medium ) { - script_init (client, "MEDIUM", client -> active -> medium); - - /* If the medium we chose won't fly, go to INIT state. */ - if (script_go (client)) - goto cancel; - - /* Record the medium. */ - client -> medium = client -> active -> medium; - } - - /* If the lease has expired, relinquish the address and go back - to the INIT state. */ - if (client -> state != S_REQUESTING && - cur_time > client -> active -> expiry) { - /* Run the client script with the new parameters. */ - script_init (client, "EXPIRE", (struct string_list *)0); - script_write_params (client, "old_", client -> active); - if (client -> alias) - script_write_params (client, "alias_", - client -> alias); - script_go (client); - - /* Now do a preinit on the interface so that we can - discover a new address. */ - script_init (client, "PREINIT", (struct string_list *)0); - if (client -> alias) - script_write_params (client, "alias_", - client -> alias); - script_go (client); - - client -> state = S_INIT; - state_init (client); - return; - } - - /* Do the exponential backoff... */ - if (!client -> interval) - client -> interval = client -> config -> initial_interval; - else { - client -> interval += ((random () >> 2) % - (2 * client -> interval)); - } - - /* Don't backoff past cutoff. */ - if (client -> interval > - client -> config -> backoff_cutoff) - client -> interval = - ((client -> config -> backoff_cutoff / 2) - + ((random () >> 2) % - client -> config -> backoff_cutoff)); - - /* If the backoff would take us to the expiry time, just set the - timeout to the expiry time. */ - if (client -> state != S_REQUESTING && - cur_time + client -> interval > client -> active -> expiry) - client -> interval = - client -> active -> expiry - cur_time + 1; - - /* If the lease T2 time has elapsed, or if we're not yet bound, - broadcast the DHCPREQUEST rather than unicasting. */ - if (client -> state == S_REQUESTING || - client -> state == S_REBOOTING || - cur_time > client -> active -> rebind) - destination.sin_addr = sockaddr_broadcast.sin_addr; - else - memcpy (&destination.sin_addr.s_addr, - client -> destination.iabuf, - sizeof destination.sin_addr.s_addr); - destination.sin_port = remote_port; - destination.sin_family = AF_INET; -#ifdef HAVE_SA_LEN - destination.sin_len = sizeof destination; -#endif - - if (client -> state == S_RENEWING || - client -> state == S_REBINDING) - memcpy (&from, client -> active -> address.iabuf, - sizeof from); - else - from.s_addr = INADDR_ANY; - - /* Record the number of seconds since we started sending. */ - if (client -> state == S_REQUESTING) - client -> packet.secs = client -> secs; - else { - if (interval < 65536) - client -> packet.secs = htons (interval); - else - client -> packet.secs = htons (65535); - } - - log_info ("DHCPREQUEST on %s to %s port %d", - client -> name ? client -> name : client -> interface -> name, - inet_ntoa (destination.sin_addr), - ntohs (destination.sin_port)); - - if (destination.sin_addr.s_addr != INADDR_BROADCAST && - fallback_interface) - result = send_packet (fallback_interface, - (struct packet *)0, - &client -> packet, - client -> packet_length, - from, &destination, - (struct hardware *)0); - else - /* Send out a packet. */ - result = send_packet (client -> interface, (struct packet *)0, - &client -> packet, - client -> packet_length, - from, &destination, - (struct hardware *)0); - - add_timeout (cur_time + client -> interval, - send_request, client, 0, 0); -} - -void send_decline (cpp) - void *cpp; -{ - struct client_state *client = cpp; - - int result; - - log_info ("DHCPDECLINE on %s to %s port %d", - client -> name ? client -> name : client -> interface -> name, - inet_ntoa (sockaddr_broadcast.sin_addr), - ntohs (sockaddr_broadcast.sin_port)); - - /* Send out a packet. */ - result = send_packet (client -> interface, (struct packet *)0, - &client -> packet, - client -> packet_length, - inaddr_any, &sockaddr_broadcast, - (struct hardware *)0); -} - -void send_release (cpp) - void *cpp; -{ - struct client_state *client = cpp; - - int result; - struct sockaddr_in destination; - struct in_addr from; - - memcpy (&from, client -> active -> address.iabuf, - sizeof from); - memcpy (&destination.sin_addr.s_addr, - client -> destination.iabuf, - sizeof destination.sin_addr.s_addr); - destination.sin_port = remote_port; - destination.sin_family = AF_INET; -#ifdef HAVE_SA_LEN - destination.sin_len = sizeof destination; -#endif - - /* Set the lease to end now, so that we don't accidentally - reuse it if we restart before the old expiry time. */ - client -> active -> expiry = - client -> active -> renewal = - client -> active -> rebind = cur_time; - if (!write_client_lease (client, client -> active, 1, 1)) { - log_error ("Can't release lease: lease write failed."); - return; - } - - log_info ("DHCPRELEASE on %s to %s port %d", - client -> name ? client -> name : client -> interface -> name, - inet_ntoa (destination.sin_addr), - ntohs (destination.sin_port)); - - if (fallback_interface) - result = send_packet (fallback_interface, - (struct packet *)0, - &client -> packet, - client -> packet_length, - from, &destination, - (struct hardware *)0); - else - /* Send out a packet. */ - result = send_packet (client -> interface, (struct packet *)0, - &client -> packet, - client -> packet_length, - from, &destination, - (struct hardware *)0); -} - -void make_client_options (client, lease, type, sid, rip, prl, op) - struct client_state *client; - struct client_lease *lease; - u_int8_t *type; - struct option_cache *sid; - struct iaddr *rip; - u_int32_t *prl; - struct option_state **op; -{ - unsigned i; - struct option_cache *oc; - struct buffer *bp = (struct buffer *)0; - - /* If there are any leftover options, get rid of them. */ - if (*op) - option_state_dereference (op, MDL); - - /* Allocate space for options. */ - option_state_allocate (op, MDL); - - /* Send the server identifier if provided. */ - if (sid) - save_option (&dhcp_universe, *op, sid); - - oc = (struct option_cache *)0; - - /* Send the requested address if provided. */ - if (rip) { - client -> requested_address = *rip; - if (!(make_const_option_cache - (&oc, (struct buffer **)0, rip -> iabuf, rip -> len, - &dhcp_options [DHO_DHCP_REQUESTED_ADDRESS], MDL))) - log_error ("can't make requested address cache."); - else { - save_option (&dhcp_universe, *op, oc); - option_cache_dereference (&oc, MDL); - } - } else { - client -> requested_address.len = 0; - } - - if (!(make_const_option_cache - (&oc, (struct buffer **)0, - type, 1, &dhcp_options [DHO_DHCP_MESSAGE_TYPE], MDL))) - log_error ("can't make message type."); - else { - save_option (&dhcp_universe, *op, oc); - option_cache_dereference (&oc, MDL); - } - - if (prl) { - /* Figure out how many parameters were requested. */ - for (i = 0; prl [i]; i++) - ; - if (!buffer_allocate (&bp, i, MDL)) - log_error ("can't make parameter list buffer."); - else { - for (i = 0; prl [i]; i++) - bp -> data [i] = prl [i]; - if (!(make_const_option_cache - (&oc, &bp, (u_int8_t *)0, i, - &dhcp_options [DHO_DHCP_PARAMETER_REQUEST_LIST], - MDL))) - log_error ("can't make option cache"); - else { - save_option (&dhcp_universe, *op, oc); - option_cache_dereference (&oc, MDL); - } - } - } - - /* Run statements that need to be run on transmission. */ - if (client -> config -> on_transmission) - execute_statements_in_scope - ((struct binding_value **)0, - (struct packet *)0, (struct lease *)0, client, - (lease ? lease -> options : (struct option_state *)0), - *op, &global_scope, - client -> config -> on_transmission, - (struct group *)0); -} - -void make_discover (client, lease) - struct client_state *client; - struct client_lease *lease; -{ - unsigned char discover = DHCPDISCOVER; - int i; - struct option_state *options = (struct option_state *)0; - - memset (&client -> packet, 0, sizeof (client -> packet)); - - make_client_options (client, - lease, &discover, (struct option_cache *)0, - lease ? &lease -> address : (struct iaddr *)0, - client -> config -> requested_options, - &options); - - /* Set up the option buffer... */ - client -> packet_length = - cons_options ((struct packet *)0, &client -> packet, - (struct lease *)0, client, - /* maximum packet size */1500, - (struct option_state *)0, - options, - /* scope */ &global_scope, - /* overload */ 0, - /* terminate */0, - /* bootpp */0, - (struct data_string *)0, - client -> config -> vendor_space_name); - - option_state_dereference (&options, MDL); - if (client -> packet_length < BOOTP_MIN_LEN) - client -> packet_length = BOOTP_MIN_LEN; - - client -> packet.op = BOOTREQUEST; - client -> packet.htype = client -> interface -> hw_address.hbuf [0]; - client -> packet.hlen = client -> interface -> hw_address.hlen - 1; - client -> packet.hops = 0; - client -> packet.xid = random (); - client -> packet.secs = 0; /* filled in by send_discover. */ - - if (can_receive_unicast_unconfigured (client -> interface)) - client -> packet.flags = 0; - else - client -> packet.flags = htons (BOOTP_BROADCAST); - - memset (&(client -> packet.ciaddr), - 0, sizeof client -> packet.ciaddr); - memset (&(client -> packet.yiaddr), - 0, sizeof client -> packet.yiaddr); - memset (&(client -> packet.siaddr), - 0, sizeof client -> packet.siaddr); - client -> packet.giaddr = giaddr; - if (client -> interface -> hw_address.hlen > 0) - memcpy (client -> packet.chaddr, - &client -> interface -> hw_address.hbuf [1], - (unsigned)(client -> interface -> hw_address.hlen - 1)); - -#ifdef DEBUG_PACKET - dump_raw ((unsigned char *)&client -> packet, client -> packet_length); -#endif -} - - -void make_request (client, lease) - struct client_state *client; - struct client_lease *lease; -{ - unsigned char request = DHCPREQUEST; - int i, j; - unsigned char *tmp, *digest; - unsigned char *old_digest_loc; - struct option_cache *oc; - - memset (&client -> packet, 0, sizeof (client -> packet)); - - if (client -> state == S_REQUESTING) - oc = lookup_option (&dhcp_universe, lease -> options, - DHO_DHCP_SERVER_IDENTIFIER); - else - oc = (struct option_cache *)0; - - if (client -> sent_options) - option_state_dereference (&client -> sent_options, MDL); - - make_client_options (client, lease, &request, oc, - ((client -> state == S_REQUESTING || - client -> state == S_REBOOTING) - ? &lease -> address - : (struct iaddr *)0), - client -> config -> requested_options, - &client -> sent_options); - - /* Set up the option buffer... */ - client -> packet_length = - cons_options ((struct packet *)0, &client -> packet, - (struct lease *)0, client, - /* maximum packet size */1500, - (struct option_state *)0, - client -> sent_options, - /* scope */ &global_scope, - /* overload */ 0, - /* terminate */0, - /* bootpp */0, - (struct data_string *)0, - client -> config -> vendor_space_name); - - if (client -> packet_length < BOOTP_MIN_LEN) - client -> packet_length = BOOTP_MIN_LEN; - - client -> packet.op = BOOTREQUEST; - client -> packet.htype = client -> interface -> hw_address.hbuf [0]; - client -> packet.hlen = client -> interface -> hw_address.hlen - 1; - client -> packet.hops = 0; - client -> packet.xid = client -> xid; - client -> packet.secs = 0; /* Filled in by send_request. */ - - /* If we own the address we're requesting, put it in ciaddr; - otherwise set ciaddr to zero. */ - if (client -> state == S_BOUND || - client -> state == S_RENEWING || - client -> state == S_REBINDING) { - memcpy (&client -> packet.ciaddr, - lease -> address.iabuf, lease -> address.len); - client -> packet.flags = 0; - } else { - memset (&client -> packet.ciaddr, 0, - sizeof client -> packet.ciaddr); - if (can_receive_unicast_unconfigured (client -> interface)) - client -> packet.flags = 0; - else - client -> packet.flags = htons (BOOTP_BROADCAST); - } - - memset (&client -> packet.yiaddr, 0, - sizeof client -> packet.yiaddr); - memset (&client -> packet.siaddr, 0, - sizeof client -> packet.siaddr); - if (client -> state != S_BOUND && - client -> state != S_RENEWING) - client -> packet.giaddr = giaddr; - else - memset (&client -> packet.giaddr, 0, - sizeof client -> packet.giaddr); - if (client -> interface -> hw_address.hlen > 0) - memcpy (client -> packet.chaddr, - &client -> interface -> hw_address.hbuf [1], - (unsigned)(client -> interface -> hw_address.hlen - 1)); - -#ifdef DEBUG_PACKET - dump_raw ((unsigned char *)&client -> packet, client -> packet_length); -#endif -} - -void make_decline (client, lease) - struct client_state *client; - struct client_lease *lease; -{ - unsigned char decline = DHCPDECLINE; - int i; - struct option_cache *oc; - - struct option_state *options = (struct option_state *)0; - - oc = lookup_option (&dhcp_universe, lease -> options, - DHO_DHCP_SERVER_IDENTIFIER); - make_client_options (client, lease, &decline, oc, - &lease -> address, (u_int32_t *)0, &options); - - /* Set up the option buffer... */ - memset (&client -> packet, 0, sizeof (client -> packet)); - client -> packet_length = - cons_options ((struct packet *)0, &client -> packet, - (struct lease *)0, client, 0, - (struct option_state *)0, options, - &global_scope, 0, 0, 0, (struct data_string *)0, - client -> config -> vendor_space_name); - option_state_dereference (&options, MDL); - if (client -> packet_length < BOOTP_MIN_LEN) - client -> packet_length = BOOTP_MIN_LEN; - option_state_dereference (&options, MDL); - - client -> packet.op = BOOTREQUEST; - client -> packet.htype = client -> interface -> hw_address.hbuf [0]; - client -> packet.hlen = client -> interface -> hw_address.hlen - 1; - client -> packet.hops = 0; - client -> packet.xid = client -> xid; - client -> packet.secs = 0; /* Filled in by send_request. */ - if (can_receive_unicast_unconfigured (client -> interface)) - client -> packet.flags = 0; - else - client -> packet.flags = htons (BOOTP_BROADCAST); - - /* ciaddr must always be zero. */ - memset (&client -> packet.ciaddr, 0, - sizeof client -> packet.ciaddr); - memset (&client -> packet.yiaddr, 0, - sizeof client -> packet.yiaddr); - memset (&client -> packet.siaddr, 0, - sizeof client -> packet.siaddr); - client -> packet.giaddr = giaddr; - memcpy (client -> packet.chaddr, - &client -> interface -> hw_address.hbuf [1], - client -> interface -> hw_address.hlen); - -#ifdef DEBUG_PACKET - dump_raw ((unsigned char *)&client -> packet, client -> packet_length); -#endif -} - -void make_release (client, lease) - struct client_state *client; - struct client_lease *lease; -{ - unsigned char request = DHCPRELEASE; - int i; - struct option_cache *oc; - - struct option_state *options = (struct option_state *)0; - - memset (&client -> packet, 0, sizeof (client -> packet)); - - oc = lookup_option (&dhcp_universe, lease -> options, - DHO_DHCP_SERVER_IDENTIFIER); - make_client_options (client, lease, &request, oc, - (struct iaddr *)0, (u_int32_t *)0, - &options); - - /* Set up the option buffer... */ - client -> packet_length = - cons_options ((struct packet *)0, &client -> packet, - (struct lease *)0, client, - /* maximum packet size */1500, - (struct option_state *)0, - options, - /* scope */ &global_scope, - /* overload */ 0, - /* terminate */0, - /* bootpp */0, - (struct data_string *)0, - client -> config -> vendor_space_name); - - if (client -> packet_length < BOOTP_MIN_LEN) - client -> packet_length = BOOTP_MIN_LEN; - option_state_dereference (&options, MDL); - - client -> packet.op = BOOTREQUEST; - client -> packet.htype = client -> interface -> hw_address.hbuf [0]; - client -> packet.hlen = client -> interface -> hw_address.hlen - 1; - client -> packet.hops = 0; - client -> packet.xid = random (); - client -> packet.secs = 0; - client -> packet.flags = 0; - memcpy (&client -> packet.ciaddr, - lease -> address.iabuf, lease -> address.len); - memset (&client -> packet.yiaddr, 0, - sizeof client -> packet.yiaddr); - memset (&client -> packet.siaddr, 0, - sizeof client -> packet.siaddr); - client -> packet.giaddr = giaddr; - memcpy (client -> packet.chaddr, - &client -> interface -> hw_address.hbuf [1], - client -> interface -> hw_address.hlen); - -#ifdef DEBUG_PACKET - dump_raw ((unsigned char *)&client -> packet, client -> packet_length); -#endif -} - -void destroy_client_lease (lease) - struct client_lease *lease; -{ - int i; - - if (lease -> server_name) - dfree (lease -> server_name, MDL); - if (lease -> filename) - dfree (lease -> filename, MDL); - option_state_dereference (&lease -> options, MDL); - free_client_lease (lease, MDL); -} - -FILE *leaseFile; - -void rewrite_client_leases () -{ - struct interface_info *ip; - struct client_state *client; - struct client_lease *lp; - - if (leaseFile) - fclose (leaseFile); - leaseFile = fopen (path_dhclient_db, "w"); - if (!leaseFile) { - log_error ("can't create %s: %m", path_dhclient_db); - return; - } - - /* Write out all the leases attached to configured interfaces that - we know about. */ - for (ip = interfaces; ip; ip = ip -> next) { - for (client = ip -> client; client; client = client -> next) { - for (lp = client -> leases; lp; lp = lp -> next) { - write_client_lease (client, lp, 1, 0); - } - if (client -> active) - write_client_lease (client, - client -> active, 1, 0); - } - } - - /* Write out any leases that are attached to interfaces that aren't - currently configured. */ - for (ip = dummy_interfaces; ip; ip = ip -> next) { - for (client = ip -> client; client; client = client -> next) { - for (lp = client -> leases; lp; lp = lp -> next) { - write_client_lease (client, lp, 1, 0); - } - if (client -> active) - write_client_lease (client, - client -> active, 1, 0); - } - } - fflush (leaseFile); -} - -void write_lease_option (struct option_cache *oc, - struct packet *packet, struct lease *lease, - struct client_state *client_state, - struct option_state *in_options, - struct option_state *cfg_options, - struct binding_scope **scope, - struct universe *u, void *stuff) -{ - const char *name, *dot; - struct data_string ds; - int status; - struct client_state *client; - - memset (&ds, 0, sizeof ds); - - if (u != &dhcp_universe) { - name = u -> name; - dot = "."; - } else { - name = ""; - dot = ""; - } - if (evaluate_option_cache (&ds, packet, lease, client_state, - in_options, cfg_options, scope, oc, MDL)) { - fprintf (leaseFile, - " option %s%s%s %s;\n", - name, dot, oc -> option -> name, - pretty_print_option (oc -> option, - ds.data, ds.len, 1, 1)); - data_string_forget (&ds, MDL); - } -} - -int write_client_lease (client, lease, rewrite, makesure) - struct client_state *client; - struct client_lease *lease; - int rewrite; - int makesure; -{ - int i; - struct tm *t; - static int leases_written; - struct option_cache *oc; - struct data_string ds; - pair *hash; - int errors = 0; - char *s; - - 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. */ - if (lease -> is_static) - return 1; - - if (!leaseFile) { /* XXX */ - leaseFile = fopen (path_dhclient_db, "w"); - if (!leaseFile) { - log_error ("can't create %s: %m", path_dhclient_db); - return 0; - } - } - - errno = 0; - fprintf (leaseFile, "lease {\n"); - if (lease -> is_bootp) { - fprintf (leaseFile, " bootp;\n"); - if (errno) { - ++errors; - errno = 0; - } - } - fprintf (leaseFile, " interface \"%s\";\n", - client -> interface -> name); - if (errno) { - ++errors; - errno = 0; - } - if (client -> name) { - fprintf (leaseFile, " name \"%s\";\n", client -> name); - if (errno) { - ++errors; - errno = 0; - } - } - fprintf (leaseFile, " fixed-address %s;\n", - piaddr (lease -> address)); - if (errno) { - ++errors; - errno = 0; - } - if (lease -> filename) { - s = quotify_string (lease -> filename, MDL); - if (s) { - fprintf (leaseFile, " filename \"%s\";\n", s); - if (errno) { - ++errors; - errno = 0; - } - dfree (s, MDL); - } else - errors++; - - } - if (lease -> server_name) { - s = quotify_string (lease -> filename, MDL); - if (s) { - fprintf (leaseFile, " server-name \"%s\";\n", s); - if (errno) { - ++errors; - errno = 0; - } - dfree (s, MDL); - } else - ++errors; - } - if (lease -> medium) { - s = quotify_string (lease -> medium -> string, MDL); - if (s) { - fprintf (leaseFile, " medium \"%s\";\n", s); - if (errno) { - ++errors; - errno = 0; - } - dfree (s, MDL); - } else - errors++; - } - if (errno != 0) { - errors++; - errno = 0; - } - - memset (&ds, 0, sizeof ds); - - for (i = 0; i < lease -> options -> universe_count; i++) { - option_space_foreach ((struct packet *)0, (struct lease *)0, - client, (struct option_state *)0, - lease -> options, &global_scope, - universes [i], - client, write_lease_option); - } - - /* 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", - t -> tm_wday, t -> tm_year + 1900, - t -> tm_mon + 1, t -> tm_mday, - t -> tm_hour, t -> tm_min, t -> tm_sec); - if (errno != 0) { - errors++; - errno = 0; - } - t = gmtime (&lease -> rebind); - fprintf (leaseFile, - " rebind %d %d/%d/%d %02d:%02d:%02d;\n", - t -> tm_wday, t -> tm_year + 1900, - t -> tm_mon + 1, t -> tm_mday, - t -> tm_hour, t -> tm_min, t -> tm_sec); - if (errno != 0) { - errors++; - errno = 0; - } - t = gmtime (&lease -> expiry); - fprintf (leaseFile, - " expire %d %d/%d/%d %02d:%02d:%02d;\n", - t -> tm_wday, t -> tm_year + 1900, - t -> tm_mon + 1, t -> tm_mday, - t -> tm_hour, t -> tm_min, t -> tm_sec); - if (errno != 0) { - errors++; - errno = 0; - } - fprintf (leaseFile, "}\n"); - if (errno != 0) { - errors++; - errno = 0; - } - fflush (leaseFile); - if (errno != 0) { - errors++; - errno = 0; - } - if (!errors && makesure) { - if (fsync (fileno (leaseFile)) < 0) { - log_info ("write_client_lease: %m"); - return 0; - } - } - return errors ? 0 : 1; -} - -/* Variables holding name of script and file pointer for writing to - script. Needless to say, this is not reentrant - only one script - can be invoked at a time. */ -char scriptName [256]; -FILE *scriptFile; - -void script_init (client, reason, medium) - struct client_state *client; - const char *reason; - struct string_list *medium; -{ - struct string_list *sl, *next; - - if (client) { - for (sl = client -> env; sl; sl = next) { - next = sl -> next; - dfree (sl, MDL); - } - client -> env = (struct string_list *)0; - client -> envc = 0; - - if (client -> interface) { - client_envadd (client, "", "interface", "%s", - client -> interface -> name); - } - if (client -> name) - client_envadd (client, - "", "client", "%s", client -> name); - if (medium) - client_envadd (client, - "", "medium", "%s", medium -> string); - - client_envadd (client, "", "reason", "%s", reason); - client_envadd (client, "", "pid", "%ld", (long int)getpid ()); - } -} - -struct envadd_state { - struct client_state *client; - const char *prefix; -}; - -void client_option_envadd (struct option_cache *oc, - struct packet *packet, struct lease *lease, - struct client_state *client_state, - struct option_state *in_options, - struct option_state *cfg_options, - struct binding_scope **scope, - struct universe *u, void *stuff) -{ - struct envadd_state *es = stuff; - struct data_string data; - memset (&data, 0, sizeof data); - - if (evaluate_option_cache (&data, packet, lease, client_state, - in_options, cfg_options, scope, oc, MDL)) { - if (data.len) { - char name [256]; - if (dhcp_option_ev_name (name, sizeof name, - oc -> option)) { - client_envadd (es -> client, es -> prefix, - name, "%s", - (pretty_print_option - (oc -> option, - data.data, data.len, - 0, 0))); - data_string_forget (&data, MDL); - } - } - } -} - -void script_write_params (client, prefix, lease) - struct client_state *client; - const char *prefix; - struct client_lease *lease; -{ - int i; - struct data_string data; - struct option_cache *oc; - pair *hash; - char *s, *t; - struct envadd_state es; - - es.client = client; - es.prefix = prefix; - - client_envadd (client, - prefix, "ip_address", "%s", piaddr (lease -> address)); - - /* For the benefit of Linux (and operating systems which may - have similar needs), compute the network address based on - the supplied ip address and netmask, if provided. Also - compute the broadcast address (the host address all ones - broadcast address, not the host address all zeroes - broadcast address). */ - - memset (&data, 0, sizeof data); - oc = lookup_option (&dhcp_universe, lease -> options, DHO_SUBNET_MASK); - if (oc && evaluate_option_cache (&data, (struct packet *)0, - (struct lease *)0, client, - (struct option_state *)0, - lease -> options, - &global_scope, oc, MDL)) { - if (data.len > 3) { - struct iaddr netmask, subnet, broadcast; - - memcpy (netmask.iabuf, data.data, data.len); - netmask.len = data.len; - data_string_forget (&data, MDL); - - subnet = subnet_number (lease -> address, netmask); - if (subnet.len) { - client_envadd (client, prefix, "network_number", - "%s", piaddr (subnet)); - - oc = lookup_option (&dhcp_universe, - lease -> options, - DHO_BROADCAST_ADDRESS); - if (!oc || - !(evaluate_option_cache - (&data, (struct packet *)0, - (struct lease *)0, client, - (struct option_state *)0, - lease -> options, - &global_scope, oc, MDL))) { - broadcast = broadcast_addr (subnet, netmask); - if (broadcast.len) { - client_envadd (client, - prefix, "broadcast_address", - "%s", piaddr (broadcast)); - } - } - } - } - data_string_forget (&data, MDL); - } - - if (lease -> filename) - client_envadd (client, - prefix, "filename", "%s", lease -> filename); - if (lease -> server_name) - client_envadd (client, prefix, "server_name", - "%s", lease -> server_name); - - for (i = 0; i < lease -> options -> universe_count; i++) { - option_space_foreach ((struct packet *)0, (struct lease *)0, - client, (struct option_state *)0, - lease -> options, &global_scope, - universes [i], - &es, client_option_envadd); - } - client_envadd (client, prefix, "expiry", "%d", (int)(lease -> expiry)); -} - -int script_go (client) - struct client_state *client; -{ - int rval; - char *scriptName; - char *argv [2]; - char **envp; - char *epp [3]; - char reason [] = "REASON=NBI"; - static char client_path [] = CLIENT_PATH; - int i; - struct string_list *sp, *next; - int pid, wpid, wstatus; - - if (client) - scriptName = client -> config -> script_name; - else - scriptName = top_level_config.script_name; - - envp = dmalloc (((client ? client -> envc : 2) + - client_env_count + 2) * sizeof (char *), MDL); - if (!envp) { - log_error ("No memory for client script environment."); - return 0; - } - i = 0; - /* Copy out the environment specified on the command line, - if any. */ - for (sp = client_env; sp; sp = sp -> next) { - envp [i++] = sp -> string; - } - /* Copy out the environment specified by dhclient. */ - if (client) { - for (sp = client -> env; sp; sp = sp -> next) { - envp [i++] = sp -> string; - } - } else { - envp [i++] = reason; - } - /* Set $PATH. */ - envp [i++] = client_path; - envp [i] = (char *)0; - - argv [0] = scriptName; - argv [1] = (char *)0; - - pid = fork (); - if (pid < 0) { - log_error ("fork: %m"); - wstatus = 0; - } else if (pid) { - do { - wpid = wait (&wstatus); - } while (wpid != pid && wpid > 0); - if (wpid < 0) { - log_error ("wait: %m"); - wstatus = 0; - } - } else { - execve (scriptName, argv, envp); - log_error ("execve (%s, ...): %m", scriptName); - exit (0); - } - - if (client) { - for (sp = client -> env; sp; sp = next) { - next = sp -> next; - dfree (sp, MDL); - } - client -> env = (struct string_list *)0; - client -> envc = 0; - } - dfree (envp, MDL); - GET_TIME (&cur_time); - return (WIFEXITED (wstatus) ? - WEXITSTATUS (wstatus) : -WTERMSIG (wstatus)); -} - -void client_envadd (struct client_state *client, - const char *prefix, const char *name, const char *fmt, ...) -{ - char spbuf [1024]; - char *s; - unsigned len, i; - struct string_list *val; - va_list list; - - va_start (list, fmt); - len = vsnprintf (spbuf, sizeof spbuf, fmt, list); - va_end (list); - - val = dmalloc (strlen (prefix) + strlen (name) + 1 /* = */ + - len + sizeof *val, MDL); - if (!val) - return; - s = val -> string; - strcpy (s, prefix); - strcat (s, name); - s += strlen (s); - *s++ = '='; - if (len >= sizeof spbuf) { - va_start (list, fmt); - vsnprintf (s, len + 1, fmt, list); - va_end (list); - } else - strcpy (s, spbuf); - val -> next = client -> env; - client -> env = val; - client -> envc++; -} - -int dhcp_option_ev_name (buf, buflen, option) - char *buf; - size_t buflen; - struct option *option; -{ - int i, j; - const char *s; - - j = 0; - if (option -> universe != &dhcp_universe) { - s = option -> universe -> name; - i = 0; - } else { - s = option -> name; - i = 1; - } - - do { - while (*s) { - if (j + 1 == buflen) - return 0; - if (*s == '-') - buf [j++] = '_'; - else - buf [j++] = *s; - ++s; - } - if (!i) { - s = option -> name; - if (j + 1 == buflen) - return 0; - buf [j++] = '_'; - } - ++i; - } while (i != 2); - - buf [j] = 0; - return 1; -} - -void go_daemon () -{ - static int state = 0; - int pid; - int i; - - /* Don't become a daemon if the user requested otherwise. */ - if (no_daemon) { - write_client_pid_file (); - return; - } - - /* Only do it once. */ - if (state) - return; - state = 1; - - /* Stop logging to stderr... */ - log_perror = 0; - - /* Become a daemon... */ - if ((pid = fork ()) < 0) - log_fatal ("Can't fork daemon: %m"); - else if (pid) - exit (0); - /* Become session leader and get pid... */ - pid = setsid (); - - /* Close standard I/O descriptors. */ - close(0); - close(1); - close(2); - - /* Reopen them on /dev/null. */ - i = open ("/dev/null", O_RDWR); - if (i == 0) - i = open ("/dev/null", O_RDWR); - if (i == 1) { - i = open ("/dev/null", O_RDWR); - log_perror = 0; /* No sense logging to /dev/null. */ - } else if (i != -1) - close (i); - - write_client_pid_file (); -} - -void write_client_pid_file () -{ - FILE *pf; - int pfdesc; - - pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY, 0644); - - if (pfdesc < 0) { - log_error ("Can't create %s: %m", path_dhclient_pid); - return; - } - - pf = fdopen (pfdesc, "w"); - if (!pf) - log_error ("Can't fdopen %s: %m", path_dhclient_pid); - else { - fprintf (pf, "%ld\n", (long)getpid ()); - fclose (pf); - } -} - -void client_location_changed () -{ - struct interface_info *ip; - struct client_state *client; - - for (ip = interfaces; ip; ip = ip -> next) { - for (client = ip -> client; client; client = client -> next) { - switch (client -> state) { - case S_SELECTING: - cancel_timeout (send_discover, client); - break; - - case S_BOUND: - cancel_timeout (state_bound, client); - break; - - case S_REBOOTING: - case S_REQUESTING: - case S_RENEWING: - cancel_timeout (send_request, client); - break; - - case S_INIT: - case S_REBINDING: - case S_STOPPED: - break; - } - client -> state = S_INIT; - state_reboot (client); - } - } -} - -void do_release(client) - struct client_state *client; -{ - struct data_string ds; - struct option_cache *oc; - - /* Pick a random xid. */ - client -> xid = random (); - - /* is there even a lease to release? */ - if (client -> active) { - /* Make a DHCPRELEASE packet, and set appropriate per-interface - flags. */ - make_release (client, client -> active); - - memset (&ds, 0, sizeof ds); - oc = lookup_option (&dhcp_universe, - client -> active -> options, - DHO_DHCP_SERVER_IDENTIFIER); - if (oc && - evaluate_option_cache (&ds, (struct packet *)0, - (struct lease *)0, client, - (struct option_state *)0, - client -> active -> options, - &global_scope, oc, MDL)) { - if (ds.len > 3) { - memcpy (client -> destination.iabuf, - ds.data, 4); - client -> destination.len = 4; - } else - client -> destination = iaddr_broadcast; - - data_string_forget (&ds, MDL); - } else - client -> destination = iaddr_broadcast; - client -> first_sending = cur_time; - client -> interval = client -> config -> initial_interval; - - /* Zap the medium list... */ - client -> medium = (struct string_list *)0; - - /* Send out the first and only DHCPRELEASE packet. */ - send_release (client); - - /* Do the client script RELEASE operation. */ - script_init (client, - "RELEASE", (struct string_list *)0); - if (client -> alias) - script_write_params (client, "alias_", - client -> alias); - script_write_params (client, "old_", client -> active); - script_go (client); - } - - /* Cancel any timeouts. */ - cancel_timeout (state_bound, client); - cancel_timeout (send_discover, client); - cancel_timeout (state_init, client); - cancel_timeout (send_request, client); - cancel_timeout (state_reboot, client); - client -> state = S_STOPPED; -} - -int dhclient_interface_shutdown_hook (struct interface_info *interface) -{ - do_release (interface -> client); - - return 1; -} - -int dhclient_interface_discovery_hook (struct interface_info *tmp) -{ - struct interface_info *last, *ip; - /* See if we can find the client from dummy_interfaces */ - last = 0; - for (ip = dummy_interfaces; ip; ip = ip -> next) { - if (!strcmp (ip -> name, tmp -> name)) { - /* Remove from dummy_interfaces */ - if (last) { - ip = (struct interface_info *)0; - interface_reference (&ip, last -> next, MDL); - interface_dereference (&last -> next, MDL); - if (ip -> next) { - interface_reference (&last -> next, - ip -> next, MDL); - interface_dereference (&ip -> next, - MDL); - } - } else { - ip = (struct interface_info *)0; - interface_reference (&ip, - dummy_interfaces, MDL); - interface_dereference (&dummy_interfaces, MDL); - if (ip -> next) { - interface_reference (&dummy_interfaces, - ip -> next, MDL); - interface_dereference (&ip -> next, - MDL); - } - } - /* Copy "client" to tmp */ - if (ip -> client) { - tmp -> client = ip -> client; - tmp -> client -> interface = tmp; - } - interface_dereference (&ip, MDL); - break; - } - last = ip; - } - return 1; -} - -isc_result_t dhclient_interface_startup_hook (struct interface_info *interface) -{ - struct interface_info *ip; - struct client_state *client; - - /* This code needs some rethinking. It doesn't test against - a signal name, and it just kind of bulls into doing something - that may or may not be appropriate. */ - - if (interfaces) { - interface_reference (&interface -> next, interfaces, MDL); - interface_dereference (&interfaces, MDL); - } - interface_reference (&interfaces, interface, MDL); - - discover_interfaces (DISCOVER_UNCONFIGURED); - - for (ip = interfaces; ip; ip = ip -> next) { - /* If interfaces were specified, don't configure - interfaces that weren't specified! */ - if (ip -> flags & INTERFACE_RUNNING || - (ip -> flags & (INTERFACE_REQUESTED | - INTERFACE_AUTOMATIC)) != - INTERFACE_REQUESTED) - continue; - script_init (ip -> client, - "PREINIT", (struct string_list *)0); - if (ip -> client -> alias) - script_write_params (ip -> client, "alias_", - ip -> client -> alias); - script_go (ip -> client); - } - - discover_interfaces (interfaces_requested - ? DISCOVER_REQUESTED - : DISCOVER_RUNNING); - - for (ip = interfaces; ip; ip = ip -> next) { - if (ip -> flags & INTERFACE_RUNNING) - continue; - ip -> flags |= INTERFACE_RUNNING; - for (client = ip -> client; client; client = client -> next) { - client -> state = S_INIT; - /* Set up a timeout to start the initialization - process. */ - add_timeout (cur_time + random () % 5, - state_reboot, client, 0, 0); - } - } - return ISC_R_SUCCESS; -} - -/* The client should never receive a relay agent information option, - so if it does, log it and discard it. */ - -int parse_agent_information_option (packet, len, data) - struct packet *packet; - int len; - u_int8_t *data; -{ - return 1; -} - -/* The client never sends relay agent information options. */ - -unsigned cons_agent_information_options (cfg_options, outpacket, - agentix, length) - struct option_state *cfg_options; - struct dhcp_packet *outpacket; - unsigned agentix; - unsigned length; -{ - return length; -} - -static void shutdown_exit (void *foo) -{ - exit (0); -} - -isc_result_t dhcp_set_control_state (control_object_state_t oldstate, - control_object_state_t newstate) -{ - struct interface_info *ip; - struct client_state *client; - - /* Do the right thing for each interface. */ - for (ip = interfaces; ip; ip = ip -> next) { - for (client = ip -> client; client; client = client -> next) { - switch (newstate) { - case server_startup: - return ISC_R_SUCCESS; - - case server_running: - return ISC_R_SUCCESS; - - case server_shutdown: - if (client -> active && - client -> active -> expiry > cur_time) { - if (client -> config -> do_forward_update) - client_dns_update (client, 0, 0); - do_release (client); - } - break; - - case server_hibernate: - state_stop (client); - break; - - case server_awaken: - state_reboot (client); - break; - } - } - } - if (newstate == server_shutdown) - add_timeout (cur_time + 1, shutdown_exit, 0, 0, 0); - return ISC_R_SUCCESS; -} - -/* Called after a timeout if the DNS update failed on the previous try. - Retries the update, and if it times out, schedules a retry after - ten times as long of a wait. */ - -void client_dns_update_timeout (void *cp) -{ - struct client_state *client = cp; - isc_result_t status; - - if (client -> active) { - status = client_dns_update (client, 1, - (client -> active -> renewal - - cur_time)); - if (status == ISC_R_TIMEDOUT) { - client -> dns_update_timeout *= 10; - add_timeout (cur_time + client -> dns_update_timeout, - client_dns_update_timeout, client, 0, 0); - } - } -} - -/* See if we should do a DNS update, and if so, do it. */ - -isc_result_t client_dns_update (struct client_state *client, int addp, int ttl) -{ - struct data_string ddns_fqdn, ddns_fwd_name, - ddns_dhcid, client_identifier; - struct option_cache *oc; - int ignorep; - int result; - isc_result_t rcode; - - /* If we didn't send an FQDN option, we certainly aren't going to - be doing an update. */ - if (!client -> sent_options) - return ISC_R_SUCCESS; - - /* If we don't have a lease, we can't do an update. */ - if (!client -> active) - return ISC_R_SUCCESS; - - /* If we set the no client update flag, don't do the update. */ - if ((oc = lookup_option (&fqdn_universe, client -> sent_options, - FQDN_NO_CLIENT_UPDATE)) && - evaluate_boolean_option_cache (&ignorep, (struct packet *)0, - (struct lease *)0, client, - client -> sent_options, - (struct option_state *)0, - &global_scope, oc, MDL)) - return ISC_R_SUCCESS; - - /* If we set the "server, please update" flag, or didn't set it - to false, don't do the update. */ - if (!(oc = lookup_option (&fqdn_universe, client -> sent_options, - FQDN_SERVER_UPDATE)) || - evaluate_boolean_option_cache (&ignorep, (struct packet *)0, - (struct lease *)0, client, - client -> sent_options, - (struct option_state *)0, - &global_scope, oc, MDL)) - return ISC_R_SUCCESS; - - /* If no FQDN option was supplied, don't do the update. */ - memset (&ddns_fwd_name, 0, sizeof ddns_fwd_name); - if (!(oc = lookup_option (&fqdn_universe, client -> sent_options, - FQDN_FQDN)) || - !evaluate_option_cache (&ddns_fwd_name, (struct packet *)0, - (struct lease *)0, client, - client -> sent_options, - (struct option_state *)0, - &global_scope, oc, MDL)) - return ISC_R_SUCCESS; - - /* Make a dhcid string out of either the client identifier, - if we are sending one, or the interface's MAC address, - otherwise. */ - memset (&ddns_dhcid, 0, sizeof ddns_dhcid); - - memset (&client_identifier, 0, sizeof client_identifier); - if ((oc = lookup_option (&dhcp_universe, client -> sent_options, - DHO_DHCP_CLIENT_IDENTIFIER)) && - evaluate_option_cache (&client_identifier, (struct packet *)0, - (struct lease *)0, client, - client -> sent_options, - (struct option_state *)0, - &global_scope, oc, MDL)) { - result = get_dhcid (&ddns_dhcid, - DHO_DHCP_CLIENT_IDENTIFIER, - client_identifier.data, - client_identifier.len); - data_string_forget (&client_identifier, MDL); - } else - result = get_dhcid (&ddns_dhcid, 0, - client -> interface -> hw_address.hbuf, - client -> interface -> hw_address.hlen); - if (!result) { - data_string_forget (&ddns_fwd_name, MDL); - return ISC_R_SUCCESS; - } - - /* Start the resolver, if necessary. */ - if (!resolver_inited) { - minires_ninit (&resolver_state); - resolver_inited = 1; - resolver_state.retrans = 1; - resolver_state.retry = 1; - } - - /* - * Perform updates. - */ - if (ddns_fwd_name.len && ddns_dhcid.len) { - if (addp) - rcode = ddns_update_a (&ddns_fwd_name, - client -> active -> address, - &ddns_dhcid, ttl, - 1); - else - rcode = ddns_remove_a (&ddns_fwd_name, - client -> active -> address, - &ddns_dhcid); - } else - rcode = ISC_R_FAILURE; - - data_string_forget (&ddns_fwd_name, MDL); - data_string_forget (&ddns_dhcid, MDL); - return rcode; -} diff --git a/contrib/dhcp-3.0/client/dhclient.conf b/contrib/dhcp-3.0/client/dhclient.conf deleted file mode 100644 index 147e004..0000000 --- a/contrib/dhcp-3.0/client/dhclient.conf +++ /dev/null @@ -1,36 +0,0 @@ -send host-name "andare.fugue.com"; -send dhcp-client-identifier 1:0:a0:24:ab:fb:9c; -send dhcp-lease-time 3600; -supersede domain-name "fugue.com home.vix.com"; -prepend domain-name-servers 127.0.0.1; -request subnet-mask, broadcast-address, time-offset, routers, - domain-name, domain-name-servers, host-name; -require subnet-mask, domain-name-servers; -timeout 60; -retry 60; -reboot 10; -select-timeout 5; -initial-interval 2; -script "/etc/dhclient-script"; -media "-link0 -link1 -link2", "link0 link1"; -reject 192.33.137.209; - -alias { - interface "ep0"; - fixed-address 192.5.5.213; - option subnet-mask 255.255.255.255; -} - -lease { - interface "ep0"; - fixed-address 192.33.137.200; - medium "link0 link1"; - option host-name "andare.swiftmedia.com"; - option subnet-mask 255.255.255.0; - option broadcast-address 192.33.137.255; - option routers 192.33.137.250; - option domain-name-servers 127.0.0.1; - renew 2 2000/1/12 00:00:01; - rebind 2 2000/1/12 00:00:01; - expire 2 2000/1/12 00:00:01; -} diff --git a/contrib/dhcp-3.0/client/dhclient.conf.5 b/contrib/dhcp-3.0/client/dhclient.conf.5 deleted file mode 100644 index cc63f85..0000000 --- a/contrib/dhcp-3.0/client/dhclient.conf.5 +++ /dev/null @@ -1,623 +0,0 @@ -.\" $Id: dhclient.conf.5,v 1.12.2.11 2004/09/10 21:02:30 dhankins Exp $ -.\" -.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") -.\" Copyright (c) 1996-2003 by Internet Software Consortium -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.\" Internet Systems Consortium, Inc. -.\" 950 Charter Street -.\" Redwood City, CA 94063 -.\" -.\" http://www.isc.org/ -.\" -.\" This software has been written for Internet Software Consortium -.\" by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. -.\" To learn more about Internet Software Consortium, see -.\" ``http://www.isc.org/''. To learn more about Vixie Enterprises, -.\" see ``http://www.vix.com''. To learn more about Nominum, Inc., see -.\" ``http://www.nominum.com''. -.TH dhclient.conf 5 -.SH NAME -dhclient.conf - DHCP client configuration file -.SH DESCRIPTION -The dhclient.conf file contains configuration information for -.IR dhclient, -the Internet Systems Consortium DHCP Client. -.PP -The dhclient.conf file is a free-form ASCII text file. It is parsed by -the recursive-descent parser built into dhclient. The file may contain -extra tabs and newlines for formatting purposes. Keywords in the file -are case-insensitive. Comments may be placed anywhere within the -file (except within quotes). Comments begin with the # character and -end at the end of the line. -.PP -The dhclient.conf file can be used to configure the behaviour of the -client in a wide variety of ways: protocol timing, information -requested from the server, information required of the server, -defaults to use if the server does not provide certain information, -values with which to override information provided by the server, or -values to prepend or append to information provided by the server. -The configuration file can also be preinitialized with addresses to -use on networks that don't have DHCP servers. -.SH PROTOCOL TIMING -The timing behaviour of the client need not be configured by the user. -If no timing configuration is provided by the user, a fairly -reasonable timing behaviour will be used by default - one which -results in fairly timely updates without placing an inordinate load on -the server. -.PP -The following statements can be used to adjust the timing behaviour of -the DHCP client if required, however: -.PP -.I The -.B timeout -.I statement -.PP -.B timeout -.I time -.B ; -.PP -The -.I timeout -statement determines the amount of time that must pass between the -time that the client begins to try to determine its address and the -time that it decides that it's not going to be able to contact a -server. By default, this timeout is sixty seconds. After the -timeout has passed, if there are any static leases defined in the -configuration file, or any leases remaining in the lease database that -have not yet expired, the client will loop through these leases -attempting to validate them, and if it finds one that appears to be -valid, it will use that lease's address. If there are no valid -static leases or unexpired leases in the lease database, the client -will restart the protocol after the defined retry interval. -.PP -.I The -.B retry -.I statement -.PP - \fBretry \fItime\fR\fB;\fR -.PP -The -.I retry -statement determines the time that must pass after the client has -determined that there is no DHCP server present before it tries again -to contact a DHCP server. By default, this is five minutes. -.PP -.I The -.B select-timeout -.I statement -.PP - \fBselect-timeout \fItime\fR\fB;\fR -.PP -It is possible (some might say desirable) for there to be more than -one DHCP server serving any given network. In this case, it is -possible that a client may be sent more than one offer in response to -its initial lease discovery message. It may be that one of these -offers is preferable to the other (e.g., one offer may have the -address the client previously used, and the other may not). -.PP -The -.I select-timeout -is the time after the client sends its first lease discovery request -at which it stops waiting for offers from servers, assuming that it -has received at least one such offer. If no offers have been -received by the time the -.I select-timeout -has expired, the client will accept the first offer that arrives. -.PP -By default, the select-timeout is zero seconds - that is, the client -will take the first offer it sees. -.PP -.I The -.B reboot -.I statement -.PP - \fBreboot \fItime\fR\fB;\fR -.PP -When the client is restarted, it first tries to reacquire the last -address it had. This is called the INIT-REBOOT state. If it is -still attached to the same network it was attached to when it last -ran, this is the quickest way to get started. The -.I reboot -statement sets the time that must elapse after the client first tries -to reacquire its old address before it gives up and tries to discover -a new address. By default, the reboot timeout is ten seconds. -.PP -.I The -.B backoff-cutoff -.I statement -.PP - \fBbackoff-cutoff \fItime\fR\fB;\fR -.PP -The client uses an exponential backoff algorithm with some randomness, -so that if many clients try to configure themselves at the same time, -they will not make their requests in lockstep. The -.I backoff-cutoff -statement determines the maximum amount of time that the client is -allowed to back off, the actual value will be evaluated randomly between -1/2 to 1 1/2 times the \fItime\fR specified. It defaults to two minutes. -.PP -.I The -.B initial-interval -.I statement -.PP - \fBinitial-interval \fItime\fR\fB;\fR -.PP -The -.I initial-interval -statement sets the amount of time between the first attempt to reach a -server and the second attempt to reach a server. Each time a message -is sent, the interval between messages is incremented by twice the -current interval multiplied by a random number between zero and one. -If it is greater than the backoff-cutoff amount, it is set to that -amount. It defaults to ten seconds. -.SH LEASE REQUIREMENTS AND REQUESTS -The DHCP protocol allows the client to request that the server send it -specific information, and not send it other information that it is not -prepared to accept. The protocol also allows the client to reject -offers from servers if they don't contain information the client -needs, or if the information provided is not satisfactory. -.PP -There is a variety of data contained in offers that DHCP servers send -to DHCP clients. The data that can be specifically requested is what -are called \fIDHCP Options\fR. DHCP Options are defined in - \fBdhcp-options(5)\fR. -.PP -.I The -.B request -.I statement -.PP - \fBrequest [ \fIoption\fR ] [\fB,\fI ... \fIoption\fR ]\fB;\fR -.PP -The request statement causes the client to request that any server -responding to the client send the client its values for the specified -options. Only the option names should be specified in the request -statement - not option parameters. By default, the DHCP server -requests the subnet-mask, broadcast-address, time-offset, routers, -domain-name, domain-name-servers and host-name options. -.PP -In some cases, it may be desirable to send no parameter request list -at all. To do this, simply write the request statement but specify -no parameters: -.PP -.nf - request; -.fi -.PP -.I The -.B require -.I statement -.PP - \fBrequire [ \fIoption\fR ] [\fB,\fI ... \fIoption ]\fB;\fR -.PP -The require statement lists options that must be sent in order for an -offer to be accepted. Offers that do not contain all the listed -options will be ignored. -.PP -.I The -.B send -.I statement -.PP - \fBsend { [ \fIoption declaration\fR ] -[\fB,\fI ... \fIoption declaration\fR ]\fB}\fR -.PP -The send statement causes the client to send the specified options to -the server with the specified values. These are full option -declarations as described in \fBdhcp-options(5)\fR. Options that are -always sent in the DHCP protocol should not be specified here, except -that the client can specify a \fBrequested-lease-time\fR option other -than the default requested lease time, which is two hours. The other -obvious use for this statement is to send information to the server -that will allow it to differentiate between this client and other -clients or kinds of clients. -.SH DYNAMIC DNS -The client now has some very limited support for doing DNS updates -when a lease is acquired. This is prototypical, and probably doesn't -do what you want. It also only works if you happen to have control -over your DNS server, which isn't very likely. -.PP -To make it work, you have to declare a key and zone as in the DHCP -server (see \fBdhcpd.conf\fR(5) for details). You also need to -configure the fqdn option on the client, as follows: -.PP -.nf - send fqdn.fqdn "grosse.fugue.com."; - send fqdn.encoded on; - send fqdn.server-update off; -.fi -.PP -The \fIfqdn.fqdn\fR option \fBMUST\fR be a fully-qualified domain -name. You \fBMUST\fR define a zone statement for the zone to be -updated. The \fIfqdn.encoded\fR option may need to be set to -\fIon\fR or \fIoff\fR, depending on the DHCP server you are using. -.PP -.I The -.B do-forward-updates -.I statement -.PP - \fBdo-forward-updates [ \fIflag\fR ] \fB;\fR -.PP -If you want to do DNS updates in the DHCP client -script (see \fBdhclient-script(8)\fR) rather than having the -DHCP client do the update directly (for example, if you want to -use SIG(0) authentication, which is not supported directly by the -DHCP client, you can instruct the client not to do the update using -the \fBdo-forward-updates\fR statement. \fIFlag\fR should be \fBtrue\fR -if you want the DHCP client to do the update, and \fBfalse\fR if -you don't want the DHCP client to do the update. By default, the DHCP -client will do the DNS update. -.SH OPTION MODIFIERS -In some cases, a client may receive option data from the server which -is not really appropriate for that client, or may not receive -information that it needs, and for which a useful default value -exists. It may also receive information which is useful, but which -needs to be supplemented with local information. To handle these -needs, several option modifiers are available. -.PP -.I The -.B default -.I statement -.PP - \fBdefault [ \fIoption declaration\fR ] \fB;\fR -.PP -If for some option the client should use the value supplied by -the server, but needs to use some default value if no value was supplied -by the server, these values can be defined in the -.B default -statement. -.PP -.I The -.B supersede -.I statement -.PP - \fBsupersede [ \fIoption declaration\fR ] \fB;\fR -.PP -If for some option the client should always use a locally-configured -value or values rather than whatever is supplied by the server, these -values can be defined in the -.B supersede -statement. -.PP -.I The -.B prepend -.I statement -.PP - \fBprepend [ \fIoption declaration\fR ] \fB;\fR -.PP -If for some set of options the client should use a value you -supply, and then use the values supplied by -the server, if any, these values can be defined in the -.B prepend -statement. The -.B prepend -statement can only be used for options which -allow more than one value to be given. This restriction is not -enforced - if you ignore it, the behaviour will be unpredictable. -.PP -.I The -.B append -.I statement -.PP - \fBappend [ \fIoption declaration\fR ] \fB;\fR -.PP -If for some set of options the client should first use the values -supplied by the server, if any, and then use values you supply, these -values can be defined in the -.B append -statement. The -.B append -statement can only be used for options which -allow more than one value to be given. This restriction is not -enforced - if you ignore it, the behaviour will be unpredictable. -.SH LEASE DECLARATIONS -.PP -.I The -.B lease -.I declaration -.PP - \fBlease {\fR \fIlease-declaration\fR [ ... \fIlease-declaration ] \fB}\fR -.PP -The DHCP client may decide after some period of time (see \fBPROTOCOL -TIMING\fR) that it is not going to succeed in contacting a -server. At that time, it consults its own database of old leases and -tests each one that has not yet timed out by pinging the listed router -for that lease to see if that lease could work. It is possible to -define one or more \fIfixed\fR leases in the client configuration file -for networks where there is no DHCP or BOOTP service, so that the -client can still automatically configure its address. This is done -with the -.B lease -statement. -.PP -NOTE: the lease statement is also used in the dhclient.leases file in -order to record leases that have been received from DHCP servers. -Some of the syntax for leases as described below is only needed in the -dhclient.leases file. Such syntax is documented here for -completeness. -.PP -A lease statement consists of the lease keyword, followed by a left -curly brace, followed by one or more lease declaration statements, -followed by a right curly brace. The following lease declarations -are possible: -.PP - \fBbootp;\fR -.PP -The -.B bootp -statement is used to indicate that the lease was acquired using the -BOOTP protocol rather than the DHCP protocol. It is never necessary -to specify this in the client configuration file. The client uses -this syntax in its lease database file. -.PP - \fBinterface\fR \fB"\fR\fIstring\fR\fB";\fR -.PP -The -.B interface -lease statement is used to indicate the interface on which the lease -is valid. If set, this lease will only be tried on a particular -interface. When the client receives a lease from a server, it always -records the interface number on which it received that lease. -If predefined leases are specified in the dhclient.conf file, the -interface should also be specified, although this is not required. -.PP - \fBfixed-address\fR \fIip-address\fR\fB;\fR -.PP -The -.B fixed-address -statement is used to set the ip address of a particular lease. This -is required for all lease statements. The IP address must be -specified as a dotted quad (e.g., 12.34.56.78). -.PP - \fBfilename "\fR\fIstring\fR\fB";\fR -.PP -The -.B filename -statement specifies the name of the boot filename to use. This is -not used by the standard client configuration script, but is included -for completeness. -.PP - \fBserver-name "\fR\fIstring\fR\fB";\fR -.PP -The -.B server-name -statement specifies the name of the boot server name to use. This is -also not used by the standard client configuration script. -.PP - \fBoption\fR \fIoption-declaration\fR\fB;\fR -.PP -The -.B option -statement is used to specify the value of an option supplied by the -server, or, in the case of predefined leases declared in -dhclient.conf, the value that the user wishes the client configuration -script to use if the predefined lease is used. -.PP - \fBscript "\fIscript-name\fB";\fR -.PP -The -.B script -statement is used to specify the pathname of the dhcp client -configuration script. This script is used by the dhcp client to set -each interface's initial configuration prior to requesting an address, -to test the address once it has been offered, and to set the -interface's final configuration once a lease has been acquired. If -no lease is acquired, the script is used to test predefined leases, if -any, and also called once if no valid lease can be identified. For -more information, see -.B dhclient-script(8). -.PP - \fBvendor option space "\fIname\fB";\fR -.PP -The -.B vendor option space -statement is used to specify which option space should be used for -decoding the vendor-encapsulate-options option if one is received. -The \fIdhcp-vendor-identifier\fR can be used to request a specific -class of vendor options from the server. See -.B dhcp-options(5) -for details. -.PP - \fBmedium "\fImedia setup\fB";\fR -.PP -The -.B medium -statement can be used on systems where network interfaces cannot -automatically determine the type of network to which they are -connected. The media setup string is a system-dependent parameter -which is passed to the dhcp client configuration script when -initializing the interface. On Unix and Unix-like systems, the -argument is passed on the ifconfig command line when configuring the -interface. -.PP -The dhcp client automatically declares this parameter if it uses a -media type (see the -.B media -statement) when configuring the interface in order to obtain a lease. -This statement should be used in predefined leases only if the network -interface requires media type configuration. -.PP - \fBrenew\fR \fIdate\fB;\fR -.PP - \fBrebind\fR \fIdate\fB;\fR -.PP - \fBexpire\fR \fIdate\fB;\fR -.PP -The \fBrenew\fR statement defines the time at which the dhcp client -should begin trying to contact its server to renew a lease that it is -using. The \fBrebind\fR statement defines the time at which the dhcp -client should begin to try to contact \fIany\fR dhcp server in order -to renew its lease. The \fBexpire\fR statement defines the time at -which the dhcp client must stop using a lease if it has not been able -to contact a server in order to renew it. -.PP -These declarations are automatically set in leases acquired by the -DHCP client, but must also be configured in predefined leases - a -predefined lease whose expiry time has passed will not be used by the -DHCP client. -.PP -Dates are specified as follows: -.PP - \fI \fB/\fI\fB/\fI -\fB:\fI\fB:\fI\fR -.PP -The weekday is present to make it easy for a human to tell when a -lease expires - it's specified as a number from zero to six, with zero -being Sunday. When declaring a predefined lease, it can always be -specified as zero. The year is specified with the century, so it -should generally be four digits except for really long leases. The -month is specified as a number starting with 1 for January. The day -of the month is likewise specified starting with 1. The hour is a -number between 0 and 23, the minute a number between 0 and 59, and the -second also a number between 0 and 59. -.SH ALIAS DECLARATIONS - \fBalias { \fI declarations ... \fB}\fR -.PP -Some DHCP clients running TCP/IP roaming protocols may require that in -addition to the lease they may acquire via DHCP, their interface also -be configured with a predefined IP alias so that they can have a -permanent IP address even while roaming. The Internet Systems -Consortium DHCP client doesn't support roaming with fixed addresses -directly, but in order to facilitate such experimentation, the dhcp -client can be set up to configure an IP alias using the -.B alias -declaration. -.PP -The alias declaration resembles a lease declaration, except that -options other than the subnet-mask option are ignored by the standard -client configuration script, and expiry times are ignored. A typical -alias declaration includes an interface declaration, a fixed-address -declaration for the IP alias address, and a subnet-mask option -declaration. A medium statement should never be included in an alias -declaration. -.SH OTHER DECLARATIONS - \fBreject \fIip-address\fB;\fR -.PP -The -.B reject -statement causes the DHCP client to reject offers from -servers who use the specified address as a server identifier. This -can be used to avoid being configured by rogue or misconfigured dhcp -servers, although it should be a last resort - better to track down -the bad DHCP server and fix it. -.PP - \fBinterface "\fIname\fB" { \fIdeclarations ... \fB } -.PP -A client with more than one network interface may require different -behaviour depending on which interface is being configured. All -timing parameters and declarations other than lease and alias -declarations can be enclosed in an interface declaration, and those -parameters will then be used only for the interface that matches the -specified name. Interfaces for which there is no interface -declaration will use the parameters declared outside of any interface -declaration, or the default settings. -.PP - \fBpseudo "\fIname\fR" "\fIreal-name\fB" { \fIdeclarations ... \fB } -.PP -Under some circumstances it can be useful to declare a pseudo-interface -and have the DHCP client acquire a configuration for that interface. -Each interface that the DHCP client is supporting normally has a DHCP -client state machine running on it to acquire and maintain its lease. -A pseudo-interface is just another state machine running on the -interface named \fIreal-name\fR, with its own lease and its own -state. If you use this feature, you must provide a client identifier -for both the pseudo-interface and the actual interface, and the two -identifiers must be different. You must also provide a separate -client script for the pseudo-interface to do what you want with the IP -address. For example: -.PP -.nf - interface "ep0" { - send dhcp-client-identifier "my-client-ep0"; - } - pseudo "secondary" "ep0" { - send dhcp-client-identifier "my-client-ep0-secondary"; - script "/etc/dhclient-secondary"; - } -.fi -.PP -The client script for the pseudo-interface should not configure the -interface up or down - essentially, all it needs to handle are the -states where a lease has been acquired or renewed, and the states -where a lease has expired. See \fBdhclient-script(8)\fR for more -information. -.PP - \fBmedia "\fImedia setup\fB"\fI [ \fB, "\fImedia setup\fB", \fI... ]\fB;\fR -.PP -The -.B media -statement defines one or more media configuration parameters which may -be tried while attempting to acquire an IP address. The dhcp client -will cycle through each media setup string on the list, configuring -the interface using that setup and attempting to boot, and then trying -the next one. This can be used for network interfaces which aren't -capable of sensing the media type unaided - whichever media type -succeeds in getting a request to the server and hearing the reply is -probably right (no guarantees). -.PP -The media setup is only used for the initial phase of address -acquisition (the DHCPDISCOVER and DHCPOFFER packets). Once an -address has been acquired, the dhcp client will record it in its lease -database and will record the media type used to acquire the address. -Whenever the client tries to renew the lease, it will use that same -media type. The lease must expire before the client will go back to -cycling through media types. -.SH SAMPLE -The following configuration file is used on a laptop running NetBSD -1.3. The laptop has an IP alias of 192.5.5.213, and has one -interface, ep0 (a 3com 3C589C). Booting intervals have been -shortened somewhat from the default, because the client is known to -spend most of its time on networks with little DHCP activity. The -laptop does roam to multiple networks. - -.nf - -timeout 60; -retry 60; -reboot 10; -select-timeout 5; -initial-interval 2; -reject 192.33.137.209; - -interface "ep0" { - send host-name "andare.fugue.com"; - send dhcp-client-identifier 1:0:a0:24:ab:fb:9c; - send dhcp-lease-time 3600; - supersede domain-name "fugue.com rc.vix.com home.vix.com"; - prepend domain-name-servers 127.0.0.1; - request subnet-mask, broadcast-address, time-offset, routers, - domain-name, domain-name-servers, host-name; - require subnet-mask, domain-name-servers; - script "CLIENTBINDIR/dhclient-script"; - media "media 10baseT/UTP", "media 10base2/BNC"; -} - -alias { - interface "ep0"; - fixed-address 192.5.5.213; - option subnet-mask 255.255.255.255; -} -.fi -This is a very complicated dhclient.conf file - in general, yours -should be much simpler. In many cases, it's sufficient to just -create an empty dhclient.conf file - the defaults are usually fine. -.SH SEE ALSO -dhcp-options(5), dhclient.leases(5), dhcpd(8), dhcpd.conf(5), RFC2132, -RFC2131. -.SH AUTHOR -.B dhclient(8) -was written by Ted Lemon -under a contract with Vixie Labs. Funding -for this project was provided by Internet Systems Consortium. -Information about Internet Systems Consortium can be found at -.B http://www.isc.org. diff --git a/contrib/dhcp-3.0/client/dhclient.leases.5 b/contrib/dhcp-3.0/client/dhclient.leases.5 deleted file mode 100644 index 204a800..0000000 --- a/contrib/dhcp-3.0/client/dhclient.leases.5 +++ /dev/null @@ -1,53 +0,0 @@ -.\" $Id: dhclient.leases.5,v 1.2.4.4 2004/06/10 17:59:13 dhankins Exp $ -.\" -.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") -.\" Copyright (c) 1997-2003 by Internet Software Consortium -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.\" Internet Systems Consortium, Inc. -.\" 950 Charter Street -.\" Redwood City, CA 94063 -.\" -.\" http://www.isc.org/ -.\" -.\" This software has been written for Internet Systems Consortium -.\" by Ted Lemon in cooperation with Vixie -.\" Enterprises. To learn more about Internet Systems Consortium, -.\" see ``http://www.isc.org/isc''. To learn more about Vixie -.\" Enterprises, see ``http://www.vix.com''. -.TH dhclient.leases 5 -.SH NAME -dhclient.leases - DHCP client lease database -.SH DESCRIPTION -The Internet Systems Consortium DHCP client keeps a persistent -database of leases that it has acquired that are still valid. The -database is a free-form ASCII file containing one valid declaration -per lease. If more than one declaration appears for a given lease, -the last one in the file is used. The file is written as a log, so -this is not an unusual occurrance. -.PP -The format of the lease declarations is described in -.B dhclient.conf(5). -.SH FILES -.B DBDIR/dhclient.leases -.SH SEE ALSO -dhclient(8), dhcp-options(5), dhclient.conf(5), dhcpd(8), -dhcpd.conf(5), RFC2132, RFC2131. -.SH AUTHOR -.B dhclient(8) -was written by Ted Lemon -under a contract with Vixie Labs. Funding -for this project was provided by Internet Systems Consortium. -Information about Internet Systems Consortium can be found at -.B http://www.isc.org. diff --git a/contrib/dhcp-3.0/client/scripts/freebsd b/contrib/dhcp-3.0/client/scripts/freebsd deleted file mode 100755 index 2058c13..0000000 --- a/contrib/dhcp-3.0/client/scripts/freebsd +++ /dev/null @@ -1,242 +0,0 @@ -#!/bin/sh -# -# $Id: freebsd,v 1.13.2.7 2004/09/30 23:22:48 dhankins Exp $ -# -# $FreeBSD$ - -if [ -x /usr/bin/logger ]; then - LOGGER="/usr/bin/logger -s -p user.notice -t dhclient" -else - LOGGER=echo -fi - -make_resolv_conf() { - if [ x"$new_domain_name_servers" != x ]; then - if [ "x$new_domain_name" != x ]; then - ( echo search $new_domain_name >/etc/resolv.conf ) - exit_status=$? - else - if [ -e /etc/resolv.conf ] ; then - ( rm /etc/resolv.conf ) - exit_status=$? - else - ( touch /etc/resolv.conf ) - exit_status=$? - fi - fi - if [ $exit_status -ne 0 ]; then - $LOGGER "WARNING: Unable to update resolv.conf: Error $exit_status" - else - for nameserver in $new_domain_name_servers; do - ( echo nameserver $nameserver >>/etc/resolv.conf ) - done - fi - fi -} - -# Must be used on exit. Invokes the local dhcp client exit hooks, if any. -exit_with_hooks() { - exit_status=$1 - if [ -f /etc/dhclient-exit-hooks ]; then - . /etc/dhclient-exit-hooks - fi -# probably should do something with exit status of the local script - exit $exit_status -} - -# Invoke the local dhcp client enter hooks, if they exist. -if [ -f /etc/dhclient-enter-hooks ]; then - exit_status=0 - . /etc/dhclient-enter-hooks - # allow the local script to abort processing of this state - # local script must set exit_status variable to nonzero. - if [ $exit_status -ne 0 ]; then - exit $exit_status - fi -fi - -if [ x$new_network_number != x ]; then - $LOGGER New Network Number: $new_network_number -fi - -if [ x$new_broadcast_address != x ]; then - $LOGGER New Broadcast Address: $new_broadcast_address - new_broadcast_arg="broadcast $new_broadcast_address" -fi -if [ x$old_broadcast_address != x ]; then - old_broadcast_arg="broadcast $old_broadcast_address" -fi -if [ x$new_subnet_mask != x ]; then - new_netmask_arg="netmask $new_subnet_mask" -fi -if [ x$old_subnet_mask != x ]; then - old_netmask_arg="netmask $old_subnet_mask" -fi -if [ x$alias_subnet_mask != x ]; then - alias_subnet_arg="netmask $alias_subnet_mask" -fi - -if [ x$reason = xMEDIUM ]; then - eval "ifconfig $interface $medium" - eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1 - sleep 1 - exit_with_hooks 0 -fi - -if [ x$reason = xPREINIT ]; then - if [ x$alias_ip_address != x ]; then - ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1 - route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1 - fi - ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \ - broadcast 255.255.255.255 up - exit_with_hooks 0 -fi - -if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then - exit_with_hooks 0; -fi - -if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ - [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then - current_hostname=`/bin/hostname` - if [ x$current_hostname = x ] || \ - [ x$current_hostname = x$old_host_name ]; then - if [ x$current_hostname = x ] || \ - [ x$new_host_name != x$old_host_name ]; then - $LOGGER "New Hostname: $new_host_name" - hostname $new_host_name - fi - fi - if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \ - [ x$alias_ip_address != x$old_ip_address ]; then - ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1 - route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1 - fi - if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ] - then - eval "ifconfig $interface inet -alias $old_ip_address $medium" - route delete $old_ip_address 127.1 >/dev/null 2>&1 - for router in $old_routers; do - route delete default $router >/dev/null 2>&1 - done - if [ -n "$old_static_routes" ]; then - set -- $old_static_routes - while [ $# -gt 1 ]; do - route delete $1 $2 - shift; shift - done - fi - arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' |sh - fi - if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ - [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then - eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \ - $new_broadcast_arg $medium" - $LOGGER "New IP Address ($interface): $new_ip_address" - $LOGGER "New Subnet Mask ($interface): $new_subnet_mask" - $LOGGER "New Broadcast Address ($interface): $new_broadcast_address" - if [ -n "$new_routers" ]; then - $LOGGER "New Routers: $new_routers" - fi - route add $new_ip_address 127.1 >/dev/null 2>&1 - for router in $new_routers; do - route add default $router >/dev/null 2>&1 - done - if [ -n "$new_static_routes" ]; then - $LOGGER "New Static Routes: $new_static_routes" - set -- $new_static_routes - while [ $# -gt 1 ]; do - route add $1 $2 - shift; shift - done - fi - fi - if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ]; - then - ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg - route add $alias_ip_address 127.0.0.1 - fi - make_resolv_conf - exit_with_hooks 0 -fi - -if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \ - || [ x$reason = xSTOP ]; then - if [ x$alias_ip_address != x ]; then - ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1 - route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1 - fi - if [ x$old_ip_address != x ]; then - eval "ifconfig $interface inet -alias $old_ip_address $medium" - route delete $old_ip_address 127.1 >/dev/null 2>&1 - for router in $old_routers; do - route delete default $router >/dev/null 2>&1 - done - if [ -n "$old_static_routes" ]; then - set -- $old_static_routes - while [ $# -gt 1 ]; do - route delete $1 $2 - shift; shift - done - fi - arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \ - |sh >/dev/null 2>&1 - fi - if [ x$alias_ip_address != x ]; then - ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg - route add $alias_ip_address 127.0.0.1 - fi - exit_with_hooks 0 -fi - -if [ x$reason = xTIMEOUT ]; then - if [ x$alias_ip_address != x ]; then - ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1 - route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1 - fi - eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \ - $new_broadcast_arg $medium" - $LOGGER "New IP Address ($interface): $new_ip_address" - $LOGGER "New Subnet Mask ($interface): $new_subnet_mask" - $LOGGER "New Broadcast Address ($interface): $new_broadcast_address" - sleep 1 - if [ -n "$new_routers" ]; then - $LOGGER "New Routers: $new_routers" - set -- $new_routers - if ping -q -c 1 $1; then - if [ x$new_ip_address != x$alias_ip_address ] && \ - [ x$alias_ip_address != x ]; then - ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg - route add $alias_ip_address 127.0.0.1 - fi - route add $new_ip_address 127.1 >/dev/null 2>&1 - for router in $new_routers; do - route add default $router >/dev/null 2>&1 - done - set -- $new_static_routes - while [ $# -gt 1 ]; do - route add $1 $2 - shift; shift - done - make_resolv_conf - exit_with_hooks 0 - fi - fi - eval "ifconfig $interface inet -alias $new_ip_address $medium" - for router in $old_routers; do - route delete default $router >/dev/null 2>&1 - done - if [ -n "$old_static_routes" ]; then - set -- $old_static_routes - while [ $# -gt 1 ]; do - route delete $1 $2 - shift; shift - done - fi - arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \ - |sh >/dev/null 2>&1 - exit_with_hooks 1 -fi - -exit_with_hooks 0 diff --git a/contrib/dhcp-3.0/common/alloc.c b/contrib/dhcp-3.0/common/alloc.c deleted file mode 100644 index 39edd81..0000000 --- a/contrib/dhcp-3.0/common/alloc.c +++ /dev/null @@ -1,1317 +0,0 @@ -/* alloc.c - - Memory allocation... */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996-2003 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Internet Systems Consortium, Inc. - * 950 Charter Street - * Redwood City, CA 94063 - * - * http://www.isc.org/ - * - * This software has been written for Internet Systems Consortium - * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. - * To learn more about Internet Systems Consortium, see - * ``http://www.isc.org/''. To learn more about Vixie Enterprises, - * see ``http://www.vix.com''. To learn more about Nominum, Inc., see - * ``http://www.nominum.com''. - */ - -#ifndef lint -static char copyright[] = -"$Id: alloc.c,v 1.53.2.10 2004/06/10 17:59:14 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" -#include - -struct dhcp_packet *dhcp_free_list; -struct packet *packet_free_list; - -int option_chain_head_allocate (ptr, file, line) - struct option_chain_head **ptr; - const char *file; - int line; -{ - int size; - struct option_chain_head *h; - - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct option_chain_head *)0; -#endif - } - - h = dmalloc (sizeof *h, file, line); - if (h) { - memset (h, 0, sizeof *h); - return option_chain_head_reference (ptr, h, file, line); - } - return 0; -} - -int option_chain_head_reference (ptr, bp, file, line) - struct option_chain_head **ptr; - struct option_chain_head *bp; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct option_chain_head *)0; -#endif - } - *ptr = bp; - bp -> refcnt++; - rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC); - return 1; -} - -int option_chain_head_dereference (ptr, file, line) - struct option_chain_head **ptr; - const char *file; - int line; -{ - int i; - struct option_chain_head *option_chain_head; - pair car, cdr; - - if (!ptr || !*ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - option_chain_head = *ptr; - *ptr = (struct option_chain_head *)0; - --option_chain_head -> refcnt; - rc_register (file, line, ptr, option_chain_head, - option_chain_head -> refcnt, 1, RC_MISC); - if (option_chain_head -> refcnt > 0) - return 1; - - if (option_chain_head -> refcnt < 0) { - log_error ("%s(%d): negative refcnt!", file, line); -#if defined (DEBUG_RC_HISTORY) - dump_rc_history (option_chain_head); -#endif -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - /* If there are any options on this head, free them. */ - for (car = option_chain_head -> first; car; car = cdr) { - cdr = car -> cdr; - if (car -> car) - option_cache_dereference ((struct option_cache **) - (&car -> car), MDL); - dfree (car, MDL); - car = cdr; - } - - dfree (option_chain_head, file, line); - return 1; -} - -int group_allocate (ptr, file, line) - struct group **ptr; - const char *file; - int line; -{ - int size; - struct group *g; - - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct group *)0; -#endif - } - - g = dmalloc (sizeof *g, file, line); - if (g) { - memset (g, 0, sizeof *g); - return group_reference (ptr, g, file, line); - } - return 0; -} - -int group_reference (ptr, bp, file, line) - struct group **ptr; - struct group *bp; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct group *)0; -#endif - } - *ptr = bp; - bp -> refcnt++; - rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC); - return 1; -} - -int group_dereference (ptr, file, line) - struct group **ptr; - const char *file; - int line; -{ - int i; - struct group *group; - - if (!ptr || !*ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - group = *ptr; - *ptr = (struct group *)0; - --group -> refcnt; - rc_register (file, line, ptr, group, group -> refcnt, 1, RC_MISC); - if (group -> refcnt > 0) - return 1; - - if (group -> refcnt < 0) { - log_error ("%s(%d): negative refcnt!", file, line); -#if defined (DEBUG_RC_HISTORY) - dump_rc_history (group); -#endif -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - if (group -> object) - group_object_dereference (&group -> object, file, line); - if (group -> subnet) - subnet_dereference (&group -> subnet, file, line); - if (group -> shared_network) - shared_network_dereference (&group -> shared_network, - file, line); - if (group -> statements) - executable_statement_dereference (&group -> statements, - file, line); - if (group -> next) - group_dereference (&group -> next, file, line); - dfree (group, file, line); - return 1; -} - -struct dhcp_packet *new_dhcp_packet (file, line) - const char *file; - int line; -{ - struct dhcp_packet *rval; - rval = (struct dhcp_packet *)dmalloc (sizeof (struct dhcp_packet), - file, line); - return rval; -} - -struct protocol *new_protocol (file, line) - const char *file; - int line; -{ - struct protocol *rval = dmalloc (sizeof (struct protocol), file, line); - return rval; -} - -struct domain_search_list *new_domain_search_list (file, line) - const char *file; - int line; -{ - struct domain_search_list *rval = - dmalloc (sizeof (struct domain_search_list), file, line); - return rval; -} - -struct name_server *new_name_server (file, line) - const char *file; - int line; -{ - struct name_server *rval = - dmalloc (sizeof (struct name_server), file, line); - return rval; -} - -void free_name_server (ptr, file, line) - struct name_server *ptr; - const char *file; - int line; -{ - dfree ((VOIDPTR)ptr, file, line); -} - -struct option *new_option (file, line) - const char *file; - int line; -{ - struct option *rval = - dmalloc (sizeof (struct option), file, line); - if (rval) - memset (rval, 0, sizeof *rval); - return rval; -} - -void free_option (ptr, file, line) - struct option *ptr; - const char *file; - int line; -{ -/* XXX have to put all options on heap before this is possible. */ -#if 0 - if (ptr -> name) - dfree ((VOIDPTR)option -> name, file, line); - dfree ((VOIDPTR)ptr, file, line); -#endif -} - -struct universe *new_universe (file, line) - const char *file; - int line; -{ - struct universe *rval = - dmalloc (sizeof (struct universe), file, line); - return rval; -} - -void free_universe (ptr, file, line) - struct universe *ptr; - const char *file; - int line; -{ - dfree ((VOIDPTR)ptr, file, line); -} - -void free_domain_search_list (ptr, file, line) - struct domain_search_list *ptr; - const char *file; - int line; -{ - dfree ((VOIDPTR)ptr, file, line); -} - -void free_protocol (ptr, file, line) - struct protocol *ptr; - const char *file; - int line; -{ - dfree ((VOIDPTR)ptr, file, line); -} - -void free_dhcp_packet (ptr, file, line) - struct dhcp_packet *ptr; - const char *file; - int line; -{ - dfree ((VOIDPTR)ptr, file, line); -} - -struct client_lease *new_client_lease (file, line) - const char *file; - int line; -{ - return (struct client_lease *)dmalloc (sizeof (struct client_lease), - file, line); -} - -void free_client_lease (lease, file, line) - struct client_lease *lease; - const char *file; - int line; -{ - dfree (lease, file, line); -} - -pair free_pairs; - -pair new_pair (file, line) - const char *file; - int line; -{ - pair foo; - - if (free_pairs) { - foo = free_pairs; - free_pairs = foo -> cdr; - memset (foo, 0, sizeof *foo); - dmalloc_reuse (foo, file, line, 0); - return foo; - } - - foo = dmalloc (sizeof *foo, file, line); - if (!foo) - return foo; - memset (foo, 0, sizeof *foo); - return foo; -} - -void free_pair (foo, file, line) - pair foo; - const char *file; - int line; -{ - foo -> cdr = free_pairs; - free_pairs = foo; - dmalloc_reuse (free_pairs, (char *)0, 0, 0); -} - -#if defined (DEBUG_MEMORY_LEAKAGE) || \ - defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) -void relinquish_free_pairs () -{ - pair pf, pc; - - for (pf = free_pairs; pf; pf = pc) { - pc = pf -> cdr; - dfree (pf, MDL); - } - free_pairs = (pair)0; -} -#endif - -struct expression *free_expressions; - -int expression_allocate (cptr, file, line) - struct expression **cptr; - const char *file; - int line; -{ - struct expression *rval; - - if (free_expressions) { - rval = free_expressions; - free_expressions = rval -> data.not; - dmalloc_reuse (rval, file, line, 1); - } else { - rval = dmalloc (sizeof (struct expression), file, line); - if (!rval) - return 0; - } - memset (rval, 0, sizeof *rval); - return expression_reference (cptr, rval, file, line); -} - -int expression_reference (ptr, src, file, line) - struct expression **ptr; - struct expression *src; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct expression *)0; -#endif - } - *ptr = src; - src -> refcnt++; - rc_register (file, line, ptr, src, src -> refcnt, 0, RC_MISC); - return 1; -} - -void free_expression (expr, file, line) - struct expression *expr; - const char *file; - int line; -{ - expr -> data.not = free_expressions; - free_expressions = expr; - dmalloc_reuse (free_expressions, (char *)0, 0, 0); -} - -#if defined (DEBUG_MEMORY_LEAKAGE) || \ - defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) -void relinquish_free_expressions () -{ - struct expression *e, *n; - - for (e = free_expressions; e; e = n) { - n = e -> data.not; - dfree (e, MDL); - } - free_expressions = (struct expression *)0; -} -#endif - -struct binding_value *free_binding_values; - -int binding_value_allocate (cptr, file, line) - struct binding_value **cptr; - const char *file; - int line; -{ - struct binding_value *rval; - - if (free_binding_values) { - rval = free_binding_values; - free_binding_values = rval -> value.bv; - dmalloc_reuse (rval, file, line, 1); - } else { - rval = dmalloc (sizeof (struct binding_value), file, line); - if (!rval) - return 0; - } - memset (rval, 0, sizeof *rval); - return binding_value_reference (cptr, rval, file, line); -} - -int binding_value_reference (ptr, src, file, line) - struct binding_value **ptr; - struct binding_value *src; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct binding_value *)0; -#endif - } - *ptr = src; - src -> refcnt++; - rc_register (file, line, ptr, src, src -> refcnt, 0, RC_MISC); - return 1; -} - -void free_binding_value (bv, file, line) - struct binding_value *bv; - const char *file; - int line; -{ - bv -> value.bv = free_binding_values; - free_binding_values = bv; - dmalloc_reuse (free_binding_values, (char *)0, 0, 0); -} - -#if defined (DEBUG_MEMORY_LEAKAGE) || \ - defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) -void relinquish_free_binding_values () -{ - struct binding_value *b, *n; - - for (b = free_binding_values; b; b = n) { - n = b -> value.bv; - dfree (b, MDL); - } - free_binding_values = (struct binding_value *)0; -} -#endif - -int fundef_allocate (cptr, file, line) - struct fundef **cptr; - const char *file; - int line; -{ - struct fundef *rval; - - rval = dmalloc (sizeof (struct fundef), file, line); - if (!rval) - return 0; - memset (rval, 0, sizeof *rval); - return fundef_reference (cptr, rval, file, line); -} - -int fundef_reference (ptr, src, file, line) - struct fundef **ptr; - struct fundef *src; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct fundef *)0; -#endif - } - *ptr = src; - src -> refcnt++; - rc_register (file, line, ptr, src, src -> refcnt, 0, RC_MISC); - return 1; -} - -struct option_cache *free_option_caches; - -#if defined (DEBUG_MEMORY_LEAKAGE) || \ - defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) -void relinquish_free_option_caches () -{ - struct option_cache *o, *n; - - for (o = free_option_caches; o; o = n) { - n = (struct option_cache *)(o -> expression); - dfree (o, MDL); - } - free_option_caches = (struct option_cache *)0; -} -#endif - -int option_cache_allocate (cptr, file, line) - struct option_cache **cptr; - const char *file; - int line; -{ - struct option_cache *rval; - - if (free_option_caches) { - rval = free_option_caches; - free_option_caches = - (struct option_cache *)(rval -> expression); - dmalloc_reuse (rval, file, line, 0); - } else { - rval = dmalloc (sizeof (struct option_cache), file, line); - if (!rval) - return 0; - } - memset (rval, 0, sizeof *rval); - return option_cache_reference (cptr, rval, file, line); -} - -int option_cache_reference (ptr, src, file, line) - struct option_cache **ptr; - struct option_cache *src; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct option_cache *)0; -#endif - } - *ptr = src; - src -> refcnt++; - rc_register (file, line, ptr, src, src -> refcnt, 0, RC_MISC); - return 1; -} - -int buffer_allocate (ptr, len, file, line) - struct buffer **ptr; - unsigned len; - const char *file; - int line; -{ - struct buffer *bp; - - bp = dmalloc (len + sizeof *bp, file, line); - if (!bp) - return 0; - memset (bp, 0, sizeof *bp); - bp -> refcnt = 0; - return buffer_reference (ptr, bp, file, line); -} - -int buffer_reference (ptr, bp, file, line) - struct buffer **ptr; - struct buffer *bp; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct buffer *)0; -#endif - } - *ptr = bp; - bp -> refcnt++; - rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC); - return 1; -} - -int buffer_dereference (ptr, file, line) - struct buffer **ptr; - const char *file; - int line; -{ - struct buffer *bp; - - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - if (!*ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - (*ptr) -> refcnt--; - rc_register (file, line, ptr, *ptr, (*ptr) -> refcnt, 1, RC_MISC); - if (!(*ptr) -> refcnt) { - dfree ((*ptr), file, line); - } else if ((*ptr) -> refcnt < 0) { - log_error ("%s(%d): negative refcnt!", file, line); -#if defined (DEBUG_RC_HISTORY) - dump_rc_history (*ptr); -#endif -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - *ptr = (struct buffer *)0; - return 1; -} - -int dns_host_entry_allocate (ptr, hostname, file, line) - struct dns_host_entry **ptr; - const char *hostname; - const char *file; - int line; -{ - struct dns_host_entry *bp; - - bp = dmalloc (strlen (hostname) + sizeof *bp, file, line); - if (!bp) - return 0; - memset (bp, 0, sizeof *bp); - bp -> refcnt = 0; - strcpy (bp -> hostname, hostname); - return dns_host_entry_reference (ptr, bp, file, line); -} - -int dns_host_entry_reference (ptr, bp, file, line) - struct dns_host_entry **ptr; - struct dns_host_entry *bp; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct dns_host_entry *)0; -#endif - } - *ptr = bp; - bp -> refcnt++; - rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC); - return 1; -} - -int dns_host_entry_dereference (ptr, file, line) - struct dns_host_entry **ptr; - const char *file; - int line; -{ - struct dns_host_entry *bp; - - if (!ptr || !*ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - (*ptr) -> refcnt--; - rc_register (file, line, ptr, *ptr, (*ptr) -> refcnt, 1, RC_MISC); - if (!(*ptr) -> refcnt) - dfree ((*ptr), file, line); - if ((*ptr) -> refcnt < 0) { - log_error ("%s(%d): negative refcnt!", file, line); -#if defined (DEBUG_RC_HISTORY) - dump_rc_history (*ptr); -#endif -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - *ptr = (struct dns_host_entry *)0; - return 1; -} - -int option_state_allocate (ptr, file, line) - struct option_state **ptr; - const char *file; - int line; -{ - unsigned size; - - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct option_state *)0; -#endif - } - - size = sizeof **ptr + (universe_count - 1) * sizeof (VOIDPTR); - *ptr = dmalloc (size, file, line); - if (*ptr) { - memset (*ptr, 0, size); - (*ptr) -> universe_count = universe_count; - (*ptr) -> refcnt = 1; - rc_register (file, line, - ptr, *ptr, (*ptr) -> refcnt, 0, RC_MISC); - return 1; - } - return 0; -} - -int option_state_reference (ptr, bp, file, line) - struct option_state **ptr; - struct option_state *bp; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct option_state *)0; -#endif - } - *ptr = bp; - bp -> refcnt++; - rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC); - return 1; -} - -int option_state_dereference (ptr, file, line) - struct option_state **ptr; - const char *file; - int line; -{ - int i; - struct option_state *options; - - if (!ptr || !*ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - options = *ptr; - *ptr = (struct option_state *)0; - --options -> refcnt; - rc_register (file, line, ptr, options, options -> refcnt, 1, RC_MISC); - if (options -> refcnt > 0) - return 1; - - if (options -> refcnt < 0) { - log_error ("%s(%d): negative refcnt!", file, line); -#if defined (DEBUG_RC_HISTORY) - dump_rc_history (options); -#endif -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - /* Loop through the per-universe state. */ - for (i = 0; i < options -> universe_count; i++) - if (options -> universes [i] && - universes [i] -> option_state_dereference) - ((*(universes [i] -> option_state_dereference)) - (universes [i], options, file, line)); - dfree (options, file, line); - return 1; -} - -int executable_statement_allocate (ptr, file, line) - struct executable_statement **ptr; - const char *file; - int line; -{ - struct executable_statement *bp; - - bp = dmalloc (sizeof *bp, file, line); - if (!bp) - return 0; - memset (bp, 0, sizeof *bp); - return executable_statement_reference (ptr, bp, file, line); -} - -int executable_statement_reference (ptr, bp, file, line) - struct executable_statement **ptr; - struct executable_statement *bp; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct executable_statement *)0; -#endif - } - *ptr = bp; - bp -> refcnt++; - rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC); - return 1; -} - -static struct packet *free_packets; - -#if defined (DEBUG_MEMORY_LEAKAGE) || \ - defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) -void relinquish_free_packets () -{ - struct packet *p, *n; - for (p = free_packets; p; p = n) { - n = (struct packet *)(p -> raw); - dfree (p, MDL); - } - free_packets = (struct packet *)0; -} -#endif - -int packet_allocate (ptr, file, line) - struct packet **ptr; - const char *file; - int line; -{ - int size; - struct packet *p; - - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct packet *)0; -#endif - } - - if (free_packets) { - p = free_packets; - free_packets = (struct packet *)(p -> raw); - dmalloc_reuse (p, file, line, 1); - } else { - p = dmalloc (sizeof *p, file, line); - } - if (p) { - memset (p, 0, sizeof *p); - return packet_reference (ptr, p, file, line); - } - return 0; -} - -int packet_reference (ptr, bp, file, line) - struct packet **ptr; - struct packet *bp; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct packet *)0; -#endif - } - *ptr = bp; - bp -> refcnt++; - rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC); - return 1; -} - -int packet_dereference (ptr, file, line) - struct packet **ptr; - const char *file; - int line; -{ - int i; - struct packet *packet; - - if (!ptr || !*ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - packet = *ptr; - *ptr = (struct packet *)0; - --packet -> refcnt; - rc_register (file, line, ptr, packet, packet -> refcnt, 1, RC_MISC); - if (packet -> refcnt > 0) - return 1; - - if (packet -> refcnt < 0) { - log_error ("%s(%d): negative refcnt!", file, line); -#if defined (DEBUG_RC_HISTORY) - dump_rc_history (packet); -#endif -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - if (packet -> options) - option_state_dereference (&packet -> options, file, line); - if (packet -> interface) - interface_dereference (&packet -> interface, MDL); - if (packet -> shared_network) - shared_network_dereference (&packet -> shared_network, MDL); - for (i = 0; i < packet -> class_count && i < PACKET_MAX_CLASSES; i++) { - if (packet -> classes [i]) - omapi_object_dereference ((omapi_object_t **) - &packet -> classes [i], MDL); - } - packet -> raw = (struct dhcp_packet *)free_packets; - free_packets = packet; - dmalloc_reuse (free_packets, (char *)0, 0, 0); - return 1; -} - -int dns_zone_allocate (ptr, file, line) - struct dns_zone **ptr; - const char *file; - int line; -{ - int size; - struct dns_zone *d; - - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct dns_zone *)0; -#endif - } - - d = dmalloc (sizeof *d, file, line); - if (d) { - memset (d, 0, sizeof *d); - return dns_zone_reference (ptr, d, file, line); - } - return 0; -} - -int dns_zone_reference (ptr, bp, file, line) - struct dns_zone **ptr; - struct dns_zone *bp; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct dns_zone *)0; -#endif - } - *ptr = bp; - bp -> refcnt++; - rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC); - return 1; -} - -int binding_scope_allocate (ptr, file, line) - struct binding_scope **ptr; - const char *file; - int line; -{ - struct binding_scope *bp; - - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - - bp = dmalloc (sizeof *bp, file, line); - if (!bp) - return 0; - memset (bp, 0, sizeof *bp); - binding_scope_reference (ptr, bp, file, line); - return 1; -} - -int binding_scope_reference (ptr, bp, file, line) - struct binding_scope **ptr; - struct binding_scope *bp; - const char *file; - int line; -{ - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - return 0; -#endif - } - if (*ptr) { - log_error ("%s(%d): non-null pointer", file, line); -#if defined (POINTER_DEBUG) - abort (); -#else - *ptr = (struct binding_scope *)0; -#endif - } - *ptr = bp; - bp -> refcnt++; - rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC); - return 1; -} - -/* Make a copy of the data in data_string, upping the buffer reference - count if there's a buffer. */ - -void data_string_copy (dest, src, file, line) - struct data_string *dest; - struct data_string *src; - const char *file; - int line; -{ - if (src -> buffer) - buffer_reference (&dest -> buffer, src -> buffer, file, line); - dest -> data = src -> data; - dest -> terminated = src -> terminated; - dest -> len = src -> len; -} - -/* Release the reference count to a data string's buffer (if any) and - zero out the other information, yielding the null data string. */ - -void data_string_forget (data, file, line) - struct data_string *data; - const char *file; - int line; -{ - if (data -> buffer) - buffer_dereference (&data -> buffer, file, line); - memset (data, 0, sizeof *data); -} - -/* Make a copy of the data in data_string, upping the buffer reference - count if there's a buffer. */ - -void data_string_truncate (dp, len) - struct data_string *dp; - int len; -{ - if (len < dp -> len) { - dp -> terminated = 0; - dp -> len = len; - } -} diff --git a/contrib/dhcp-3.0/common/bpf.c b/contrib/dhcp-3.0/common/bpf.c deleted file mode 100644 index 2066268..0000000 --- a/contrib/dhcp-3.0/common/bpf.c +++ /dev/null @@ -1,547 +0,0 @@ -/* bpf.c - - BPF socket interface code, originally contributed by Archie Cobbs. */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996-2003 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Internet Systems Consortium, Inc. - * 950 Charter Street - * Redwood City, CA 94063 - * - * http://www.isc.org/ - * - * This software was contributed to Internet Systems Consortium - * by Archie Cobbs. - * - * Patches for FDDI support on Digital Unix were written by Bill - * Stapleton, and maintained for a while by Mike Meredith before he - * managed to get me to integrate them. - */ - -#ifndef lint -static char copyright[] = -"$Id: bpf.c,v 1.48.2.7 2004/11/24 17:39:15 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" -#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE) \ - || defined (USE_LPF_RECEIVE) -# if defined (USE_LPF_RECEIVE) -# include -# include -# define bpf_insn sock_filter /* Linux: dare to be gratuitously different. */ -# else -# include -# include -# include -# if defined (NEED_OSF_PFILT_HACKS) -# include -# endif -# endif - -#include -#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. */ - -#ifdef USE_BPF_SEND -void if_reinitialize_send (info) - struct interface_info *info; -{ -} -#endif - -#ifdef USE_BPF_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. */ - -#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE) -int if_register_bpf (info) - struct interface_info *info; -{ - int sock; - char filename[50]; - int b; - - /* Open a BPF device */ - for (b = 0; 1; b++) { - /* %Audit% 31 bytes max. %2004.06.17,Safe% */ - sprintf(filename, BPF_FORMAT, b); - sock = open (filename, O_RDWR, 0); - if (sock < 0) { - if (errno == EBUSY) { - continue; - } else { - if (!b) - log_fatal ("No bpf devices.%s%s%s", - " Please read the README", - " section for your operating", - " system."); - log_fatal ("Can't find free bpf: %m"); - } - } else { - break; - } - } - - /* Set the BPF device to point at this interface. */ - if (ioctl (sock, BIOCSETIF, info -> ifp) < 0) - log_fatal ("Can't attach interface %s to bpf device %s: %m", - info -> name, filename); - - return sock; -} -#endif /* USE_BPF_SEND || USE_BPF_RECEIVE */ - -#ifdef USE_BPF_SEND -void if_register_send (info) - struct interface_info *info; -{ - /* If we're using the bpf API for sending and receiving, - we don't need to register this interface twice. */ -#ifndef USE_BPF_RECEIVE - info -> wfdesc = if_register_bpf (info, interface); -#else - info -> wfdesc = info -> rfdesc; -#endif - if (!quiet_interface_discovery) - log_info ("Sending on BPF/%s/%s%s%s", - info -> name, - print_hw_addr (info -> hw_address.hbuf [0], - info -> hw_address.hlen - 1, - &info -> hw_address.hbuf [1]), - (info -> shared_network ? "/" : ""), - (info -> shared_network ? - info -> shared_network -> name : "")); -} - -void if_deregister_send (info) - struct interface_info *info; -{ - /* If we're using the bpf API for sending and receiving, - we don't need to register this interface twice. */ -#ifndef USE_BPF_RECEIVE - close (info -> wfdesc); -#endif - info -> wfdesc = -1; - - if (!quiet_interface_discovery) - log_info ("Disabling output on BPF/%s/%s%s%s", - info -> name, - print_hw_addr (info -> hw_address.hbuf [0], - info -> hw_address.hlen - 1, - &info -> hw_address.hbuf [1]), - (info -> shared_network ? "/" : ""), - (info -> shared_network ? - info -> shared_network -> name : "")); -} -#endif /* USE_BPF_SEND */ - -#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 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), - - /* Make sure it's a UDP packet... */ - BPF_STMT (BPF_LD + BPF_B + BPF_ABS, 23), - BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 0, 6), - - /* Make sure this isn't a fragment... */ - BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 20), - BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 4, 0), - - /* Get the IP header length... */ - BPF_STMT (BPF_LDX + BPF_B + BPF_MSH, 14), - - /* Make sure it's to the right port... */ - BPF_STMT (BPF_LD + BPF_H + BPF_IND, 16), - BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 67, 0, 1), /* patch */ - - /* If we passed all the tests, ask for the whole packet. */ - BPF_STMT(BPF_RET+BPF_K, (u_int)-1), - - /* Otherwise, drop it. */ - BPF_STMT(BPF_RET+BPF_K, 0), -}; - -#if defined (DEC_FDDI) -struct bpf_insn *bpf_fddi_filter; -#endif - -int dhcp_bpf_filter_len = sizeof dhcp_bpf_filter / sizeof (struct bpf_insn); -#if defined (HAVE_TR_SUPPORT) -struct bpf_insn dhcp_bpf_tr_filter [] = { - /* accept all token ring packets due to variable length header */ - /* if we want to get clever, insert the program here */ - - /* If we passed all the tests, ask for the whole packet. */ - BPF_STMT(BPF_RET+BPF_K, (u_int)-1), - - /* Otherwise, drop it. */ - BPF_STMT(BPF_RET+BPF_K, 0), -}; - -int dhcp_bpf_tr_filter_len = (sizeof dhcp_bpf_tr_filter / - sizeof (struct bpf_insn)); -#endif /* HAVE_TR_SUPPORT */ -#endif /* USE_LPF_RECEIVE || USE_BPF_RECEIVE */ - -#if defined (USE_BPF_RECEIVE) -void if_register_receive (info) - struct interface_info *info; -{ - int flag = 1; - struct bpf_version v; - u_int32_t addr; - struct bpf_program p; - u_int32_t bits; -#ifdef DEC_FDDI - int link_layer; -#endif /* DEC_FDDI */ - - /* Open a BPF device and hang it on this interface... */ - info -> rfdesc = if_register_bpf (info); - - /* Make sure the BPF version is in range... */ - if (ioctl (info -> rfdesc, BIOCVERSION, &v) < 0) - log_fatal ("Can't get BPF version: %m"); - - if (v.bv_major != BPF_MAJOR_VERSION || - v.bv_minor < BPF_MINOR_VERSION) - log_fatal ("BPF version mismatch - recompile DHCP!"); - - /* Set immediate mode so that reads return as soon as a packet - comes in, rather than waiting for the input buffer to fill with - packets. */ - if (ioctl (info -> rfdesc, BIOCIMMEDIATE, &flag) < 0) - log_fatal ("Can't set immediate mode on bpf device: %m"); - -#ifdef NEED_OSF_PFILT_HACKS - /* Allow the copyall flag to be set... */ - if (ioctl(info -> rfdesc, EIOCALLOWCOPYALL, &flag) < 0) - log_fatal ("Can't set ALLOWCOPYALL: %m"); - - /* Clear all the packet filter mode bits first... */ - bits = 0; - if (ioctl (info -> rfdesc, EIOCMBIS, &bits) < 0) - log_fatal ("Can't clear pfilt bits: %m"); - - /* Set the ENBATCH, ENCOPYALL, ENBPFHDR bits... */ - bits = ENBATCH | ENCOPYALL | ENBPFHDR; - if (ioctl (info -> rfdesc, EIOCMBIS, &bits) < 0) - log_fatal ("Can't set ENBATCH|ENCOPYALL|ENBPFHDR: %m"); -#endif - /* Get the required BPF buffer length from the kernel. */ - if (ioctl (info -> rfdesc, BIOCGBLEN, &info -> rbuf_max) < 0) - log_fatal ("Can't get bpf buffer length: %m"); - info -> rbuf = dmalloc (info -> rbuf_max, MDL); - if (!info -> rbuf) - log_fatal ("Can't allocate %ld bytes for bpf input buffer.", - (long)(info -> rbuf_max)); - info -> rbuf_offset = 0; - info -> rbuf_len = 0; - - /* Set up the bpf filter program structure. */ - p.bf_len = dhcp_bpf_filter_len; - -#ifdef DEC_FDDI - /* See if this is an FDDI interface, flag it for later. */ - if (ioctl(info -> rfdesc, BIOCGDLT, &link_layer) >= 0 && - link_layer == DLT_FDDI) { - if (!bpf_fddi_filter) { - bpf_fddi_filter = dmalloc (sizeof bpf_fddi_filter, - MDL); - if (!bpf_fddi_filter) - log_fatal ("No memory for FDDI filter."); - memcpy (bpf_fddi_filter, - dhcp_bpf_filter, sizeof dhcp_bpf_filter); - /* Patch the BPF program to account for the difference - in length between ethernet headers (14), FDDI and - 802.2 headers (16 +8=24, +10). - XXX changes to filter program may require changes to - XXX the insn number(s) used below! */ - bpf_fddi_filter[0].k += 10; - bpf_fddi_filter[2].k += 10; - bpf_fddi_filter[4].k += 10; - bpf_fddi_filter[6].k += 10; - bpf_fddi_filter[7].k += 10; - } - p.bf_insns = bpf_fddi_filter; - } else -#endif /* DEC_FDDI */ - 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 */ - dhcp_bpf_filter [8].k = ntohs (local_port); - - if (ioctl (info -> rfdesc, BIOCSETF, &p) < 0) - log_fatal ("Can't install packet filter program: %m"); - if (!quiet_interface_discovery) - log_info ("Listening on BPF/%s/%s%s%s", - info -> name, - print_hw_addr (info -> hw_address.hbuf [0], - info -> hw_address.hlen - 1, - &info -> hw_address.hbuf [1]), - (info -> shared_network ? "/" : ""), - (info -> shared_network ? - info -> shared_network -> name : "")); -} - -void if_deregister_receive (info) - struct interface_info *info; -{ - close (info -> rfdesc); - info -> rfdesc = -1; - - if (!quiet_interface_discovery) - log_info ("Disabling input on BPF/%s/%s%s%s", - info -> name, - print_hw_addr (info -> hw_address.hbuf [0], - info -> hw_address.hlen - 1, - &info -> hw_address.hbuf [1]), - (info -> shared_network ? "/" : ""), - (info -> shared_network ? - info -> shared_network -> name : "")); -} -#endif /* USE_BPF_RECEIVE */ - -#ifdef USE_BPF_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; -{ - unsigned hbufp = 0, ibufp = 0; - double hw [4]; - double ip [32]; - struct iovec iov [3]; - int result; - int fudge; - - if (!strcmp (interface -> name, "fallback")) - return send_fallback (interface, packet, raw, - len, from, to, hto); - - /* Assemble the headers... */ - assemble_hw_header (interface, (unsigned char *)hw, &hbufp, hto); - assemble_udp_ip_header (interface, - (unsigned char *)ip, &ibufp, from.s_addr, - to -> sin_addr.s_addr, to -> sin_port, - (unsigned char *)raw, len); - - /* Fire it off */ - iov [0].iov_base = ((char *)hw); - iov [0].iov_len = hbufp; - iov [1].iov_base = ((char *)ip); - iov [1].iov_len = ibufp; - iov [2].iov_base = (char *)raw; - iov [2].iov_len = len; - - result = writev(interface -> wfdesc, iov, 3); - if (result < 0) - log_error ("send_packet: %m"); - return result; -} -#endif /* USE_BPF_SEND */ - -#ifdef USE_BPF_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 length = 0; - int offset = 0; - struct bpf_hdr hdr; - - /* All this complexity is because BPF doesn't guarantee - that only one packet will be returned at a time. We're - getting what we deserve, though - this is a terrible abuse - of the BPF interface. Sigh. */ - - /* Process packets until we get one we can return or until we've - done a read and gotten nothing we can return... */ - - do { - /* If the buffer is empty, fill it. */ - if (interface -> rbuf_offset == interface -> rbuf_len) { - length = read (interface -> rfdesc, - interface -> rbuf, - (size_t)interface -> rbuf_max); - if (length <= 0) { -#ifdef __FreeBSD__ - if (errno == ENXIO) { -#else - if (errno == EIO) { -#endif - dhcp_interface_remove - ((omapi_object_t *)interface, - (omapi_object_t *)0); - } - return length; - } - interface -> rbuf_offset = 0; - interface -> rbuf_len = BPF_WORDALIGN (length); - } - - /* If there isn't room for a whole bpf header, something went - wrong, but we'll ignore it and hope it goes away... XXX */ - if (interface -> rbuf_len - - interface -> rbuf_offset < sizeof hdr) { - interface -> rbuf_offset = interface -> rbuf_len; - continue; - } - - /* Copy out a bpf header... */ - memcpy (&hdr, &interface -> rbuf [interface -> rbuf_offset], - sizeof hdr); - - /* If the bpf header plus data doesn't fit in what's left - of the buffer, stick head in sand yet again... */ - if (interface -> rbuf_offset + - hdr.bh_hdrlen + hdr.bh_caplen > interface -> rbuf_len) { - interface -> rbuf_offset = interface -> rbuf_len; - continue; - } - - /* If the captured data wasn't the whole packet, or if - the packet won't fit in the input buffer, all we - can do is drop it. */ - if (hdr.bh_caplen != hdr.bh_datalen) { - interface -> rbuf_offset = - BPF_WORDALIGN (interface -> rbuf_offset + - hdr.bh_hdrlen + hdr.bh_caplen); - continue; - } - - /* Skip over the BPF header... */ - interface -> rbuf_offset += hdr.bh_hdrlen; - - /* Decode the physical header... */ - offset = decode_hw_header (interface, - interface -> rbuf, - interface -> rbuf_offset, - hfrom); - - /* If a physical layer checksum failed (dunno of any - physical layer that supports this, but WTH), skip this - packet. */ - if (offset < 0) { - interface -> rbuf_offset = - BPF_WORDALIGN (interface -> rbuf_offset + - hdr.bh_caplen); - continue; - } - interface -> rbuf_offset += offset; - hdr.bh_caplen -= offset; - - /* Decode the IP and UDP headers... */ - offset = decode_udp_ip_header (interface, - interface -> rbuf, - interface -> rbuf_offset, - from, - hdr.bh_caplen); - - /* If the IP or UDP checksum was bad, skip the packet... */ - if (offset < 0) { - interface -> rbuf_offset = - BPF_WORDALIGN (interface -> rbuf_offset + - hdr.bh_caplen); - continue; - } - interface -> rbuf_offset = interface -> rbuf_offset + offset; - hdr.bh_caplen -= offset; - - /* If there's not enough room to stash the packet data, - we have to skip it (this shouldn't happen in real - life, though). */ - if (hdr.bh_caplen > len) { - interface -> rbuf_offset = - BPF_WORDALIGN (interface -> rbuf_offset + - hdr.bh_caplen); - continue; - } - - /* Copy out the data in the packet... */ - memcpy (buf, interface -> rbuf + interface -> rbuf_offset, - hdr.bh_caplen); - interface -> rbuf_offset = - BPF_WORDALIGN (interface -> rbuf_offset + - hdr.bh_caplen); - return hdr.bh_caplen; - } while (!length); - return 0; -} - -int can_unicast_without_arp (ip) - struct interface_info *ip; -{ - return 1; -} - -int can_receive_unicast_unconfigured (ip) - struct interface_info *ip; -{ - return 1; -} - -int supports_multiple_interfaces (ip) - struct interface_info *ip; -{ - return 1; -} - -void maybe_setup_fallback () -{ - isc_result_t status; - struct interface_info *fbi = (struct interface_info *)0; - if (setup_fallback (&fbi, MDL)) { - if_register_fallback (fbi); - status = omapi_register_io_object ((omapi_object_t *)fbi, - if_readsocket, 0, - fallback_discard, 0, 0); - if (status != ISC_R_SUCCESS) - log_fatal ("Can't register I/O handle for %s: %s", - fbi -> name, isc_result_totext (status)); - interface_dereference (&fbi, MDL); - } -} -#endif diff --git a/contrib/dhcp-3.0/common/comapi.c b/contrib/dhcp-3.0/common/comapi.c deleted file mode 100644 index 9f0b965..0000000 --- a/contrib/dhcp-3.0/common/comapi.c +++ /dev/null @@ -1,949 +0,0 @@ -/* omapi.c - - OMAPI object interfaces for the DHCP server. */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1999-2003 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Internet Systems Consortium, Inc. - * 950 Charter Street - * Redwood City, CA 94063 - * - * http://www.isc.org/ - * - * This software has been written for Internet Systems Consortium - * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. - * To learn more about Internet Systems Consortium, see - * ``http://www.isc.org/''. To learn more about Vixie Enterprises, - * see ``http://www.vix.com''. To learn more about Nominum, Inc., see - * ``http://www.nominum.com''. - */ - -/* Many, many thanks to Brian Murrell and BCtel for this code - BCtel - provided the funding that resulted in this code and the entire - OMAPI support library being written, and Brian helped brainstorm - and refine the requirements. To the extent that this code is - useful, you have Brian and BCtel to thank. Any limitations in the - code are a result of mistakes on my part. -- Ted Lemon */ - -#ifndef lint -static char copyright[] = -"$Id: comapi.c,v 1.9.2.7 2004/06/10 17:59:14 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" -#include - -OMAPI_OBJECT_ALLOC (subnet, struct subnet, dhcp_type_subnet) -OMAPI_OBJECT_ALLOC (shared_network, struct shared_network, - dhcp_type_shared_network) -OMAPI_OBJECT_ALLOC (group_object, struct group_object, dhcp_type_group) -OMAPI_OBJECT_ALLOC (dhcp_control, dhcp_control_object_t, dhcp_type_control) - -omapi_object_type_t *dhcp_type_interface; -omapi_object_type_t *dhcp_type_group; -omapi_object_type_t *dhcp_type_shared_network; -omapi_object_type_t *dhcp_type_subnet; -omapi_object_type_t *dhcp_type_control; -dhcp_control_object_t *dhcp_control_object; - -void dhcp_common_objects_setup () -{ - isc_result_t status; - - status = omapi_object_type_register (&dhcp_type_control, - "control", - dhcp_control_set_value, - dhcp_control_get_value, - dhcp_control_destroy, - dhcp_control_signal_handler, - dhcp_control_stuff_values, - dhcp_control_lookup, - dhcp_control_create, - dhcp_control_remove, 0, 0, 0, - sizeof (dhcp_control_object_t), - 0, RC_MISC); - if (status != ISC_R_SUCCESS) - log_fatal ("Can't register control object type: %s", - isc_result_totext (status)); - status = dhcp_control_allocate (&dhcp_control_object, MDL); - if (status != ISC_R_SUCCESS) - log_fatal ("Can't make initial control object: %s", - isc_result_totext (status)); - dhcp_control_object -> state = server_startup; - - status = omapi_object_type_register (&dhcp_type_group, - "group", - dhcp_group_set_value, - dhcp_group_get_value, - dhcp_group_destroy, - dhcp_group_signal_handler, - dhcp_group_stuff_values, - dhcp_group_lookup, - dhcp_group_create, - dhcp_group_remove, 0, 0, 0, - sizeof (struct group_object), 0, - RC_MISC); - if (status != ISC_R_SUCCESS) - log_fatal ("Can't register group object type: %s", - isc_result_totext (status)); - - status = omapi_object_type_register (&dhcp_type_subnet, - "subnet", - dhcp_subnet_set_value, - dhcp_subnet_get_value, - dhcp_subnet_destroy, - dhcp_subnet_signal_handler, - dhcp_subnet_stuff_values, - dhcp_subnet_lookup, - dhcp_subnet_create, - dhcp_subnet_remove, 0, 0, 0, - sizeof (struct subnet), 0, - RC_MISC); - if (status != ISC_R_SUCCESS) - log_fatal ("Can't register subnet object type: %s", - isc_result_totext (status)); - - status = omapi_object_type_register - (&dhcp_type_shared_network, - "shared-network", - dhcp_shared_network_set_value, - dhcp_shared_network_get_value, - dhcp_shared_network_destroy, - dhcp_shared_network_signal_handler, - dhcp_shared_network_stuff_values, - dhcp_shared_network_lookup, - dhcp_shared_network_create, - dhcp_shared_network_remove, 0, 0, 0, - sizeof (struct shared_network), 0, RC_MISC); - if (status != ISC_R_SUCCESS) - log_fatal ("Can't register shared network object type: %s", - isc_result_totext (status)); - - interface_setup (); -} - -isc_result_t dhcp_group_set_value (omapi_object_t *h, - omapi_object_t *id, - omapi_data_string_t *name, - omapi_typed_data_t *value) -{ - struct group_object *group; - isc_result_t status; - int foo; - - if (h -> type != dhcp_type_group) - return ISC_R_INVALIDARG; - group = (struct group_object *)h; - - /* XXX For now, we can only set these values on new group objects. - XXX Soon, we need to be able to update group objects. */ - if (!omapi_ds_strcmp (name, "name")) { - if (group -> name) - return ISC_R_EXISTS; - if (value -> type == omapi_datatype_data || - value -> type == omapi_datatype_string) { - group -> name = dmalloc (value -> u.buffer.len + 1, - MDL); - if (!group -> name) - return ISC_R_NOMEMORY; - memcpy (group -> name, - value -> u.buffer.value, - value -> u.buffer.len); - group -> name [value -> u.buffer.len] = 0; - } else - return ISC_R_INVALIDARG; - return ISC_R_SUCCESS; - } - - if (!omapi_ds_strcmp (name, "statements")) { - if (group -> group && group -> group -> statements) - return ISC_R_EXISTS; - if (!group -> group) { - if (!clone_group (&group -> group, root_group, MDL)) - return ISC_R_NOMEMORY; - } - if (value -> type == omapi_datatype_data || - value -> type == omapi_datatype_string) { - struct parse *parse; - int lose = 0; - parse = (struct parse *)0; - status = new_parse (&parse, -1, - (char *)value -> u.buffer.value, - value -> u.buffer.len, - "network client", 0); - if (status != ISC_R_SUCCESS) - return status; - if (!(parse_executable_statements - (&group -> group -> statements, parse, &lose, - context_any))) { - end_parse (&parse); - return ISC_R_BADPARSE; - } - end_parse (&parse); - return ISC_R_SUCCESS; - } else - return ISC_R_INVALIDARG; - } - - /* Try to find some inner object that can take the value. */ - if (h -> inner && h -> inner -> type -> set_value) { - status = ((*(h -> inner -> type -> set_value)) - (h -> inner, id, name, value)); - if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED) - return status; - } - - return ISC_R_NOTFOUND; -} - - -isc_result_t dhcp_group_get_value (omapi_object_t *h, omapi_object_t *id, - omapi_data_string_t *name, - omapi_value_t **value) -{ - struct group_object *group; - isc_result_t status; - struct data_string ip_addrs; - - if (h -> type != dhcp_type_group) - return ISC_R_INVALIDARG; - group = (struct group_object *)h; - - if (!omapi_ds_strcmp (name, "name")) - return omapi_make_string_value (value, - name, group -> name, MDL); - - /* Try to find some inner object that can take the value. */ - if (h -> inner && h -> inner -> type -> get_value) { - status = ((*(h -> inner -> type -> get_value)) - (h -> inner, id, name, value)); - if (status == ISC_R_SUCCESS) - return status; - } - return ISC_R_NOTFOUND; -} - -isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *file, int line) -{ - struct group_object *group, *t; - isc_result_t status; - - if (h -> type != dhcp_type_group) - return ISC_R_INVALIDARG; - group = (struct group_object *)h; - - if (group -> name) { - if (group_name_hash) { - t = (struct group_object *)0; - if (group_hash_lookup (&t, group_name_hash, - group -> name, - strlen (group -> name), MDL)) { - group_hash_delete (group_name_hash, - group -> name, - strlen (group -> name), - MDL); - group_object_dereference (&t, MDL); - } - } - dfree (group -> name, file, line); - group -> name = (char *)0; - } - if (group -> group) - group_dereference (&group -> group, MDL); - - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_group_signal_handler (omapi_object_t *h, - const char *name, va_list ap) -{ - struct group_object *group, *t; - isc_result_t status; - int updatep = 0; - - if (h -> type != dhcp_type_group) - return ISC_R_INVALIDARG; - group = (struct group_object *)h; - - if (!strcmp (name, "updated")) { - /* A group object isn't valid if a subgroup hasn't yet been - associated with it. */ - if (!group -> group) - return ISC_R_INVALIDARG; - - /* Group objects always have to have names. */ - if (!group -> name) { - char hnbuf [64]; - sprintf (hnbuf, "ng%08lx%08lx", - (unsigned long)cur_time, - (unsigned long)group); - group -> name = dmalloc (strlen (hnbuf) + 1, MDL); - if (!group -> name) - return ISC_R_NOMEMORY; - strcpy (group -> name, hnbuf); - } - - supersede_group (group, 1); - updatep = 1; - } - - /* Try to find some inner object that can take the value. */ - if (h -> inner && h -> inner -> type -> get_value) { - status = ((*(h -> inner -> type -> signal_handler)) - (h -> inner, name, ap)); - if (status == ISC_R_SUCCESS) - return status; - } - if (updatep) - return ISC_R_SUCCESS; - return ISC_R_NOTFOUND; -} - -isc_result_t dhcp_group_stuff_values (omapi_object_t *c, - omapi_object_t *id, - omapi_object_t *h) -{ - struct group_object *group; - isc_result_t status; - - if (h -> type != dhcp_type_group) - return ISC_R_INVALIDARG; - group = (struct group_object *)h; - - /* Write out all the values. */ - if (group -> name) { - status = omapi_connection_put_name (c, "name"); - if (status != ISC_R_SUCCESS) - return status; - status = omapi_connection_put_string (c, group -> name); - if (status != ISC_R_SUCCESS) - return status; - } - - /* Write out the inner object, if any. */ - if (h -> inner && h -> inner -> type -> stuff_values) { - status = ((*(h -> inner -> type -> stuff_values)) - (c, id, h -> inner)); - if (status == ISC_R_SUCCESS) - return status; - } - - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_group_lookup (omapi_object_t **lp, - omapi_object_t *id, omapi_object_t *ref) -{ - omapi_value_t *tv = (omapi_value_t *)0; - isc_result_t status; - struct group_object *group; - - if (!ref) - return ISC_R_NOKEYS; - - /* First see if we were sent a handle. */ - status = omapi_get_value_str (ref, id, "handle", &tv); - if (status == ISC_R_SUCCESS) { - status = omapi_handle_td_lookup (lp, tv -> value); - - omapi_value_dereference (&tv, MDL); - if (status != ISC_R_SUCCESS) - return status; - - /* Don't return the object if the type is wrong. */ - if ((*lp) -> type != dhcp_type_group) { - omapi_object_dereference (lp, MDL); - return ISC_R_INVALIDARG; - } - } - - /* Now look for a name. */ - status = omapi_get_value_str (ref, id, "name", &tv); - if (status == ISC_R_SUCCESS) { - group = (struct group_object *)0; - if (group_name_hash && - group_hash_lookup (&group, group_name_hash, - (const char *) - tv -> value -> u.buffer.value, - tv -> value -> u.buffer.len, MDL)) { - omapi_value_dereference (&tv, MDL); - - if (*lp && *lp != (omapi_object_t *)group) { - group_object_dereference (&group, MDL); - omapi_object_dereference (lp, MDL); - return ISC_R_KEYCONFLICT; - } else if (!*lp) { - /* XXX fix so that hash lookup itself creates - XXX the reference. */ - omapi_object_reference (lp, - (omapi_object_t *)group, - MDL); - group_object_dereference (&group, MDL); - } - } else if (!*lp) - return ISC_R_NOTFOUND; - } - - /* If we get to here without finding a group, no valid key was - specified. */ - if (!*lp) - return ISC_R_NOKEYS; - - if (((struct group_object *)(*lp)) -> flags & GROUP_OBJECT_DELETED) { - omapi_object_dereference (lp, MDL); - return ISC_R_NOTFOUND; - } - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_group_create (omapi_object_t **lp, - omapi_object_t *id) -{ - struct group_object *group; - isc_result_t status; - group = (struct group_object *)0; - - status = group_object_allocate (&group, MDL); - if (status != ISC_R_SUCCESS) - return status; - group -> flags = GROUP_OBJECT_DYNAMIC; - status = omapi_object_reference (lp, (omapi_object_t *)group, MDL); - group_object_dereference (&group, MDL); - return status; -} - -isc_result_t dhcp_group_remove (omapi_object_t *lp, - omapi_object_t *id) -{ - struct group_object *group; - isc_result_t status; - if (lp -> type != dhcp_type_group) - return ISC_R_INVALIDARG; - group = (struct group_object *)lp; - - group -> flags |= GROUP_OBJECT_DELETED; - if (group_write_hook) { - if (!(*group_write_hook) (group)) - return ISC_R_IOERROR; - } - - status = dhcp_group_destroy ((omapi_object_t *)group, MDL); - - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_control_set_value (omapi_object_t *h, - omapi_object_t *id, - omapi_data_string_t *name, - omapi_typed_data_t *value) -{ - dhcp_control_object_t *control; - isc_result_t status; - int foo; - unsigned long newstate; - - if (h -> type != dhcp_type_control) - return ISC_R_INVALIDARG; - control = (dhcp_control_object_t *)h; - - if (!omapi_ds_strcmp (name, "state")) { - status = omapi_get_int_value (&newstate, value); - if (status != ISC_R_SUCCESS) - return status; - status = dhcp_set_control_state (control -> state, newstate); - if (status == ISC_R_SUCCESS) - control -> state = value -> u.integer; - return status; - } - - /* Try to find some inner object that can take the value. */ - if (h -> inner && h -> inner -> type -> set_value) { - status = ((*(h -> inner -> type -> set_value)) - (h -> inner, id, name, value)); - if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED) - return status; - } - - return ISC_R_NOTFOUND; -} - - -isc_result_t dhcp_control_get_value (omapi_object_t *h, omapi_object_t *id, - omapi_data_string_t *name, - omapi_value_t **value) -{ - dhcp_control_object_t *control; - isc_result_t status; - struct data_string ip_addrs; - - if (h -> type != dhcp_type_control) - return ISC_R_INVALIDARG; - control = (dhcp_control_object_t *)h; - - if (!omapi_ds_strcmp (name, "state")) - return omapi_make_int_value (value, - name, (int)control -> state, MDL); - - /* Try to find some inner object that can take the value. */ - if (h -> inner && h -> inner -> type -> get_value) { - status = ((*(h -> inner -> type -> get_value)) - (h -> inner, id, name, value)); - if (status == ISC_R_SUCCESS) - return status; - } - return ISC_R_NOTFOUND; -} - -isc_result_t dhcp_control_destroy (omapi_object_t *h, - const char *file, int line) -{ - dhcp_control_object_t *control, *t; - isc_result_t status; - - if (h -> type != dhcp_type_control) - return ISC_R_INVALIDARG; - - /* Can't destroy the control object. */ - return ISC_R_NOPERM; -} - -isc_result_t dhcp_control_signal_handler (omapi_object_t *h, - const char *name, va_list ap) -{ - dhcp_control_object_t *control, *t; - isc_result_t status; - int updatep = 0; - - if (h -> type != dhcp_type_control) - return ISC_R_INVALIDARG; - control = (dhcp_control_object_t *)h; - - /* Try to find some inner object that can take the value. */ - if (h -> inner && h -> inner -> type -> get_value) { - status = ((*(h -> inner -> type -> signal_handler)) - (h -> inner, name, ap)); - if (status == ISC_R_SUCCESS) - return status; - } - return ISC_R_NOTFOUND; -} - -isc_result_t dhcp_control_stuff_values (omapi_object_t *c, - omapi_object_t *id, - omapi_object_t *h) -{ - dhcp_control_object_t *control; - isc_result_t status; - - if (h -> type != dhcp_type_control) - return ISC_R_INVALIDARG; - control = (dhcp_control_object_t *)h; - - /* Write out all the values. */ - status = omapi_connection_put_name (c, "state"); - if (status != ISC_R_SUCCESS) - return status; - status = omapi_connection_put_uint32 (c, sizeof (u_int32_t)); - if (status != ISC_R_SUCCESS) - return status; - status = omapi_connection_put_uint32 (c, control -> state); - if (status != ISC_R_SUCCESS) - return status; - - /* Write out the inner object, if any. */ - if (h -> inner && h -> inner -> type -> stuff_values) { - status = ((*(h -> inner -> type -> stuff_values)) - (c, id, h -> inner)); - if (status == ISC_R_SUCCESS) - return status; - } - - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_control_lookup (omapi_object_t **lp, - omapi_object_t *id, omapi_object_t *ref) -{ - omapi_value_t *tv = (omapi_value_t *)0; - isc_result_t status; - dhcp_control_object_t *control; - - /* First see if we were sent a handle. */ - if (ref) { - status = omapi_get_value_str (ref, id, "handle", &tv); - if (status == ISC_R_SUCCESS) { - status = omapi_handle_td_lookup (lp, tv -> value); - - omapi_value_dereference (&tv, MDL); - if (status != ISC_R_SUCCESS) - return status; - - /* Don't return the object if the type is wrong. */ - if ((*lp) -> type != dhcp_type_control) { - omapi_object_dereference (lp, MDL); - return ISC_R_INVALIDARG; - } - } - } - - /* Otherwise, stop playing coy - there's only one control object, - so we can just return it. */ - dhcp_control_reference ((dhcp_control_object_t **)lp, - dhcp_control_object, MDL); - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_control_create (omapi_object_t **lp, - omapi_object_t *id) -{ - /* Can't create a control object - there can be only one. */ - return ISC_R_NOPERM; -} - -isc_result_t dhcp_control_remove (omapi_object_t *lp, - omapi_object_t *id) -{ - /* Form is emptiness; emptiness form. The control object - cannot go out of existance. */ - return ISC_R_NOPERM; -} - -isc_result_t dhcp_subnet_set_value (omapi_object_t *h, - omapi_object_t *id, - omapi_data_string_t *name, - omapi_typed_data_t *value) -{ - struct subnet *subnet; - isc_result_t status; - int foo; - - if (h -> type != dhcp_type_subnet) - return ISC_R_INVALIDARG; - subnet = (struct subnet *)h; - - /* No values to set yet. */ - - /* Try to find some inner object that can take the value. */ - if (h -> inner && h -> inner -> type -> set_value) { - status = ((*(h -> inner -> type -> set_value)) - (h -> inner, id, name, value)); - if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED) - return status; - } - - return ISC_R_NOTFOUND; -} - - -isc_result_t dhcp_subnet_get_value (omapi_object_t *h, omapi_object_t *id, - omapi_data_string_t *name, - omapi_value_t **value) -{ - struct subnet *subnet; - isc_result_t status; - - if (h -> type != dhcp_type_subnet) - return ISC_R_INVALIDARG; - subnet = (struct subnet *)h; - - /* No values to get yet. */ - - /* Try to find some inner object that can provide the value. */ - if (h -> inner && h -> inner -> type -> get_value) { - status = ((*(h -> inner -> type -> get_value)) - (h -> inner, id, name, value)); - if (status == ISC_R_SUCCESS) - return status; - } - return ISC_R_NOTFOUND; -} - -isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line) -{ - struct subnet *subnet; - isc_result_t status; - - if (h -> type != dhcp_type_subnet) - return ISC_R_INVALIDARG; - subnet = (struct subnet *)h; - -#if defined (DEBUG_MEMORY_LEAKAGE) || \ - defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) - if (subnet -> next_subnet) - subnet_dereference (&subnet -> next_subnet, file, line); - if (subnet -> next_sibling) - subnet_dereference (&subnet -> next_sibling, file, line); - if (subnet -> shared_network) - shared_network_dereference (&subnet -> shared_network, - file, line); - if (subnet -> interface) - interface_dereference (&subnet -> interface, file, line); - if (subnet -> group) - group_dereference (&subnet -> group, file, line); -#endif - - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_subnet_signal_handler (omapi_object_t *h, - const char *name, va_list ap) -{ - struct subnet *subnet; - isc_result_t status; - int updatep = 0; - - if (h -> type != dhcp_type_subnet) - return ISC_R_INVALIDARG; - subnet = (struct subnet *)h; - - /* Can't write subnets yet. */ - - /* Try to find some inner object that can take the value. */ - if (h -> inner && h -> inner -> type -> get_value) { - status = ((*(h -> inner -> type -> signal_handler)) - (h -> inner, name, ap)); - if (status == ISC_R_SUCCESS) - return status; - } - if (updatep) - return ISC_R_SUCCESS; - return ISC_R_NOTFOUND; -} - -isc_result_t dhcp_subnet_stuff_values (omapi_object_t *c, - omapi_object_t *id, - omapi_object_t *h) -{ - struct subnet *subnet; - isc_result_t status; - - if (h -> type != dhcp_type_subnet) - return ISC_R_INVALIDARG; - subnet = (struct subnet *)h; - - /* Can't stuff subnet values yet. */ - - /* Write out the inner object, if any. */ - if (h -> inner && h -> inner -> type -> stuff_values) { - status = ((*(h -> inner -> type -> stuff_values)) - (c, id, h -> inner)); - if (status == ISC_R_SUCCESS) - return status; - } - - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_subnet_lookup (omapi_object_t **lp, - omapi_object_t *id, - omapi_object_t *ref) -{ - omapi_value_t *tv = (omapi_value_t *)0; - isc_result_t status; - struct subnet *subnet; - - /* Can't look up subnets yet. */ - - /* If we get to here without finding a subnet, no valid key was - specified. */ - if (!*lp) - return ISC_R_NOKEYS; - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_subnet_create (omapi_object_t **lp, - omapi_object_t *id) -{ - return ISC_R_NOTIMPLEMENTED; -} - -isc_result_t dhcp_subnet_remove (omapi_object_t *lp, - omapi_object_t *id) -{ - return ISC_R_NOTIMPLEMENTED; -} - -isc_result_t dhcp_shared_network_set_value (omapi_object_t *h, - omapi_object_t *id, - omapi_data_string_t *name, - omapi_typed_data_t *value) -{ - struct shared_network *shared_network; - isc_result_t status; - int foo; - - if (h -> type != dhcp_type_shared_network) - return ISC_R_INVALIDARG; - shared_network = (struct shared_network *)h; - - /* No values to set yet. */ - - /* Try to find some inner object that can take the value. */ - if (h -> inner && h -> inner -> type -> set_value) { - status = ((*(h -> inner -> type -> set_value)) - (h -> inner, id, name, value)); - if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED) - return status; - } - - return ISC_R_NOTFOUND; -} - - -isc_result_t dhcp_shared_network_get_value (omapi_object_t *h, - omapi_object_t *id, - omapi_data_string_t *name, - omapi_value_t **value) -{ - struct shared_network *shared_network; - isc_result_t status; - - if (h -> type != dhcp_type_shared_network) - return ISC_R_INVALIDARG; - shared_network = (struct shared_network *)h; - - /* No values to get yet. */ - - /* Try to find some inner object that can provide the value. */ - if (h -> inner && h -> inner -> type -> get_value) { - status = ((*(h -> inner -> type -> get_value)) - (h -> inner, id, name, value)); - if (status == ISC_R_SUCCESS) - return status; - } - return ISC_R_NOTFOUND; -} - -isc_result_t dhcp_shared_network_destroy (omapi_object_t *h, - const char *file, int line) -{ - struct shared_network *shared_network; - isc_result_t status; - - if (h -> type != dhcp_type_shared_network) - return ISC_R_INVALIDARG; - shared_network = (struct shared_network *)h; - -#if defined (DEBUG_MEMORY_LEAKAGE) || \ - defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) - if (shared_network -> next) - shared_network_dereference (&shared_network -> next, - file, line); - if (shared_network -> name) { - dfree (shared_network -> name, file, line); - shared_network -> name = 0; - } - if (shared_network -> subnets) - subnet_dereference (&shared_network -> subnets, file, line); - if (shared_network -> interface) - interface_dereference (&shared_network -> interface, - file, line); - if (shared_network -> pools) - omapi_object_dereference ((omapi_object_t **) - &shared_network -> pools, file, line); - if (shared_network -> group) - group_dereference (&shared_network -> group, file, line); -#if defined (FAILOVER_PROTOCOL) - if (shared_network -> failover_peer) - omapi_object_dereference ((omapi_object_t **) - &shared_network -> failover_peer, - file, line); -#endif -#endif /* DEBUG_MEMORY_LEAKAGE */ - - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *h, - const char *name, - va_list ap) -{ - struct shared_network *shared_network; - isc_result_t status; - int updatep = 0; - - if (h -> type != dhcp_type_shared_network) - return ISC_R_INVALIDARG; - shared_network = (struct shared_network *)h; - - /* Can't write shared_networks yet. */ - - /* Try to find some inner object that can take the value. */ - if (h -> inner && h -> inner -> type -> get_value) { - status = ((*(h -> inner -> type -> signal_handler)) - (h -> inner, name, ap)); - if (status == ISC_R_SUCCESS) - return status; - } - if (updatep) - return ISC_R_SUCCESS; - return ISC_R_NOTFOUND; -} - -isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *c, - omapi_object_t *id, - omapi_object_t *h) -{ - struct shared_network *shared_network; - isc_result_t status; - - if (h -> type != dhcp_type_shared_network) - return ISC_R_INVALIDARG; - shared_network = (struct shared_network *)h; - - /* Can't stuff shared_network values yet. */ - - /* Write out the inner object, if any. */ - if (h -> inner && h -> inner -> type -> stuff_values) { - status = ((*(h -> inner -> type -> stuff_values)) - (c, id, h -> inner)); - if (status == ISC_R_SUCCESS) - return status; - } - - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_shared_network_lookup (omapi_object_t **lp, - omapi_object_t *id, - omapi_object_t *ref) -{ - omapi_value_t *tv = (omapi_value_t *)0; - isc_result_t status; - struct shared_network *shared_network; - - /* Can't look up shared_networks yet. */ - - /* If we get to here without finding a shared_network, no valid key was - specified. */ - if (!*lp) - return ISC_R_NOKEYS; - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_shared_network_create (omapi_object_t **lp, - omapi_object_t *id) -{ - return ISC_R_NOTIMPLEMENTED; -} - -isc_result_t dhcp_shared_network_remove (omapi_object_t *lp, - omapi_object_t *id) -{ - return ISC_R_NOTIMPLEMENTED; -} - diff --git a/contrib/dhcp-3.0/common/conflex.c b/contrib/dhcp-3.0/common/conflex.c deleted file mode 100644 index 7c809f9..0000000 --- a/contrib/dhcp-3.0/common/conflex.c +++ /dev/null @@ -1,1078 +0,0 @@ -/* conflex.c - - Lexical scanner for dhcpd config file... */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1995-2003 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Internet Systems Consortium, Inc. - * 950 Charter Street - * Redwood City, CA 94063 - * - * http://www.isc.org/ - * - * This software has been written for Internet Systems Consortium - * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. - * To learn more about Internet Systems Consortium, see - * ``http://www.isc.org/''. To learn more about Vixie Enterprises, - * see ``http://www.vix.com''. To learn more about Nominum, Inc., see - * ``http://www.nominum.com''. - */ - -#ifndef lint -static char copyright[] = -"$Id: conflex.c,v 1.92.2.9 2004/11/24 17:39:15 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" -#include - -static int get_char PROTO ((struct parse *)); -static enum dhcp_token get_token PROTO ((struct parse *)); -static void skip_to_eol PROTO ((struct parse *)); -static enum dhcp_token read_string PROTO ((struct parse *)); -static enum dhcp_token read_number PROTO ((int, struct parse *)); -static enum dhcp_token read_num_or_name PROTO ((int, struct parse *)); -static enum dhcp_token intern PROTO ((char *, enum dhcp_token)); - -isc_result_t new_parse (cfile, file, inbuf, buflen, name, eolp) - struct parse **cfile; - int file; - char *inbuf; - unsigned buflen; - const char *name; - int eolp; -{ - struct parse *tmp; - - tmp = dmalloc (sizeof (struct parse), MDL); - if (!tmp) - return ISC_R_NOMEMORY; - memset (tmp, 0, sizeof *tmp); - - tmp -> token = 0; - tmp -> tlname = name; - tmp -> lpos = tmp -> line = 1; - tmp -> cur_line = tmp -> line1; - tmp -> prev_line = tmp -> line2; - tmp -> token_line = tmp -> cur_line; - tmp -> cur_line [0] = tmp -> prev_line [0] = 0; - tmp -> warnings_occurred = 0; - tmp -> file = file; - tmp -> eol_token = eolp; - - tmp -> bufix = 0; - tmp -> buflen = buflen; - if (inbuf) { - tmp -> bufsiz = 0; - tmp -> inbuf = inbuf; - } else { - tmp -> inbuf = dmalloc (8192, MDL); - if (!tmp -> inbuf) { - dfree (tmp, MDL); - return ISC_R_NOMEMORY; - } - tmp -> bufsiz = 8192; - } - - *cfile = tmp; - return ISC_R_SUCCESS; -} - -isc_result_t end_parse (cfile) - struct parse **cfile; -{ - if ((*cfile) -> bufsiz) - dfree ((*cfile) -> inbuf, MDL); - dfree (*cfile, MDL); - *cfile = (struct parse *)0; - return ISC_R_SUCCESS; -} - -static int get_char (cfile) - struct parse *cfile; -{ - /* My kingdom for WITH... */ - int c; - - if (cfile -> bufix == cfile -> buflen) { - if (cfile -> file != -1) { - cfile -> buflen = - read (cfile -> file, - cfile -> inbuf, cfile -> bufsiz); - if (cfile -> buflen == 0) { - c = EOF; - cfile -> bufix = 0; - } else if (cfile -> buflen < 0) { - c = EOF; - cfile -> bufix = cfile -> buflen = 0; - } else { - c = cfile -> inbuf [0]; - cfile -> bufix = 1; - } - } else - c = EOF; - } else { - c = cfile -> inbuf [cfile -> bufix]; - cfile -> bufix++; - } - - if (!cfile -> ugflag) { - if (c == EOL) { - if (cfile -> cur_line == cfile -> line1) { - cfile -> cur_line = cfile -> line2; - cfile -> prev_line = cfile -> line1; - } else { - cfile -> cur_line = cfile -> line1; - cfile -> prev_line = cfile -> line2; - } - cfile -> line++; - cfile -> lpos = 1; - cfile -> cur_line [0] = 0; - } else if (c != EOF) { - if (cfile -> lpos <= 80) { - cfile -> cur_line [cfile -> lpos - 1] = c; - cfile -> cur_line [cfile -> lpos] = 0; - } - cfile -> lpos++; - } - } else - cfile -> ugflag = 0; - return c; -} - -static enum dhcp_token get_token (cfile) - struct parse *cfile; -{ - int c; - enum dhcp_token ttok; - static char tb [2]; - int l, p, u; - - do { - l = cfile -> line; - p = cfile -> lpos; - u = cfile -> ugflag; - - c = get_char (cfile); -#ifdef OLD_LEXER - if (c == '\n' && p == 1 && !u - && cfile -> comment_index < sizeof cfile -> comments) - cfile -> comments [cfile -> comment_index++] = '\n'; -#endif - - if (!(c == '\n' && cfile -> eol_token) - && isascii (c) && isspace (c)) - continue; - if (c == '#') { -#ifdef OLD_LEXER - if (cfile -> comment_index < sizeof cfile -> comments) - cfile -> comments [cfile -> comment_index++] = '#'; -#endif - skip_to_eol (cfile); - continue; - } - if (c == '"') { - cfile -> lexline = l; - cfile -> lexchar = p; - ttok = read_string (cfile); - break; - } - if ((isascii (c) && isdigit (c)) || c == '-') { - cfile -> lexline = l; - cfile -> lexchar = p; - ttok = read_number (c, cfile); - break; - } else if (isascii (c) && isalpha (c)) { - cfile -> lexline = l; - cfile -> lexchar = p; - ttok = read_num_or_name (c, cfile); - break; - } else if (c == EOF) { - ttok = END_OF_FILE; - cfile -> tlen = 0; - break; - } else { - cfile -> lexline = l; - cfile -> lexchar = p; - tb [0] = c; - tb [1] = 0; - cfile -> tval = tb; - cfile -> tlen = 1; - ttok = c; - break; - } - } while (1); - return ttok; -} - -enum dhcp_token next_token (rval, rlen, cfile) - const char **rval; - unsigned *rlen; - struct parse *cfile; -{ - int rv; - - if (cfile -> token) { - if (cfile -> lexline != cfile -> tline) - cfile -> token_line = cfile -> cur_line; - cfile -> lexchar = cfile -> tlpos; - cfile -> lexline = cfile -> tline; - rv = cfile -> token; - cfile -> token = 0; - } else { - rv = get_token (cfile); - cfile -> token_line = cfile -> cur_line; - } - if (rval) - *rval = cfile -> tval; - if (rlen) - *rlen = cfile -> tlen; -#ifdef DEBUG_TOKENS - fprintf (stderr, "%s:%d ", cfile -> tval, rv); -#endif - return rv; -} - -enum dhcp_token peek_token (rval, rlen, cfile) - const char **rval; - unsigned int *rlen; - struct parse *cfile; -{ - int x; - - if (!cfile -> token) { - cfile -> tlpos = cfile -> lexchar; - cfile -> tline = cfile -> lexline; - cfile -> token = get_token (cfile); - if (cfile -> lexline != cfile -> tline) - cfile -> token_line = cfile -> prev_line; - - x = cfile -> lexchar; - cfile -> lexchar = cfile -> tlpos; - cfile -> tlpos = x; - - x = cfile -> lexline; - cfile -> lexline = cfile -> tline; - cfile -> tline = x; - } - if (rval) - *rval = cfile -> tval; - if (rlen) - *rlen = cfile -> tlen; -#ifdef DEBUG_TOKENS - fprintf (stderr, "(%s:%d) ", cfile -> tval, cfile -> token); -#endif - return cfile -> token; -} - -static void skip_to_eol (cfile) - struct parse *cfile; -{ - int c; - do { - c = get_char (cfile); - if (c == EOF) - return; -#ifdef OLD_LEXER - if (cfile -> comment_index < sizeof (cfile -> comments)) - comments [cfile -> comment_index++] = c; -#endif - if (c == EOL) { - return; - } - } while (1); -} - -static enum dhcp_token read_string (cfile) - struct parse *cfile; -{ - int i; - int bs = 0; - int c; - int value = 0; - int hex = 0; - - for (i = 0; i < sizeof cfile -> tokbuf; i++) { - again: - c = get_char (cfile); - if (c == EOF) { - parse_warn (cfile, "eof in string constant"); - break; - } - if (bs == 1) { - switch (c) { - case 't': - cfile -> tokbuf [i] = '\t'; - break; - case 'r': - cfile -> tokbuf [i] = '\r'; - break; - case 'n': - cfile -> tokbuf [i] = '\n'; - break; - case 'b': - cfile -> tokbuf [i] = '\b'; - break; - case '0': - case '1': - case '2': - case '3': - hex = 0; - value = c - '0'; - ++bs; - goto again; - case 'x': - hex = 1; - value = 0; - ++bs; - goto again; - default: - cfile -> tokbuf [i] = c; - bs = 0; - break; - } - bs = 0; - } else if (bs > 1) { - if (hex) { - if (c >= '0' && c <= '9') { - value = value * 16 + (c - '0'); - } else if (c >= 'a' && c <= 'f') { - value = value * 16 + (c - 'a' + 10); - } else if (c >= 'A' && c <= 'F') { - value = value * 16 + (c - 'A' + 10); - } else { - parse_warn (cfile, - "invalid hex digit: %x", - c); - bs = 0; - continue; - } - if (++bs == 4) { - cfile -> tokbuf [i] = value; - bs = 0; - } else - goto again; - } else { - if (c >= '0' && c <= '9') { - value = value * 8 + (c - '0'); - } else { - if (value != 0) { - parse_warn (cfile, - "invalid octal digit %x", - c); - continue; - } else - cfile -> tokbuf [i] = 0; - bs = 0; - } - if (++bs == 4) { - cfile -> tokbuf [i] = value; - bs = 0; - } else - goto again; - } - } else if (c == '\\') { - bs = 1; - goto again; - } else if (c == '"') - break; - else - cfile -> tokbuf [i] = c; - } - /* Normally, I'd feel guilty about this, but we're talking about - strings that'll fit in a DHCP packet here... */ - if (i == sizeof cfile -> tokbuf) { - parse_warn (cfile, - "string constant larger than internal buffer"); - --i; - } - cfile -> tokbuf [i] = 0; - cfile -> tlen = i; - cfile -> tval = cfile -> tokbuf; - return STRING; -} - -static enum dhcp_token read_number (c, cfile) - int c; - struct parse *cfile; -{ - int seenx = 0; - int i = 0; - int token = NUMBER; - - cfile -> tokbuf [i++] = c; - for (; i < sizeof cfile -> tokbuf; i++) { - c = get_char (cfile); - if (!seenx && c == 'x') { - seenx = 1; -#ifndef OLD_LEXER - } else if (isascii (c) && !isxdigit (c) && - (c == '-' || c == '_' || isalpha (c))) { - token = NAME; - } else if (isascii (c) && !isdigit (c) && isxdigit (c)) { - token = NUMBER_OR_NAME; -#endif - } else if (!isascii (c) || !isxdigit (c)) { - if (c != EOF) { - cfile -> bufix--; - cfile -> ugflag = 1; - } - break; - } - cfile -> tokbuf [i] = c; - } - if (i == sizeof cfile -> tokbuf) { - parse_warn (cfile, - "numeric token larger than internal buffer"); - --i; - } - cfile -> tokbuf [i] = 0; - cfile -> tlen = i; - cfile -> tval = cfile -> tokbuf; - return token; -} - -static enum dhcp_token read_num_or_name (c, cfile) - int c; - struct parse *cfile; -{ - int i = 0; - enum dhcp_token rv = NUMBER_OR_NAME; - cfile -> tokbuf [i++] = c; - for (; i < sizeof cfile -> tokbuf; i++) { - c = get_char (cfile); - if (!isascii (c) || - (c != '-' && c != '_' && !isalnum (c))) { - if (c != EOF) { - cfile -> bufix--; - cfile -> ugflag = 1; - } - break; - } - if (!isxdigit (c)) - rv = NAME; - cfile -> tokbuf [i] = c; - } - if (i == sizeof cfile -> tokbuf) { - parse_warn (cfile, "token larger than internal buffer"); - --i; - } - cfile -> tokbuf [i] = 0; - cfile -> tlen = i; - cfile -> tval = cfile -> tokbuf; - return intern (cfile -> tval, rv); -} - -static enum dhcp_token intern (atom, dfv) - char *atom; - enum dhcp_token dfv; -{ - if (!isascii (atom [0])) - return dfv; - - switch (tolower (atom [0])) { - case '-': - if (atom [1] == 0) - return MINUS; - break; - - case 'a': - if (!strncasecmp (atom + 1, "uth", 3)) { - if (!strncasecmp (atom + 3, "uthenticat", 10)) { - if (!strcasecmp (atom + 13, "ed")) - return AUTHENTICATED; - if (!strcasecmp (atom + 13, "ion")) - return AUTHENTICATION; - break; - } - if (!strcasecmp (atom + 1, "uthoritative")) - return AUTHORITATIVE; - break; - } - if (!strcasecmp (atom + 1, "nd")) - return AND; - if (!strcasecmp (atom + 1, "ppend")) - return APPEND; - if (!strcasecmp (atom + 1, "llow")) - return ALLOW; - if (!strcasecmp (atom + 1, "lias")) - return ALIAS; - if (!strcasecmp (atom + 1, "lgorithm")) - return ALGORITHM; - if (!strcasecmp (atom + 1, "bandoned")) - return TOKEN_ABANDONED; - if (!strcasecmp (atom + 1, "dd")) - return TOKEN_ADD; - if (!strcasecmp (atom + 1, "ll")) - return ALL; - if (!strcasecmp (atom + 1, "t")) - return AT; - if (!strcasecmp (atom + 1, "rray")) - return ARRAY; - if (!strcasecmp (atom + 1, "ddress")) - return ADDRESS; - if (!strcasecmp (atom + 1, "ctive")) - return TOKEN_ACTIVE; - break; - case 'b': - if (!strcasecmp (atom + 1, "ackup")) - return TOKEN_BACKUP; - if (!strcasecmp (atom + 1, "ootp")) - return TOKEN_BOOTP; - if (!strcasecmp (atom + 1, "inding")) - return BINDING; - if (!strcasecmp (atom + 1, "inary-to-ascii")) - return BINARY_TO_ASCII; - if (!strcasecmp (atom + 1, "ackoff-cutoff")) - return BACKOFF_CUTOFF; - if (!strcasecmp (atom + 1, "ooting")) - return BOOTING; - if (!strcasecmp (atom + 1, "oot-unknown-clients")) - return BOOT_UNKNOWN_CLIENTS; - if (!strcasecmp (atom + 1, "reak")) - return BREAK; - if (!strcasecmp (atom + 1, "illing")) - return BILLING; - if (!strcasecmp (atom + 1, "oolean")) - return BOOLEAN; - if (!strcasecmp (atom + 1, "alance")) - return BALANCE; - if (!strcasecmp (atom + 1, "ound")) - return BOUND; - break; - case 'c': - if (!strcasecmp (atom + 1, "ase")) - return CASE; - if (!strcasecmp (atom + 1, "ommit")) - return COMMIT; - if (!strcasecmp (atom + 1, "ode")) - return CODE; - if (!strcasecmp (atom + 1, "onfig-option")) - return CONFIG_OPTION; - if (!strcasecmp (atom + 1, "heck")) - return CHECK; - if (!strcasecmp (atom + 1, "lass")) - return CLASS; - if (!strcasecmp (atom + 1, "lose")) - return TOKEN_CLOSE; - if (!strcasecmp (atom + 1, "reate")) - return TOKEN_CREATE; - if (!strcasecmp (atom + 1, "iaddr")) - return CIADDR; - if (!strncasecmp (atom + 1, "lient", 5)) { - if (!strcasecmp (atom + 6, "-identifier")) - return CLIENT_IDENTIFIER; - if (!strcasecmp (atom + 6, "-hostname")) - return CLIENT_HOSTNAME; - if (!strcasecmp (atom + 6, "-state")) - return CLIENT_STATE; - if (!strcasecmp (atom + 6, "-updates")) - return CLIENT_UPDATES; - if (!strcasecmp (atom + 6, "s")) - return CLIENTS; - } - if (!strcasecmp (atom + 1, "oncat")) - return CONCAT; - if (!strcasecmp (atom + 1, "onnect")) - return CONNECT; - if (!strcasecmp (atom + 1, "ommunications-interrupted")) - return COMMUNICATIONS_INTERRUPTED; - if (!strcasecmp (atom + 1, "ltt")) - return CLTT; - break; - case 'd': - if (!strcasecmp (atom + 1, "ns-update")) - return DNS_UPDATE; - if (!strcasecmp (atom + 1, "ns-delete")) - return DNS_DELETE; - if (!strcasecmp (atom + 1, "omain")) - return DOMAIN; - if (!strcasecmp (atom + 1, "omain-name")) - return DOMAIN_NAME; - if (!strcasecmp (atom + 1, "o-forward-update")) - return DO_FORWARD_UPDATE; - if (!strcasecmp (atom + 1, "ebug")) - return TOKEN_DEBUG; - if (!strcasecmp (atom + 1, "eny")) - return DENY; - if (!strcasecmp (atom + 1, "eleted")) - return TOKEN_DELETED; - if (!strcasecmp (atom + 1, "elete")) - return TOKEN_DELETE; - if (!strncasecmp (atom + 1, "efault", 6)) { - if (!atom [7]) - return DEFAULT; - if (!strcasecmp (atom + 7, "-lease-time")) - return DEFAULT_LEASE_TIME; - break; - } - if (!strncasecmp (atom + 1, "ynamic", 6)) { - if (!atom [7]) - return DYNAMIC; - if (!strncasecmp (atom + 7, "-bootp", 6)) { - if (!atom [13]) - return DYNAMIC_BOOTP; - if (!strcasecmp (atom + 13, "-lease-cutoff")) - return DYNAMIC_BOOTP_LEASE_CUTOFF; - if (!strcasecmp (atom + 13, "-lease-length")) - return DYNAMIC_BOOTP_LEASE_LENGTH; - break; - } - } - if (!strcasecmp (atom + 1, "uplicates")) - return DUPLICATES; - if (!strcasecmp (atom + 1, "eclines")) - return DECLINES; - if (!strncasecmp (atom + 1, "efine", 5)) { - if (!strcasecmp (atom + 6, "d")) - return DEFINED; - if (!atom [6]) - return DEFINE; - } - break; - case 'e': - if (isascii (atom [1]) && tolower (atom [1]) == 'x') { - if (!strcasecmp (atom + 2, "tract-int")) - return EXTRACT_INT; - if (!strcasecmp (atom + 2, "ists")) - return EXISTS; - if (!strcasecmp (atom + 2, "piry")) - return EXPIRY; - if (!strcasecmp (atom + 2, "pire")) - return EXPIRE; - if (!strcasecmp (atom + 2, "pired")) - return TOKEN_EXPIRED; - } - if (!strcasecmp (atom + 1, "ncode-int")) - return ENCODE_INT; - if (!strcasecmp (atom + 1, "thernet")) - return ETHERNET; - if (!strcasecmp (atom + 1, "nds")) - return ENDS; - if (!strncasecmp (atom + 1, "ls", 2)) { - if (!strcasecmp (atom + 3, "e")) - return ELSE; - if (!strcasecmp (atom + 3, "if")) - return ELSIF; - break; - } - if (!strcasecmp (atom + 1, "rror")) - return ERROR; - if (!strcasecmp (atom + 1, "val")) - return EVAL; - if (!strcasecmp (atom + 1, "ncapsulate")) - return ENCAPSULATE; - break; - case 'f': - if (!strcasecmp (atom + 1, "atal")) - return FATAL; - if (!strcasecmp (atom + 1, "ilename")) - return FILENAME; - if (!strcasecmp (atom + 1, "ixed-address")) - return FIXED_ADDR; - if (!strcasecmp (atom + 1, "ddi")) - return FDDI; - if (!strcasecmp (atom + 1, "ormerr")) - return NS_FORMERR; - if (!strcasecmp (atom + 1, "unction")) - return FUNCTION; - if (!strcasecmp (atom + 1, "ailover")) - return FAILOVER; - if (!strcasecmp (atom + 1, "ree")) - return TOKEN_FREE; - break; - case 'g': - if (!strcasecmp (atom + 1, "iaddr")) - return GIADDR; - if (!strcasecmp (atom + 1, "roup")) - return GROUP; - if (!strcasecmp (atom + 1, "et-lease-hostnames")) - return GET_LEASE_HOSTNAMES; - break; - case 'h': - if (!strcasecmp (atom + 1, "ba")) - return HBA; - if (!strcasecmp (atom + 1, "ost")) - return HOST; - if (!strcasecmp (atom + 1, "ost-decl-name")) - return HOST_DECL_NAME; - if (!strcasecmp (atom + 1, "ardware")) - return HARDWARE; - if (!strcasecmp (atom + 1, "ostname")) - return HOSTNAME; - if (!strcasecmp (atom + 1, "elp")) - return TOKEN_HELP; - break; - case 'i': - if (!strcasecmp (atom + 1, "nclude")) - return INCLUDE; - if (!strcasecmp (atom + 1, "nteger")) - return INTEGER; - if (!strcasecmp (atom + 1, "nfinite")) - return INFINITE; - if (!strcasecmp (atom + 1, "nfo")) - return INFO; - if (!strcasecmp (atom + 1, "p-address")) - return IP_ADDRESS; - if (!strcasecmp (atom + 1, "nitial-interval")) - return INITIAL_INTERVAL; - if (!strcasecmp (atom + 1, "nterface")) - return INTERFACE; - if (!strcasecmp (atom + 1, "dentifier")) - return IDENTIFIER; - if (!strcasecmp (atom + 1, "f")) - return IF; - if (!strcasecmp (atom + 1, "s")) - return IS; - if (!strcasecmp (atom + 1, "gnore")) - return IGNORE; - break; - case 'k': - if (!strncasecmp (atom + 1, "nown", 4)) { - if (!strcasecmp (atom + 5, "-clients")) - return KNOWN_CLIENTS; - if (!atom[5]) - return KNOWN; - break; - } - if (!strcasecmp (atom + 1, "ey")) - return KEY; - break; - case 'l': - if (!strcasecmp (atom + 1, "ease")) - return LEASE; - if (!strcasecmp (atom + 1, "eased-address")) - return LEASED_ADDRESS; - if (!strcasecmp (atom + 1, "ease-time")) - return LEASE_TIME; - if (!strcasecmp (atom + 1, "imit")) - return LIMIT; - if (!strcasecmp (atom + 1, "et")) - return LET; - if (!strcasecmp (atom + 1, "oad")) - return LOAD; - if (!strcasecmp (atom + 1, "og")) - return LOG; - break; - case 'm': - if (!strncasecmp (atom + 1, "ax", 2)) { - if (!atom [3]) - return TOKEN_MAX; - if (!strcasecmp (atom + 3, "-lease-time")) - return MAX_LEASE_TIME; - if (!strcasecmp (atom + 3, "-transmit-idle")) - return MAX_TRANSMIT_IDLE; - if (!strcasecmp (atom + 3, "-response-delay")) - return MAX_RESPONSE_DELAY; - if (!strcasecmp (atom + 3, "-unacked-updates")) - return MAX_UNACKED_UPDATES; - } - if (!strncasecmp (atom + 1, "in-", 3)) { - if (!strcasecmp (atom + 4, "lease-time")) - return MIN_LEASE_TIME; - if (!strcasecmp (atom + 4, "secs")) - return MIN_SECS; - break; - } - if (!strncasecmp (atom + 1, "edi", 3)) { - if (!strcasecmp (atom + 4, "a")) - return MEDIA; - if (!strcasecmp (atom + 4, "um")) - return MEDIUM; - break; - } - if (!strcasecmp (atom + 1, "atch")) - return MATCH; - if (!strcasecmp (atom + 1, "embers")) - return MEMBERS; - if (!strcasecmp (atom + 1, "y")) - return MY; - if (!strcasecmp (atom + 1, "clt")) - return MCLT; - break; - case 'n': - if (!strcasecmp (atom + 1, "ormal")) - return NORMAL; - if (!strcasecmp (atom + 1, "ameserver")) - return NAMESERVER; - if (!strcasecmp (atom + 1, "etmask")) - return NETMASK; - if (!strcasecmp (atom + 1, "ever")) - return NEVER; - if (!strcasecmp (atom + 1, "ext-server")) - return NEXT_SERVER; - if (!strcasecmp (atom + 1, "ot")) - return TOKEN_NOT; - if (!strcasecmp (atom + 1, "o")) - return NO; - if (!strcasecmp (atom + 1, "s-update")) - return NS_UPDATE; - if (!strcasecmp (atom + 1, "oerror")) - return NS_NOERROR; - if (!strcasecmp (atom + 1, "otauth")) - return NS_NOTAUTH; - if (!strcasecmp (atom + 1, "otimp")) - return NS_NOTIMP; - if (!strcasecmp (atom + 1, "otzone")) - return NS_NOTZONE; - if (!strcasecmp (atom + 1, "xdomain")) - return NS_NXDOMAIN; - if (!strcasecmp (atom + 1, "xrrset")) - return NS_NXRRSET; - if (!strcasecmp (atom + 1, "ull")) - return TOKEN_NULL; - if (!strcasecmp (atom + 1, "ext")) - return TOKEN_NEXT; - if (!strcasecmp (atom + 1, "ew")) - return TOKEN_NEW; - break; - case 'o': - if (!strcasecmp (atom + 1, "mapi")) - return OMAPI; - if (!strcasecmp (atom + 1, "r")) - return OR; - if (!strcasecmp (atom + 1, "n")) - return ON; - if (!strcasecmp (atom + 1, "pen")) - return TOKEN_OPEN; - if (!strcasecmp (atom + 1, "ption")) - return OPTION; - if (!strcasecmp (atom + 1, "ne-lease-per-client")) - return ONE_LEASE_PER_CLIENT; - if (!strcasecmp (atom + 1, "f")) - return OF; - if (!strcasecmp (atom + 1, "wner")) - return OWNER; - break; - case 'p': - if (!strcasecmp (atom + 1, "repend")) - return PREPEND; - if (!strcasecmp (atom + 1, "acket")) - return PACKET; - if (!strcasecmp (atom + 1, "ool")) - return POOL; - if (!strcasecmp (atom + 1, "seudo")) - return PSEUDO; - if (!strcasecmp (atom + 1, "eer")) - return PEER; - if (!strcasecmp (atom + 1, "rimary")) - return PRIMARY; - if (!strncasecmp (atom + 1, "artner", 6)) { - if (!atom [7]) - return PARTNER; - if (!strcasecmp (atom + 7, "-down")) - return PARTNER_DOWN; - } - if (!strcasecmp (atom + 1, "ort")) - return PORT; - if (!strcasecmp (atom + 1, "otential-conflict")) - return POTENTIAL_CONFLICT; - if (!strcasecmp (atom + 1, "ick-first-value") || - !strcasecmp (atom + 1, "ick")) - return PICK; - if (!strcasecmp (atom + 1, "aused")) - return PAUSED; - break; - case 'r': - if (!strcasecmp (atom + 1, "esolution-interrupted")) - return RESOLUTION_INTERRUPTED; - if (!strcasecmp (atom + 1, "ange")) - return RANGE; - if (!strcasecmp (atom + 1, "ecover")) - return RECOVER; - if (!strcasecmp (atom + 1, "ecover-done")) - return RECOVER_DONE; - if (!strcasecmp (atom + 1, "ecover-wait")) - return RECOVER_WAIT; - if (!strcasecmp (atom + 1, "econtact-interval")) - return RECONTACT_INTERVAL; - if (!strcasecmp (atom + 1, "equest")) - return REQUEST; - if (!strcasecmp (atom + 1, "equire")) - return REQUIRE; - if (!strcasecmp (atom + 1, "equire")) - return REQUIRE; - if (!strcasecmp (atom + 1, "etry")) - return RETRY; - if (!strcasecmp (atom + 1, "eturn")) - return RETURN; - if (!strcasecmp (atom + 1, "enew")) - return RENEW; - if (!strcasecmp (atom + 1, "ebind")) - return REBIND; - if (!strcasecmp (atom + 1, "eboot")) - return REBOOT; - if (!strcasecmp (atom + 1, "eject")) - return REJECT; - if (!strcasecmp (atom + 1, "everse")) - return REVERSE; - if (!strcasecmp (atom + 1, "elease")) - return RELEASE; - if (!strcasecmp (atom + 1, "efused")) - return NS_REFUSED; - if (!strcasecmp (atom + 1, "eleased")) - return TOKEN_RELEASED; - if (!strcasecmp (atom + 1, "eset")) - return TOKEN_RESET; - if (!strcasecmp (atom + 1, "eserved")) - return TOKEN_RESERVED; - if (!strcasecmp (atom + 1, "emove")) - return REMOVE; - if (!strcasecmp (atom + 1, "efresh")) - return REFRESH; - break; - case 's': - if (!strcasecmp (atom + 1, "tate")) - return STATE; - if (!strcasecmp (atom + 1, "ecret")) - return SECRET; - if (!strcasecmp (atom + 1, "ervfail")) - return NS_SERVFAIL; - if (!strcasecmp (atom + 1, "witch")) - return SWITCH; - if (!strcasecmp (atom + 1, "igned")) - return SIGNED; - if (!strcasecmp (atom + 1, "tring")) - return STRING_TOKEN; - if (!strcasecmp (atom + 1, "uffix")) - return SUFFIX; - if (!strcasecmp (atom + 1, "earch")) - return SEARCH; - if (!strcasecmp (atom + 1, "tarts")) - return STARTS; - if (!strcasecmp (atom + 1, "iaddr")) - return SIADDR; - if (!strcasecmp (atom + 1, "hared-network")) - return SHARED_NETWORK; - if (!strcasecmp (atom + 1, "econdary")) - return SECONDARY; - if (!strcasecmp (atom + 1, "erver-name")) - return SERVER_NAME; - if (!strcasecmp (atom + 1, "erver-identifier")) - return SERVER_IDENTIFIER; - if (!strcasecmp (atom + 1, "erver")) - return SERVER; - if (!strcasecmp (atom + 1, "elect-timeout")) - return SELECT_TIMEOUT; - if (!strcasecmp (atom + 1, "elect")) - return SELECT; - if (!strcasecmp (atom + 1, "end")) - return SEND; - if (!strcasecmp (atom + 1, "cript")) - return SCRIPT; - if (!strcasecmp (atom + 1, "upersede")) - return SUPERSEDE; - if (!strncasecmp (atom + 1, "ub", 2)) { - if (!strcasecmp (atom + 3, "string")) - return SUBSTRING; - if (!strcasecmp (atom + 3, "net")) - return SUBNET; - if (!strcasecmp (atom + 3, "class")) - return SUBCLASS; - break; - } - if (!strcasecmp (atom + 1, "pawn")) - return SPAWN; - if (!strcasecmp (atom + 1, "pace")) - return SPACE; - if (!strcasecmp (atom + 1, "tatic")) - return STATIC; - if (!strcasecmp (atom + 1, "plit")) - return SPLIT; - if (!strcasecmp (atom + 1, "et")) - return TOKEN_SET; - if (!strcasecmp (atom + 1, "econds")) - return SECONDS; - if (!strcasecmp (atom + 1, "hutdown")) - return SHUTDOWN; - if (!strcasecmp (atom + 1, "tartup")) - return STARTUP; - break; - case 't': - if (!strcasecmp (atom + 1, "imestamp")) - return TIMESTAMP; - if (!strcasecmp (atom + 1, "imeout")) - return TIMEOUT; - if (!strcasecmp (atom + 1, "oken-ring")) - return TOKEN_RING; - if (!strcasecmp (atom + 1, "ext")) - return TEXT; - if (!strcasecmp (atom + 1, "stp")) - return TSTP; - if (!strcasecmp (atom + 1, "sfp")) - return TSFP; - if (!strcasecmp (atom + 1, "ransmission")) - return TRANSMISSION; - break; - case 'u': - if (!strcasecmp (atom + 1, "nset")) - return UNSET; - if (!strcasecmp (atom + 1, "nsigned")) - return UNSIGNED; - if (!strcasecmp (atom + 1, "id")) - return UID; - 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 (!strncasecmp (atom + 1, "nknown", 6)) { - if (!strcasecmp (atom + 7, "-clients")) - return UNKNOWN_CLIENTS; - if (!strcasecmp (atom + 7, "-state")) - return UNKNOWN_STATE; - if (!atom [7]) - return UNKNOWN; - break; - } - if (!strcasecmp (atom + 1, "nauthenticated")) - return AUTHENTICATED; - if (!strcasecmp (atom + 1, "pdated-dns-rr")) - return UPDATED_DNS_RR; - if (!strcasecmp (atom + 1, "pdate")) - return UPDATE; - break; - case 'v': - if (!strcasecmp (atom + 1, "endor-class")) - return VENDOR_CLASS; - if (!strcasecmp (atom + 1, "endor")) - return VENDOR; - break; - case 'w': - if (!strcasecmp (atom + 1, "ith")) - return WITH; - break; - case 'y': - if (!strcasecmp (atom + 1, "iaddr")) - return YIADDR; - if (!strcasecmp (atom + 1, "xdomain")) - return NS_YXDOMAIN; - if (!strcasecmp (atom + 1, "xrrset")) - return NS_YXRRSET; - break; - case 'z': - if (!strcasecmp (atom + 1, "one")) - return ZONE; - break; - } - return dfv; -} diff --git a/contrib/dhcp-3.0/common/ctrace.c b/contrib/dhcp-3.0/common/ctrace.c deleted file mode 100644 index 1149faa..0000000 --- a/contrib/dhcp-3.0/common/ctrace.c +++ /dev/null @@ -1,295 +0,0 @@ -/* trace.c - - Subroutines that support dhcp tracing... */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 2001-2003 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Internet Systems Consortium, Inc. - * 950 Charter Street - * Redwood City, CA 94063 - * - * http://www.isc.org/ - * - * This software has been written for Internet Systems Consortium - * by Ted Lemon, as part of a project for Nominum, Inc. To learn more - * about Internet Systems Consortium, see http://www.isc.org/. To - * learn more about Nominum, Inc., see ``http://www.nominum.com''. - */ - -#ifndef lint -static char copyright[] = -"$Id: ctrace.c,v 1.3.2.3 2004/09/30 20:23:06 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" - -#if defined (TRACING) -void trace_interface_register (trace_type_t *ttype, struct interface_info *ip) -{ - trace_interface_packet_t tipkt; - - if (trace_record ()) { - memset (&tipkt, 0, sizeof tipkt); - memcpy (&tipkt.hw_address, - &ip -> hw_address, sizeof ip -> hw_address); - memcpy (&tipkt.primary_address, - &ip -> primary_address, sizeof ip -> primary_address); - memcpy (tipkt.name, ip -> name, sizeof ip -> name); - tipkt.index = htonl (ip -> index); - - trace_write_packet (ttype, sizeof tipkt, (char *)&tipkt, MDL); - } -} - -void trace_interface_input (trace_type_t *ttype, unsigned len, char *buf) -{ - trace_interface_packet_t *tipkt; - struct interface_info *ip; - struct sockaddr_in *sin; - struct iaddr addr; - isc_result_t status; - - if (len != sizeof *tipkt) { - log_error ("trace interface packet size mismatch: %ld != %d", - (long)(sizeof *tipkt), len); - return; - } - tipkt = (trace_interface_packet_t *)buf; - - ip = (struct interface_info *)0; - status = interface_allocate (&ip, MDL); - if (status != ISC_R_SUCCESS) { - foo: - log_error ("trace_interface_input: %s.", - isc_result_totext (status)); - return; - } - ip -> ifp = dmalloc (sizeof *(ip -> ifp), MDL); - if (!ip -> ifp) { - interface_dereference (&ip, MDL); - status = ISC_R_NOMEMORY; - goto foo; - } - - memcpy (&ip -> hw_address, &tipkt -> hw_address, - sizeof ip -> hw_address); - memcpy (&ip -> primary_address, &tipkt -> primary_address, - sizeof ip -> primary_address); - memcpy (ip -> name, tipkt -> name, sizeof ip -> name); - ip -> index = ntohl (tipkt -> index); - - interface_snorf (ip, 0); - if (dhcp_interface_discovery_hook) - (*dhcp_interface_discovery_hook) (ip); - - /* Fake up an ifp. */ - memcpy (ip -> ifp -> ifr_name, ip -> name, sizeof ip -> name); -#ifdef HAVE_SA_LEN - ip -> ifp -> ifr_addr.sa_len = sizeof (struct sockaddr_in); -#endif - sin = (struct sockaddr_in *)&ip -> ifp -> ifr_addr; - sin -> sin_addr = ip -> primary_address; - - addr.len = 4; - memcpy (addr.iabuf, &sin -> sin_addr.s_addr, addr.len); - if (dhcp_interface_setup_hook) - (*dhcp_interface_setup_hook) (ip, &addr); - interface_stash (ip); - - if (!quiet_interface_discovery) { - log_info ("Listening on Trace/%s/%s%s%s", - ip -> name, - print_hw_addr (ip -> hw_address.hbuf [0], - ip -> hw_address.hlen - 1, - &ip -> hw_address.hbuf [1]), - (ip -> shared_network ? "/" : ""), - (ip -> shared_network ? - ip -> shared_network -> name : "")); - if (strcmp (ip -> name, "fallback")) { - log_info ("Sending on Trace/%s/%s%s%s", - ip -> name, - print_hw_addr (ip -> hw_address.hbuf [0], - ip -> hw_address.hlen - 1, - &ip -> hw_address.hbuf [1]), - (ip -> shared_network ? "/" : ""), - (ip -> shared_network ? - ip -> shared_network -> name : "")); - } - } - interface_dereference (&ip, MDL); -} - -void trace_interface_stop (trace_type_t *ttype) { - /* XXX */ -} - -void trace_inpacket_stash (struct interface_info *interface, - struct dhcp_packet *packet, - unsigned len, - unsigned int from_port, - struct iaddr from, - struct hardware *hfrom) -{ - trace_inpacket_t tip; - trace_iov_t iov [2]; - - if (!trace_record ()) - return; - tip.from_port = from_port; - tip.from = from; - tip.from.len = htonl (tip.from.len); - if (hfrom) { - tip.hfrom = *hfrom; - tip.havehfrom = 1; - } else { - memset (&tip.hfrom, 0, sizeof tip.hfrom); - tip.havehfrom = 0; - } - tip.index = htonl (interface -> index); - - iov [0].buf = (char *)&tip; - iov [0].len = sizeof tip; - iov [1].buf = (char *)packet; - iov [1].len = len; - trace_write_packet_iov (inpacket_trace, 2, iov, MDL); -} - -void trace_inpacket_input (trace_type_t *ttype, unsigned len, char *buf) -{ - trace_inpacket_t *tip; - int index; - - if (len < sizeof *tip) { - log_error ("trace_input_packet: too short - %d", len); - return; - } - tip = (trace_inpacket_t *)buf; - index = ntohl (tip -> index); - tip -> from.len = ntohl (tip -> from.len); - - if (index > interface_count || - index < 0 || - !interface_vector [index]) { - log_error ("trace_input_packet: unknown interface index %d", - index); - return; - } - - if (!bootp_packet_handler) { - log_error ("trace_input_packet: no bootp packet handler."); - return; - } - - (*bootp_packet_handler) (interface_vector [index], - (struct dhcp_packet *)(tip + 1), - len - sizeof *tip, - tip -> from_port, - tip -> from, - (tip -> havehfrom ? - &tip -> hfrom - : (struct hardware *)0)); -} - -void trace_inpacket_stop (trace_type_t *ttype) { } - -ssize_t trace_packet_send (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) -{ - trace_outpacket_t tip; - trace_iov_t iov [2]; - - if (trace_record ()) { - if (hto) { - tip.hto = *hto; - tip.havehto = 1; - } else { - memset (&tip.hto, 0, sizeof tip.hto); - tip.havehto = 0; - } - tip.from.len = 4; - memcpy (tip.from.iabuf, &from, 4); - tip.to.len = 4; - memcpy (tip.to.iabuf, &to -> sin_addr, 4); - tip.to_port = to -> sin_port; - tip.index = htonl (interface -> index); - - iov [0].buf = (char *)&tip; - iov [0].len = sizeof tip; - iov [1].buf = (char *)raw; - iov [1].len = len; - trace_write_packet_iov (outpacket_trace, 2, iov, MDL); - } - if (!trace_playback ()) { - return send_packet (interface, packet, raw, len, - from, to, hto); - } - return len; -} - -void trace_outpacket_input (trace_type_t *ttype, unsigned len, char *buf) -{ - trace_outpacket_t *tip; - int index; - - if (len < sizeof *tip) { - log_error ("trace_input_packet: too short - %d", len); - return; - } - tip = (trace_outpacket_t *)buf; - index = ntohl (tip -> index); - - if (index > interface_count || - index < 0 || - !interface_vector [index]) { - log_error ("trace_input_packet: unknown interface index %d", - index); - return; - } - - /* XXX would be nice to somehow take notice of these. */ -} - -void trace_outpacket_stop (trace_type_t *ttype) { } - -void trace_seed_stash (trace_type_t *ttype, unsigned seed) -{ - u_int32_t outseed; - if (!trace_record ()) - return; - outseed = htonl (seed); - trace_write_packet (ttype, sizeof outseed, (char *)&outseed, MDL); - return; -} - -void trace_seed_input (trace_type_t *ttype, unsigned length, char *buf) -{ - u_int32_t *seed; - - if (length != sizeof seed) { - log_error ("trace_seed_input: wrong size (%d)", length); - } - seed = (u_int32_t *)buf; - srandom (ntohl (*seed)); -} - -void trace_seed_stop (trace_type_t *ttype) { } -#endif /* TRACING */ diff --git a/contrib/dhcp-3.0/common/dhcp-eval.5 b/contrib/dhcp-3.0/common/dhcp-eval.5 deleted file mode 100644 index b2a44f7..0000000 --- a/contrib/dhcp-3.0/common/dhcp-eval.5 +++ /dev/null @@ -1,478 +0,0 @@ -.\" $Id: dhcp-eval.5,v 1.17.2.8 2004/10/12 18:45:10 dhankins Exp $ -.\" -.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") -.\" Copyright (c) 1996-2003 by Internet Software Consortium -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.\" Internet Systems Consortium, Inc. -.\" 950 Charter Street -.\" Redwood City, CA 94063 -.\" -.\" http://www.isc.org/ -.\" -.\" This software has been written for Internet Systems Consortium -.\" by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. -.\" To learn more about Internet Systems Consortium, see -.\" ``http://www.isc.org/''. To learn more about Vixie Enterprises, -.\" see ``http://www.vix.com''. To learn more about Nominum, Inc., see -.\" ``http://www.nominum.com''. -.TH dhcp-eval 5 -.SH NAME -dhcp-eval - ISC DHCP conditional evaluation -.SH DESCRIPTION -The Internet Systems Consortium DHCP client and server both provide -the ability to perform conditional behavior depending on the contents -of packets they receive. The syntax for specifying this conditional -behaviour is documented here. -.SH REFERENCE: CONDITIONAL BEHAVIOUR -Conditional behaviour is specified using the if statement and the else -or elsif statements. A conditional statement can appear anywhere -that a regular statement (e.g., an option statement) can appear, and -can enclose one or more such statements. A typical conditional -statement in a server might be: -.PP -.nf -if option dhcp-user-class = "accounting" { - max-lease-time 17600; - option domain-name "accounting.example.org"; - option domain-name-servers ns1.accounting.example.org, - ns2.accounting.example.org; -} elsif option dhcp-user-class = "sales" { - max-lease-time 17600; - option domain-name "sales.example.org"; - option domain-name-servers ns1.sales.example.org, - ns2.sales.example.org; -} elsif option dhcp-user-class = "engineering" { - max-lease-time 17600; - option domain-name "engineering.example.org"; - option domain-name-servers ns1.engineering.example.org, - ns2.engineering.example.org; -} else { - max-lease-time 600; - option domain-name "misc.example.org"; - option domain-name-servers ns1.misc.example.org, - ns2.misc.example.org; -} -.fi -.PP -On the client side, an example of conditional evaluation might be: -.PP -.nf -# example.org filters DNS at its firewall, so we have to use their DNS -# servers when we connect to their network. If we are not at -# example.org, prefer our own DNS server. -if not option domain-name = "example.org" { - prepend domain-name-servers 127.0.0.1; -} -.fi -.PP -The -.B if -statement and the -.B elsif -continuation statement both take boolean expressions as their -arguments. That is, they take expressions that, when evaluated, -produce a boolean result. If the expression evaluates to true, then -the statements enclosed in braces following the -.B if -statement are executed, and all subsequent -.B elsif -and -.B else -clauses are skipped. Otherwise, each subsequent -.B elsif -clause's expression is checked, until an elsif clause is encountered -whose test evaluates to true. If such a clause is found, the -statements in braces following it are executed, and then any -subsequent -.B elsif -and -.B else -clauses are skipped. If all the -.B if -and -.B elsif -clauses are checked but none -of their expressions evaluate true, then if there is an -.B else -clause, the statements enclosed in braces following the -.B else -are evaluated. Boolean expressions that evaluate to null are -treated as false in conditionals. -.SH BOOLEAN EXPRESSIONS -The following is the current list of boolean expressions that are -supported by the DHCP distribution. -.PP -.I data-expression-1 \fB=\fI data-expression-2\fR -.RS 0.25i -.PP -The \fB=\fR operator compares the values of two data expressions, -returning true if they are the same, false if they are not. If -either the left-hand side or the right-hand side are null, the -result is also null. -.RE -.PP -.I boolean-expression-1 \fBand\fI boolean-expression-2\fR -.PP -.RS 0.25i -The \fBand\fR operator evaluates to true if the boolean expression on -the left-hand side and the boolean expression on the right-hand side -both evaluate to true. Otherwise, it evaluates to false. If either -the expression on the left-hand side or the expression on the -right-hand side are null, the result is null. -.RE -.PP -.I boolean-expression-1 \fBor\fI boolean-expression-2\fR -.PP -.RS 0.25i -The \fBor\fR operator evaluates to true if either the boolean -expression on the left-hand side or the boolean expression on the -right-hand side evaluate to true. Otherwise, it evaluates to false. -If either the expression on the left-hand side or the expression on -the right-hand side are null, the result is null. -.RE -.PP -.B not \fIboolean-expression -.PP -.RS 0.25i -The \fBnot\fR operator evaluates to true if \fIboolean-expression\fR -evaluates to false, and returns false if \fIboolean-expression\fR evaluates -to true. If \fIboolean-expression\fR evaluates to null, the result -is also null. -.RE -.PP -.B exists \fIoption-name\fR -.PP -.RS 0.25i -The \fBexists\fR expression returns true if the specified option -exists in the incoming DHCP packet being processed. -.RE -.B known -.PP -.RS 0.25i -The \fBknown\fR expression returns true if the client whose request is -currently being processed is known - that is, if there's a host -declaration for it. -.RE -.B static -.PP -.RS 0.25i -The \fBstatic\fR expression returns true if the lease assigned to the -client whose request is currently being processed is derived from a static -address assignment. -.RE -.SH DATA EXPRESSIONS -Several of the boolean expressions above depend on the results of -evaluating data expressions. A list of these expressions is provided -here. -.PP -.B substring (\fIdata-expr\fB, \fIoffset\fB, \fIlength\fB)\fR -.PP -.RS 0.25i -The \fBsubstring\fR operator evaluates the data expression and returns -the substring of the result of that evaluation that starts -\fIoffset\fR bytes from the beginning, continuing for \fIlength\fR -bytes. \fIOffset\fR and \fIlength\fR are both numeric expressions. -If \fIdata-expr\fR, \fIoffset\fR or \fIlength\fR evaluate to null, -then the result is also null. If \fIoffset\fR is greater than or -equal to the length of the evaluated data, then a zero-length data -string is returned. If \fIlength\fI is greater then the remaining -length of the evaluated data after \fIoffset\fR, then a data string -containing all data from \fIoffset\fR to the end of the evaluated data -is returned. -.RE -.PP -.B suffix (\fIdata-expr\fB, \fIlength\fB)\fR -.PP -.RS 0.25i -The \fBsuffix\fR operator evaluates \fIdata-expr\fR and returns the -last \fIlength\fR bytes of the result of that evaluation. \fILength\fR -is a numeric expression. If \fIdata-expr\fR or \fIlength\fR evaluate -to null, then the result is also null. If \fIsuffix\fR evaluates to a -number greater than the length of the evaluated data, then the -evaluated data is returned. -.RE -.PP -.B option \fIoption-name\fR -.PP -.RS 0.25i -The \fBoption\fR operator returns the contents of the specified option in -the packet to which the server is responding. -.RE -.PP -.B config-option \fIoption-name\fR -.PP -.RS 0.25i -The \fBconfig-option\fR operator returns the value for the specified option -that the DHCP client or server has been configured to send. -.RE -.PP -.B hardware -.PP -.RS 0.25i -The \fBhardware\fR operator returns a data string whose first element -is the type of network interface indicated in packet being considered, -and whose subsequent elements are client's link-layer address. If -there is no packet, or if the RFC2131 \fIhlen\fR field is invalid, -then the result is null. Hardware types include ethernet (1), -token-ring (6), and fddi (8). Hardware types are specified by the -IETF, and details on how the type numbers are defined can be found in -RFC2131 (in the ISC DHCP distribution, this is included in the doc/ -subdirectory). -.RE -.PP -.B packet (\fIoffset\fB, \fIlength\fB)\fR -.PP -.RS 0.25i -The \fBpacket\fR operator returns the specified portion of the packet -being considered, or null in contexts where no packet is being -considered. \fIOffset\fR and \fIlength\fR are applied to the -contents packet as in the \fBsubstring\fR operator. -.RE -.PP -.I string -.PP -.RS 0.25i -A string, enclosed in quotes, may be specified as a data expression, -and returns the text between the quotes, encoded in ASCII. The -backslash ('\\') character is treated specially, as in C programming: '\\t' -means TAB, '\\r' means carriage return, '\\n' means newline, and '\\b' means -bell. Any octal value can be specified with '\\nnn', where nnn is any -positive octal number less than 0400. Any hexadecimal value can be -specified with '\\xnn', where nn is any positive hexadecimal number less -than 0xff. -.RE -.PP -.I colon-separated hexadecimal list -.PP -.RS 0.25i -A list of hexadecimal octet values, separated by colons, may be -specified as a data expression. -.RE -.PP -.B concat (\fIdata-expr1\fB, ..., \fIdata-exprN\fB)\fR -.RS 0.25i -The expressions are evaluated, and the results of each evaluation are -concatenated in the sequence that the subexpressions are listed. If -any subexpression evaluates to null, the result of the concatenation -is null. -.RE -.PP -.B reverse (\fInumeric-expr1\fB, \fIdata-expr2\fB)\fR -.RS 0.25i -The two expressions are evaluated, and then the result of evaluating -the data expression is reversed in place, using hunks of the size -specified in the numeric expression. For example, if the numeric -expression evaluates to four, and the data expression evaluates to -twelve bytes of data, then the reverse expression will evaluate to -twelve bytes of data, consisting of the last four bytes of the the -input data, followed by the middle four bytes, followed by the first -four bytes. -.RE -.PP -.B leased-address -.RS 0.25i -In any context where the client whose request is being processed has -been assigned an IP address, this data expression returns that IP -address. -.RE -.PP -.B binary-to-ascii (\fInumeric-expr1\fB, \fInumeric-expr2\fB, -.B \fIdata-expr1\fB,\fR \fIdata-expr2\fB)\fR -.RS 0.25i -Converts the result of evaluating data-expr2 into a text string -containing one number for each element of the result of evaluating -data-expr2. Each number is separated from the other by the result of -evaluating data-expr1. The result of evaluating numeric-expr1 -specifies the base (2 through 16) into which the numbers should be -converted. The result of evaluating numeric-expr2 specifies the -width in bits of each number, which may be either 8, 16 or 32. -.PP -As an example of the preceding three types of expressions, to produce -the name of a PTR record for the IP address being assigned to a -client, one could write the following expression: -.RE -.PP -.nf - concat (binary-to-ascii (10, 8, ".", - reverse (1, leased-address)), - ".in-addr.arpa."); - -.fi -.PP -.B encode-int (\fInumeric-expr\fB, \fIwidth\fB)\fR -.RS 0.25i -Numeric-expr is evaluated and encoded as a data string of the -specified width, in network byte order (most significant byte first). -If the numeric expression evaluates to the null value, the result is -also null. -.RE -.PP -.B pick-first-value (\fIdata-expr1\fR [ ... \fIexpr\fRn ] \fB)\fR -.RS 0.25i -The pick-first-value function takes any number of data expressions as -its arguments. Each expression is evaluated, starting with the first -in the list, until an expression is found that does not evaluate to a -null value. That expression is returned, and none of the subsequent -expressions are evaluated. If all expressions evaluate to a null -value, the null value is returned. -.RE -.PP -.B host-decl-name -.RS 0.25i -The host-decl-name function returns the name of the host declaration -that matched the client whose request is currently being processed, if -any. If no host declaration matched, the result is the null value. -.RE -.SH NUMERIC EXPRESSIONS -Numeric expressions are expressions that evaluate to an integer. In -general, the maximum size of such an integer should not be assumed to -be representable in fewer than 32 bits, but the precision of such -integers may be more than 32 bits. -.PP -.B extract-int (\fIdata-expr\fB, \fIwidth\fB)\fR -.PP -.RS 0.25i -The \fBextract-int\fR operator extracts an integer value in network -byte order from the result of evaluating the specified data -expression. Width is the width in bits of the integer to extract. -Currently, the only supported widths are 8, 16 and 32. If the -evaluation of the data expression doesn't provide sufficient bits to -extract an integer of the specified size, the null value is returned. -.RE -.PP -.B lease-time -.PP -.RS 0.25i -The duration of the current lease - that is, the difference between -the current time and the time that the lease expires. -.RE -.PP -.I number -.PP -.RS 0.25i -Any number between zero and the maximum representable size may be -specified as a numeric expression. -.RE -.PP -.B client-state -.PP -.RS 0.25i -The current state of the client instance being processed. This is -only useful in DHCP client configuration files. Possible values are: -.TP 2 -.I \(bu -Booting - DHCP client is in the INIT state, and does not yet have an -IP address. The next message transmitted will be a DHCPDISCOVER, -which will be broadcast. -.TP -.I \(bu -Reboot - DHCP client is in the INIT-REBOOT state. It has an IP -address, but is not yet using it. The next message to be transmitted -will be a DHCPREQUEST, which will be broadcast. If no response is -heard, the client will bind to its address and move to the BOUND state. -.TP -.I \(bu -Select - DHCP client is in the SELECTING state - it has received at -least one DHCPOFFER message, but is waiting to see if it may receive -other DHCPOFFER messages from other servers. No messages are sent in -the SELECTING state. -.TP -.I \(bu -Request - DHCP client is in the REQUESTING state - it has received at -least one DHCPOFFER message, and has chosen which one it will -request. The next message to be sent will be a DHCPREQUEST message, -which will be broadcast. -.TP -.I \(bu -Bound - DHCP client is in the BOUND state - it has an IP address. No -messages are transmitted in this state. -.TP -.I \(bu -Renew - DHCP client is in the RENEWING state - it has an IP address, -and is trying to contact the server to renew it. The next message to -be sent will be a DHCPREQUEST message, which will be unicast directly -to the server. -.TP -.I \(bu -Rebind - DHCP client is in the REBINDING state - it has an IP address, -and is trying to contact any server to renew it. The next message to -be sent will be a DHCPREQUEST, which will be broadcast. -.RE -.SH REFERENCE: LOGGING -Logging statements may be used to send information to the standard logging -channels. A logging statement includes an optional priority (\fBfatal\fR, -\fBerror\fR, \fBinfo\fR, or \fBdebug\fR), and a data expression. -.PP -.B log (\fIpriority\fB, \fIdata-expr\fB)\fR -.PP -Logging statements take only a single data expression argument, so if you -want to output multiple data values, you will need to use the \fBconcat\fR -operator to concatenate them. -.RE -.SH REFERENCE: DYNAMIC DNS UPDATES -.PP -The DHCP client and server have the ability to dynamically update the -Domain Name System. Within the configuration files, you can define -how you want the Domain Name System to be updated. These updates are -RFC 2136 compliant so any DNS server supporting RFC 2136 should be -able to accept updates from the DHCP server. -.SH SECURITY -Support for TSIG and DNSSEC is not yet available. When you set your -DNS server up to allow updates from the DHCP server or client, you may -be exposing it to unauthorized updates. To avoid this, the best you -can do right now is to use IP address-based packet filtering to -prevent unauthorized hosts from submitting update requests. -Obviously, there is currently no way to provide security for client -updates - this will require TSIG or DNSSEC, neither of which is yet -available in the DHCP distribution. -.PP -Dynamic DNS (DDNS) updates are performed by using the \fBdns-update\fR -expression. The \fBdns-update\fR expression is a boolean expression -that takes four parameters. If the update succeeds, the result is -true. If it fails, the result is false. The four parameters that the -are the resource record type (RR), the left hand side of the RR, the -right hand side of the RR and the ttl that should be applied to the -record. The simplest example of the use of the function can be found -in the reference section of the dhcpd.conf file, where events are -described. In this example several statements are being used to make -the arguments to the \fBdns-update\f\R. -.PP -In the example, the first argument to the first \f\Bdns-update\fR -expression is a data expression that evaluates to the A RR type. The -second argument is constructed by concatenating the DHCP host-name -option with a text string containing the local domain, in this case -"ssd.example.net". The third argument is constructed by converting -the address the client has been assigned from a 32-bit number into an -ascii string with each byte separated by a ".". The fourth argument, -the TTL, specifies the amount of time remaining in the lease (note -that this isn't really correct, since the DNS server will pass this -TTL out whenever a request comes in, even if that is only a few -seconds before the lease expires). -.PP -If the first \fBdns-update\fR statement succeeds, it is followed up -with a second update to install a PTR RR. The installation of a PTR -record is similar to installing an A RR except that the left hand side -of the record is the leased address, reversed, with ".in-addr.arpa" -concatenated. The right hand side is the fully qualified domain name -of the client to which the address is being leased. -.SH SEE ALSO -dhcpd.conf(5), dhcpd.leases(5), dhclient.conf(5), dhcp-eval(5), dhcpd(8), -dhclient(8), RFC2132, RFC2131. -.SH AUTHOR -The Internet Systems Consortium DHCP Distribution was written by Ted -Lemon under a contract with Vixie Labs. Funding for -this project was provided through Internet Systems Consortium. -Information about Internet Systems Consortium can be found at -.B http://www.isc.org. diff --git a/contrib/dhcp-3.0/common/dhcp-options.5 b/contrib/dhcp-3.0/common/dhcp-options.5 deleted file mode 100644 index dac94a8..0000000 --- a/contrib/dhcp-3.0/common/dhcp-options.5 +++ /dev/null @@ -1,1515 +0,0 @@ -.\" $Id: dhcp-options.5,v 1.19.2.14 2004/09/21 22:43:09 dhankins Exp $ -.\" -.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") -.\" Copyright (c) 1996-2003 by Internet Software Consortium -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.\" Internet Systems Consortium, Inc. -.\" 950 Charter Street -.\" Redwood City, CA 94063 -.\" -.\" http://www.isc.org/ -.\" -.\" This software has been written for Internet Systems Consortium -.\" by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. -.\" To learn more about Internet Systems Consortium, see -.\" ``http://www.isc.org/''. To learn more about Vixie Enterprises, -.\" see ``http://www.vix.com''. To learn more about Nominum, Inc., see -.\" ``http://www.nominum.com''. -.TH dhcpd-options 5 -.SH NAME -dhcp-options - Dynamic Host Configuration Protocol options -.SH DESCRIPTION -The Dynamic Host Configuration protocol allows the client to receive -.B options -from the DHCP server describing the network configuration and various -services that are available on the network. When configuring -.B dhcpd(8) -or -.B dhclient(8) , -options must often be declared. The syntax for declaring options, -and the names and formats of the options that can be declared, are -documented here. -.SH REFERENCE: OPTION STATEMENTS -.PP -DHCP \fIoption\fR statements always start with the \fIoption\fR -keyword, followed by an option name, followed by option data. The -option names and data formats are described below. It is not -necessary to exhaustively specify all DHCP options - only those -options which are needed by clients must be specified. -.PP -Option data comes in a variety of formats, as defined below: -.PP -The -.B ip-address -data type can be entered either as an explicit IP -address (e.g., 239.254.197.10) or as a domain name (e.g., -haagen.isc.org). When entering a domain name, be sure that that -domain name resolves to a single IP address. -.PP -The -.B int32 -data type specifies a signed 32-bit integer. The -.B uint32 -data type specifies an unsigned 32-bit integer. The -.B int16 -and -.B uint16 -data types specify signed and unsigned 16-bit integers. The -.B int8 -and -.B uint8 -data types specify signed and unsigned 8-bit integers. -Unsigned 8-bit integers are also sometimes referred to as octets. -.PP -The -.B text -data type specifies an NVT ASCII string, which must be -enclosed in double quotes - for example, to specify a root-path -option, the syntax would be -.nf -.sp 1 -option root-path "10.0.1.4:/var/tmp/rootfs"; -.fi -.PP -The -.B domain-name -data type specifies a domain name, which must not -enclosed in double quotes. This data type is not used for any -existing DHCP options. The domain name is stored just as if it were -a text option. -.PP -The -.B flag -data type specifies a boolean value. Booleans can be either true or -false (or on or off, if that makes more sense to you). -.PP -The -.B string -data type specifies either an NVT ASCII string -enclosed in double quotes, or a series of octets specified in -hexadecimal, separated by colons. For example: -.nf -.sp 1 - option dhcp-client-identifier "CLIENT-FOO"; -or - option dhcp-client-identifier 43:4c:49:45:54:2d:46:4f:4f; -.fi -.SH SETTING OPTION VALUES USING EXPRESSIONS -Sometimes it's helpful to be able to set the value of a DHCP option -based on some value that the client has sent. To do this, you can -use expression evaluation. The -.B dhcp-eval(5) -manual page describes how to write expressions. To assign the result -of an evaluation to an option, define the option as follows: -.nf -.sp 1 - \fBoption \fImy-option \fB= \fIexpression \fB;\fR -.fi -.PP -For example: -.nf -.sp 1 - option hostname = binary-to-ascii (16, 8, "-", - substring (hardware, 1, 6)); -.fi -.SH STANDARD DHCP OPTIONS -The documentation for the various options mentioned below is taken -from the latest IETF draft document on DHCP options. Options not -listed below may not yet be implemented, but it is possible to use -such options by defining them in the configuration file. Please see -the DEFINING NEW OPTIONS heading later in this document for more -information. -.PP -Some of the options documented here are automatically generated by -the DHCP server or by clients, and cannot be configured by the user. -The value of such an option can be used in the configuration file of -the receiving DHCP protocol agent (server or client), for example in -conditional expressions. However, the value of the option cannot be -used in the configuration file of the sending agent, because the value -is determined only \fIafter\fR the configuration file has been -processed. In the following documentation, such options will be shown -as "not user configurable" -.PP -The standard options are: -.PP -.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 -same MTU as the subnet of that network to which the client is -directly connected. A value of true indicates that all subnets share -the same MTU. A value of false means that the client should assume that -some subnets of the directly connected network may have smaller MTUs. -.RE -.PP -.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 -.B option \fBbootfile-name\fR \fItext\fR\fB;\fR -.RS 0.25i -.PP -This option is used to identify a bootstrap file. If supported by the -client, it should have the same effect as the \fBfilename\fR -declaration. BOOTP clients are unlikely to support this option. Some -DHCP clients will support it, and others actually require it. -.RE -.PP -.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 -.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 -.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 -.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 -.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 -.B option \fBdhcp-client-identifier\fR \fIstring\fR\fB;\fR -.RS 0.25i -.PP -This option can be used to specify a DHCP client identifier in a -host declaration, so that dhcpd can find the host record by matching -against the client identifier. -.PP -Please be aware that some DHCP clients, when configured with client -identifiers that are ASCII text, will prepend a zero to the ASCII -text. So you may need to write: -.nf - - option dhcp-client-identifier "\\0foo"; - -rather than: - - option dhcp-client-identifier "foo"; -.fi -.RE -.PP -.B option \fBdhcp-lease-time\fR \fIuint32\fR\fB;\fR -.RS 0.25i -.PP -This option is used in a client request (DHCPDISCOVER or DHCPREQUEST) -to allow the client to request a lease time for the IP address. In a -server reply (DHCPOFFER), a DHCP server uses this option to specify -the lease time it is willing to offer. -.PP -This option is not directly user configurable in the server; refer to the -\fImax-lease-time\fR and \fIdefault-lease-time\fR server options in -.B dhcpd.conf(5). -.RE -.PP -.B option \fBdhcp-max-message-size\fR \fIuint16\fR\fB;\fR -.RS 0.25i -.PP -This option, when sent by the client, specifies the maximum size of -any response that the server sends to the client. When specified on -the server, if the client did not send a dhcp-max-message-size option, -the size specified on the server is used. This works for BOOTP as -well as DHCP responses. -.RE -.PP -.B option \fBdhcp-message\fR \fItext\fR\fB;\fR -.RS 0.25i -.PP -This option is used by a DHCP server to provide an error message to a -DHCP client in a DHCPNAK message in the event of a failure. A client -may use this option in a DHCPDECLINE message to indicate why the -client declined the offered parameters. -.PP -This option is not user configurable. -.RE -.PP -.B option \fBdhcp-message-type\fR \fIuint8\fR\fB;\fR -.RS 0.25i -.PP -This option, sent by both client and server, specifies the type of DHCP -message contained in the DHCP packet. Possible values (taken directly from -RFC2132) are: -.PP -.nf - 1 DHCPDISCOVER - 2 DHCPOFFER - 3 DHCPREQUEST - 4 DHCPDECLINE - 5 DHCPACK - 6 DHCPNAK - 7 DHCPRELEASE - 8 DHCPINFORM -.fi -.PP -This option is not user configurable. -.PP -.RE -.B option \fBdhcp-option-overload\fR \fIuint8\fR\fB;\fR -.RS 0.25i -.PP -This option is used to indicate that the DHCP 'sname' or 'file' -fields are being overloaded by using them to carry DHCP options. A -DHCP server inserts this option if the returned parameters will -exceed the usual space allotted for options. -.PP -If this option is present, the client interprets the specified -additional fields after it concludes interpretation of the standard -option fields. -.PP -Legal values for this option are: -.PP -.nf - 1 the 'file' field is used to hold options - 2 the 'sname' field is used to hold options - 3 both fields are used to hold options -.fi -.PP -This option is not user configurable. -.PP -.RE -.PP -.B option \fBdhcp-parameter-request-list\fR \fIuint16\fR\fB;\fR -.RS 0.25i -.PP -This option, when sent by the client, specifies which options the -client wishes the server to return. Normally, in the ISC DHCP -client, this is done using the \fIrequest\fR statement. If this -option is not specified by the client, the DHCP server will normally -return every option that is valid in scope and that fits into the -reply. When this option is specified on the server, the server -returns the specified options. This can be used to force a client to -take options that it hasn't requested, and it can also be used to -tailor the response of the DHCP server for clients that may need a -more limited set of options than those the server would normally -return. -.RE -.PP -.B option \fBdhcp-rebinding-time\fR \fIuint32\fR\fB;\fR -.RS 0.25i -.PP -This option specifies the number of seconds from the time a client gets -an address until the client transitions to the REBINDING state. -.PP -This option is not user configurable. -.PP -.RE -.PP -.B option \fBdhcp-renewal-time\fR \fIuint32\fR\fB;\fR -.RS 0.25i -.PP -This option specifies the number of seconds from the time a client gets -an address until the client transitions to the RENEWING state. -.PP -This option is not user configurable. -.PP -.RE -.PP -.B option \fBdhcp-requested-address\fR \fIip-address\fR\fB;\fR -.RS 0.25i -.PP -This option is used by the client in a DHCPDISCOVER to -request that a particular IP address be assigned. -.PP -This option is not user configurable. -.PP -.RE -.PP -.B option \fBdhcp-server-identifier\fR \fIip-address\fR\fB;\fR -.RS 0.25i -.PP -This option is used in DHCPOFFER and DHCPREQUEST messages, and may -optionally be included in the DHCPACK and DHCPNAK messages. DHCP -servers include this option in the DHCPOFFER in order to allow the -client to distinguish between lease offers. DHCP clients use the -contents of the 'server identifier' field as the destination address -for any DHCP messages unicast to the DHCP server. DHCP clients also -indicate which of several lease offers is being accepted by including -this option in a DHCPREQUEST message. -.PP -The value of this option is the IP address of the server. -.PP -This option is not directly user configurable. See the -\fIserver-identifier\fR server option in -.B \fIdhcpd.conf(5). -.PP -.RE -.PP -.B option \fBdomain-name\fR \fItext\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 -.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 -.B option \fBextensions-path\fR \fItext\fR\fB;\fR -.RS 0.25i -.PP -This option specifies the name of a file containing additional options -to be interpreted according to the DHCP option format as specified in -RFC2132. -.RE -.PP -.B option \fBfinger-server\fR \fIip-address\fR [\fB,\fR -\fIip-address\fR... ]\fB;\fR -.RS 0.25i -.PP -The Finger server option specifies a list of Finger servers available -to the client. Servers should be listed in order of preference. -.RE -.PP -.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 -.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. This option is only honored by -.B dhclient-script(8) -if the hostname for the client machine is not set. -.RE -.PP -.B option \fBieee802-3-encapsulation\fR \fIflag\fR\fB;\fR -.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 false indicates that the client -should use RFC 894 encapsulation. A value of true means that the client -should use RFC 1042 encapsulation. -.RE -.PP -.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 -.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 -.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 -.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 false means disable IP -forwarding, and a value of true means enable IP forwarding. -.RE -.PP -.B option \fBirc-server\fR \fIip-address\fR [\fB,\fR -\fIip-address\fR... ]\fB;\fR -.RS 0.25i -.PP -The IRC server option specifies a list of IRC servers available -to the client. Servers should be listed in order of preference. -.RE -.PP -.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 -.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 -.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 false indicates that the -client should not respond. A value of true means that the client should -respond. -.RE -.PP -.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 legal value is -576. -.RE -.PP -.B option \fBmerit-dump\fR \fItext\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 -.B option \fBmobile-ip-home-agent\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... ]\fB;\fR -.RS 0.25i -.PP -This option specifies a list of IP addresses indicating mobile IP -home agents available to the client. Agents should be listed in -order of preference, although normally there will be only one such -agent. -.RE -.PP -.B option \fBnds-context\fR \fIstring\fR\fB;\fR -.RS 0.25i -.PP -The nds-context option specifies the name of the initial Netware -Directory Service for an NDS client. -.RE -.PP -.B option \fBnds-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... ]\fB;\fR -.RS 0.25i -.PP -The nds-servers option specifies a list of IP addresses of NDS servers. -.RE -.PP -.B option \fBnds-tree-name\fR \fIstring\fR\fB;\fR -.RS 0.25i -.PP -The nds-tree-name option specifies NDS tree name that the NDS client -should use. -.RE -.PP -.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 -.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. NetBIOS -Name Service is currently more commonly referred to as WINS. WINS -servers can be specified using the netbios-name-servers option. -.RE -.PP -.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. -.PP -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 \fBnetbios-scope\fR \fIstring\fR\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 -.B option \fBnis-domain\fR \fItext\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 -.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 -.B option \fBnisplus-domain\fR \fItext\fR\fB;\fR -.RS 0.25i -.PP -This option specifies the name of the client's NIS+ domain. The -domain is formatted as a character string consisting of characters -from the NVT ASCII character set. -.RE -.PP -.B option \fBnisplus-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 -.B option \fBnntp-server\fR \fIip-address\fR [\fB,\fR -\fIip-address\fR... ]\fB;\fR -.RS 0.25i -.PP -The NNTP server option specifies a list of NNTP servesr available -to the client. Servers should be listed in order of preference. -.RE -.PP -.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 false means disallow forwarding of such datagrams, and a value of true -means allow forwarding. -.RE -.PP -.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 -.B option \fBnwip-domain\fR \fIstring\fR\fB;\fR -.RS 0.25i -.PP -The name of the NetWare/IP domain that a NetWare/IP client should -use. -.RE -.PP -.B option \fBnwip-suboptions\fR \fIstring\fR\fB;\fR -.RS 0.25i -.PP -A sequence of suboptions for NetWare/IP clients - see RFC2242 for -details. Normally this option is set by specifying specific -NetWare/IP suboptions - see the NETWARE/IP SUBOPTIONS section for more -information. -.RE -.PP -.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 -.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 -.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 false indicates that the client -should not perform mask discovery. A value of true means that the -client should perform mask discovery. -.RE -.PP -.nf -.B option \fBpolicy-filter\fR \fIip-address ip-address\fR - [\fB,\fR \fIip-address ip-address\fR...]\fB;\fR -.RE -.fi -.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 -destination/mask pairs with which to filter incoming source routes. -.PP -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 -.B option \fBpop-server\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... ]\fB;\fR -.RS 0.25i -.PP -The POP3 server option specifies a list of POP3 servers available -to the client. Servers should be listed in order of preference. -.RE -.PP -.B option \fBresource-location-servers\fR \fIip-address\fR - [\fB, \fR\fIip-address\fR...]\fB;\fR -.fi -.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 -.B option \fBroot-path\fR \fItext\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 -.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 false indicates that the client should not perform -router discovery. A value of true means that the client should perform -router discovery. -.RE -.PP -.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 -.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 -.B option slp-directory-agent \fIboolean ip-address -[\fB,\fR \fIip-address\fR... ]\fB;\fR -.RS 0.25i -.PP -This option specifies two things: the IP addresses of one or more -Service Location Protocol Directory Agents, and whether the use of -these addresses is mandatory. If the initial boolean value is true, -the SLP agent should just use the IP addresses given. If the value -is false, the SLP agent may additionally do active or passive -multicast discovery of SLP agents (see RFC2165 for details). -.PP -Please note that in this option and the slp-service-scope option, the -term "SLP Agent" is being used to refer to a Service Location Protocol -agent running on a machine that is being configured using the DHCP -protocol. -.PP -Also, please be aware that some companies may refer to SLP as NDS. -If you have an NDS directory agent whose address you need to -configure, the slp-directory-agent option should work. -.RE -.PP -.B option slp-service-scope \fIboolean text\fR\fB;\fR -.RS 0.25i -.PP -The Service Location Protocol Service Scope Option specifies two -things: a list of service scopes for SLP, and whether the use of this -list is mandatory. If the initial boolean value is true, the SLP -agent should only use the list of scopes provided in this option; -otherwise, it may use its own static configuration in preference to -the list provided in this option. -.PP -The text string should be a comma-separated list of scopes that the -SLP agent should use. It may be omitted, in which case the SLP Agent -will use the aggregated list of scopes of all directory agents known -to the SLP agent. -.RE -.PP -.B option \fBsmtp-server\fR \fIip-address\fR [\fB,\fR -\fIip-address\fR... ]\fB;\fR -.RS 0.25i -.PP -The SMTP server option specifies a list of SMTP servers available to -the client. Servers should be listed in order of preference. -.RE -.PP -.nf -.B option \fBstatic-routes\fR \fIip-address ip-address\fR - [\fB,\fR \fIip-address ip-address\fR...]\fB;\fR -.fi -.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 -destination are specified, they are listed in descending order of -priority. -.PP -The routes consist of a list of IP address pairs. The first address -is the destination address, and the second address is the router for -the destination. -.PP -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. Also, please note that this option is not intended for -classless IP routing - it does not include a subnet mask. Since -classless IP routing is now the most widely deployed routing standard, -this option is virtually useless, and is not implemented by any of the -popular DHCP clients, for example the Microsoft DHCP client. -.RE -.PP -.nf -.B option \fBstreettalk-directory-assistance-server\fR \fIip-address\fR - [\fB,\fR \fIip-address\fR...]\fB;\fR -.fi -.RS 0.25i -.PP -The StreetTalk Directory Assistance (STDA) server option specifies a -list of STDA servers available to the client. Servers should be -listed in order of preference. -.RE -.PP -.B option \fBstreettalk-server\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... ]\fB;\fR -.RS 0.25i -.PP -The StreetTalk server option specifies a list of StreetTalk servers -available to the client. Servers should be listed in order of -preference. -.RE -.PP -.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 -last resort dhcpd will use the subnet mask from the subnet declaration -for the network on which an address is being assigned. However, -.I any -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 -.B option \fBsubnet-selection\fR \fIstring\fR\fB;\fR -.RS 0.25i -.PP -Sent by the client if an address is required in a subnet other than the one -that would normally be selected (based on the relaying address of the -connected subnet the request is obtained from). See RFC3011. Note that the -option number used by this server is 118; this has not always been the -defined number, and some clients may use a different value. Use of this -option should be regarded as slightly experimental! -.RE -.PP -This option is not user configurable in the server. -.PP -.PP -.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 -.B option \fBtcp-keepalive-garbage\fR \fIflag\fR\fB;\fR -.RS 0.25i -.PP -This option specifies whether or not the client should send TCP -keepalive messages with an octet of garbage for compatibility with -older implementations. A value of false indicates that a garbage octet -should not be sent. A value of true indicates that a garbage octet -should be sent. -.RE -.PP -.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 -.B option \fBtftp-server-name\fR \fItext\fR\fB;\fR -.RS 0.25i -.PP -This option is used to identify a TFTP server and, if supported by the -client, should have the same effect as the \fBserver-name\fR -declaration. BOOTP clients are unlikely to support this option. -Some DHCP clients will support it, and others actually require it. -.RE -.PP -.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 -.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 -.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 false indicates that the client should not attempt to use trailers. A -value of true means that the client should attempt to use trailers. -.RE -.PP -.B option \fBuap-servers\fR \fItext\fR\fB;\fR -.RS 0.25i -.PP -This option specifies a list of URLs, each pointing to a user -authentication service that is capable of processing authentication -requests encapsulated in the User Authentication Protocol (UAP). UAP -servers can accept either HTTP 1.1 or SSLv3 connections. If the list -includes a URL that does not contain a port component, the normal -default port is assumed (i.e., port 80 for http and port 443 for -https). If the list includes a URL that does not contain a path -component, the path /uap is assumed. If more than one URL is -specified in this list, the URLs are separated by spaces. -.RE -.PP -.B option \fBuser-class\fR \fIstring\fR\fB;\fR -.RS 0.25i -.PP -This option is used by some DHCP clients as a way for users to -specify identifying information to the client. This can be used in a -similar way to the vendor-class-identifier option, but the value of -the option is specified by the user, not the vendor. Most recent -DHCP clients have a way in the user interface to specify the value for -this identifier, usually as a text string. -.PP -.B option \fBvendor-class-identifier\fR \fIstring\fR\fB;\fR -.RS 0.25i -.PP -This option is used by some DHCP clients to identify the vendor -type and possibly the configuration of a DHCP client. The information -is a string of bytes whose contents are specific to the vendor and are -not specified in a standard. To see what vendor class identifier -clients are sending, you can write the following in your DHCP server -configuration file: -.nf -.PP -set vendor-string = option vendor-class-identifier; -.fi -.PP -This will result in all entries in the DHCP server lease database file -for clients that sent vendor-class-identifier options having a set -statement that looks something like this: -.nf -.PP -set vendor-string = "SUNW.Ultra-5_10"; -.fi -.PP -The vendor-class-identifier option is normally used by the DHCP server -to determine the options that are returned in the -.B vendor-encapsulated-options -option. Please see the VENDOR ENCAPSULATED OPTIONS section later in this -manual page for further information. -.RE -.PP -.B option \fBvendor-encapsulated-options\fR \fIstring\fR\fB;\fR -.RS 0.25i -.PP -The \fBvendor-encapsulated-options\fR option can contain either a -single vendor-specific value or one or more vendor-specific -suboptions. This option is not normally specified in the DHCP server -configuration file - instead, a vendor class is defined for each -vendor, vendor class suboptions are defined, values for those -suboptions are defined, and the DHCP server makes up a response on -that basis. -.PP -Some default behaviours for well-known DHCP client vendors (currently, -the Microsoft Windows 2000 DHCP client) are configured automatically, -but otherwise this must be configured manually - see the VENDOR -ENCAPSULATED OPTIONS section later in this manual page for details. -.RE -.PP -.B option \fBwww-server\fR \fIip-address\fR [\fB,\fR -\fIip-address\fR... ]\fB;\fR -.RS 0.25i -.PP -The WWW server option specifies a list of WWW servers available -to the client. Servers should be listed in order of preference. -.RE -.PP -.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 -.SH RELAY AGENT INFORMATION OPTION -An IETF draft, draft-ietf-dhc-agent-options-11.txt, defines a series -of encapsulated options that a relay agent can add to a DHCP packet -when relaying it to the DHCP server. The server can then make -address allocation decisions (or whatever other decisions it wants) -based on these options. The server also returns these options in any -replies it sends through the relay agent, so that the relay agent can -use the information in these options for delivery or accounting -purposes. -.PP -The current draft defines two options. To reference -these options in the dhcp server, specify the option space name, -"agent", followed by a period, followed by the option name. It is -not normally useful to define values for these options in the server, -although it is permissible. These options are not supported in the -client. -.PP -.B option \fBagent.circuit-id\fR \fIstring\fR\fB;\fR -.RS 0.25i -.PP -The circuit-id suboption encodes an agent-local identifier of the -circuit from which a DHCP client-to-server packet was received. It is -intended for use by agents in relaying DHCP responses back to the -proper circuit. The format of this option is currently defined to be -vendor-dependent, and will probably remain that way, although the -current draft allows for for the possibility of standardizing the -format in the future. -.RE -.PP -.B option \fBagent.remote-id\fR \fIstring\fR\fB;\fR -.RS 0.25i -.PP -The remote-id suboption encodes information about the remote host end -of a circuit. Examples of what it might contain include caller ID -information, username information, remote ATM address, cable modem ID, -and similar things. In principal, the meaning is not well-specified, -and it should generally be assumed to be an opaque object that is -administratively guaranteed to be unique to a particular remote end of -a circuit. -.RE -.SH THE CLIENT FQDN SUBOPTIONS -The Client FQDN option, currently defined in the Internet Draft -draft-ietf-dhc-fqdn-option-00.txt is not a standard yet, but is in -sufficiently wide use already that we have implemented it. Due to -the complexity of the option format, we have implemented it as a -suboption space rather than a single option. In general this -option should not be configured by the user - instead it should be -used as part of an automatic DNS update system. -.PP -.B option fqdn.no-client-update \fIflag\fB; -.RS 0.25i -.PP -When the client sends this, if it is true, it means the client will not -attempt to update its A record. When sent by the server to the client, -it means that the client \fIshould not\fR update its own A record. -.RE -.PP -.B option fqdn.server-update \fIflag\fB; -.RS 0.25i -.PP -When the client sends this to the server, it is requesting that the server -update its A record. When sent by the server, it means that the server -has updated (or is about to update) the client's A record. -.RE -.PP -.B option fqdn.encoded \fIflag\fB; -.RS 0.25i -.PP -If true, this indicates that the domain name included in the option is -encoded in DNS wire format, rather than as plain ASCII text. The client -normally sets this to false if it doesn't support DNS wire format in the -FQDN option. The server should always send back the same value that the -client sent. When this value is set on the configuration side, it controls -the format in which the \fIfqdn.fqdn\fR suboption is encoded. -.RE -.PP -.B option fqdn.rcode1 \fIflag\fB; -.PP -.B option fqdn.rcode2 \fIflag\fB; -.RS 0.25i -.PP -These options specify the result of the updates of the A and PTR records, -respectively, and are only sent by the DHCP server to the DHCP client. -The values of these fields are those defined in the DNS protocol specification. -.RE -.PP -.B option fqdn.fqdn \fItext\fB; -.RS 0.25i -.PP -Specifies the domain name that the client wishes to use. This can be a -fully-qualified domain name, or a single label. If there is no trailing -'.' character in the name, it is not fully-qualified, and the server will -generally update that name in some locally-defined domain. -.RE -.PP -.B option fqdn.hostname \fI--never set--\fB; -.RS 0.25i -.PP -This option should never be set, but it can be read back using the \fBoption\fR -and \fBconfig-option\fR operators in an expression, in which case it returns -the first label in the \fBfqdn.fqdn\fR suboption - for example, if -the value of \fBfqdn.fqdn\fR is "foo.example.com.", then \fBfqdn.hostname\fR -will be "foo". -.RE -.PP -.B option fqdn.domainname \fI--never set--\fB; -.RS 0.25i -.PP -This option should never be set, but it can be read back using the \fBoption\fR -and \fBconfig-option\fR operators in an expression, in which case it returns -all labels after the first label in the \fBfqdn.fqdn\fR suboption - for -example, if the value of \fBfqdn.fqdn\fR is "foo.example.com.", -then \fBfqdn.hostname\fR will be "example.com.". If this suboption value -is not set, it means that an unqualified name was sent in the fqdn option, -or that no fqdn option was sent at all. -.RE -.PP -If you wish to use any of these suboptions, we strongly recommend that you -refer to the Client FQDN option draft (or standard, when it becomes a -standard) - the documentation here is sketchy and incomplete in comparison, -and is just intended for reference by people who already understand the -Client FQDN option specification. -.SH THE NETWARE/IP SUBOPTIONS -RFC2242 defines a set of encapsulated options for Novell NetWare/IP -clients. To use these options in the dhcp server, specify the option -space name, "nwip", followed by a period, followed by the option name. -The following options can be specified: -.PP -.B option \fBnwip.nsq-broadcast\fR \fIflag\fR\fB;\fR -.RS 0.25i -.PP -If true, the client should use the NetWare Nearest Server Query to -locate a NetWare/IP server. The behaviour of the Novell client if -this suboption is false, or is not present, is not specified. -.PP -.RE -.B option \fBnwip.preferred-dss\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... ]\fR\fB;\fR -.RS 0.25i -.PP -This suboption specifies a list of up to five IP addresses, each of -which should be the IP address of a NetWare Domain SAP/RIP server -(DSS). -.RE -.PP -.B option \fBnwip.nearest-nwip-server\fR \fI\fIip-address\fR - [\fB,\fR \fIip-address\fR...]\fR\fB;\fR -.RS 0.25i -.PP -This suboption specifies a list of up to five IP addresses, each of -which should be the IP address of a Nearest NetWare IP server. -.RE -.PP -.B option \fBnwip.autoretries\fR \fIuint8\fR\fB;\fR -.RS 0.25i -.PP -Specifies the number of times that a NetWare/IP client should attempt -to communicate with a given DSS server at startup. -.RE -.PP -.B option \fBnwip.autoretry-secs\fR \fIuint8\fR\fB;\fR -.RS 0.25i -.PP -Specifies the number of seconds that a Netware/IP client should wait -between retries when attempting to establish communications with a DSS -server at startup. -.RE -.PP -.B option \fBnwip.nwip-1-1\fR \fIuint8\fR\fB;\fR -.RS 0.25i -.PP -If true, the NetWare/IP client should support NetWare/IP version 1.1 -compatibility. This is only needed if the client will be contacting -Netware/IP version 1.1 servers. -.RE -.PP -.B option \fBnwip.primary-dss\fR \fIip-address\fR\fB;\fR -.RS 0.25i -.PP -Specifies the IP address of the Primary Domain SAP/RIP Service server -(DSS) for this NetWare/IP domain. The NetWare/IP administration -utility uses this value as Primary DSS server when configuring a -secondary DSS server. -.RE -.SH DEFINING NEW OPTIONS -The Internet Systems Consortium DHCP client and server provide the -capability to define new options. Each DHCP option has a name, a -code, and a structure. The name is used by you to refer to the -option. The code is a number, used by the DHCP server and client to -refer to an option. The structure describes what the contents of an -option looks like. -.PP -To define a new option, you need to choose a name for it that is not -in use for some other option - for example, you can't use "host-name" -because the DHCP protocol already defines a host-name option, which is -documented earlier in this manual page. If an option name doesn't -appear in this manual page, you can use it, but it's probably a good -idea to put some kind of unique string at the beginning so you can be -sure that future options don't take your name. For example, you -might define an option, "local-host-name", feeling some confidence -that no official DHCP option name will ever start with "local". -.PP -Once you have chosen a name, you must choose a code. For site-local -options, all codes between 128 and 254 are reserved for DHCP options, -so you can pick any one of these. In practice, some vendors have -interpreted the protocol rather loosely and have used option code -values greater than 128 themselves. There's no real way to avoid -this problem, but it's not likely to cause too much trouble in -practice. -.PP -The structure of an option is simply the format in which the option -data appears. The ISC DHCP server currently supports a few simple -types, like integers, booleans, strings and IP addresses, and it also -supports the ability to define arrays of single types or arrays of -fixed sequences of types. -.PP -New options are declared as follows: -.PP -.B option -.I new-name -.B code -.I new-code -.B = -.I definition -.B ; -.PP -The values of -.I new-name -and -.I new-code -should be the name you have chosen for the new option and the code you -have chosen. The -.I definition -should be the definition of the structure of the option. -.PP -The following simple option type definitions are supported: -.PP -.B BOOLEAN -.PP -.B option -.I new-name -.B code -.I new-code -.B = -.B boolean -.B ; -.PP -An option of type boolean is a flag with a value of either on or off -(or true or false). So an example use of the boolean type would be: -.nf - -option use-zephyr code 180 = boolean; -option use-zephyr on; - -.fi -.B INTEGER -.PP -.B option -.I new-name -.B code -.I new-code -.B = -.I sign -.B integer -.I width -.B ; -.PP -The \fIsign\fR token should either be blank, \fIunsigned\fR -or \fIsigned\fR. The width can be either 8, 16 or 32, and refers to -the number of bits in the integer. So for example, the following two -lines show a definition of the sql-connection-max option and its use: -.nf - -option sql-connection-max code 192 = unsigned integer 16; -option sql-connection-max 1536; - -.fi -.B IP-ADDRESS -.PP -.B option -.I new-name -.B code -.I new-code -.B = -.B ip-address -.B ; -.PP -An option whose structure is an IP address can be expressed either as -a domain name or as a dotted quad. So the following is an example use -of the ip-address type: -.nf - -option sql-server-address code 193 = ip-address; -option sql-server-address sql.example.com; - -.fi -.PP -.B TEXT -.PP -.B option -.I new-name -.B code -.I new-code -.B = -.B text -.B ; -.PP -An option whose type is text will encode an ASCII text string. For -example: -.nf - -option sql-default-connection-name code 194 = text; -option sql-default-connection-name "PRODZA"; - -.fi -.PP -.B DATA STRING -.PP -.B option -.I new-name -.B code -.I new-code -.B = -.B string -.B ; -.PP -An option whose type is a data string is essentially just a collection -of bytes, and can be specified either as quoted text, like the text -type, or as a list of hexadecimal contents separated by colons whose -values must be between 0 and FF. For example: -.nf - -option sql-identification-token code 195 = string; -option sql-identification-token 17:23:19:a6:42:ea:99:7c:22; - -.fi -.PP -.B ENCAPSULATION -.PP -.B option -.I new-name -.B code -.I new-code -.B = -.B encapsulate -.I identifier -.B ; -.PP -An option whose type is \fBencapsulate\fR will encapsulate the -contents of the option space specified in \fIidentifier\fR. Examples -of encapsulated options in the DHCP protocol as it currently exists -include the vendor-encapsulated-options option, the netware-suboptions -option and the relay-agent-information option. -.nf - -option space local; -option local.demo code 1 = text; -option local-encapsulation code 197 = encapsulate local; -option local.demo "demo"; - -.fi -.PP -.B ARRAYS -.PP -Options can contain arrays of any of the above types except for the -text and data string types, which aren't currently supported in -arrays. An example of an array definition is as follows: -.nf - -option kerberos-servers code 200 = array of ip-address; -option kerberos-servers 10.20.10.1, 10.20.11.1; - -.fi -.B RECORDS -.PP -Options can also contain data structures consisting of a sequence of -data types, which is sometimes called a record type. For example: -.nf - -option contrived-001 code 201 = { boolean, integer 32, text }; -option contrived-001 on 1772 "contrivance"; - -.fi -It's also possible to have options that are arrays of records, for -example: -.nf - -option new-static-routes code 201 = array of { - ip-address, ip-address, ip-address, integer 8 }; -option static-routes - 10.0.0.0 255.255.255.0 net-0-rtr.example.com 1, - 10.0.1.0 255.255.255.0 net-1-rtr.example.com 1, - 10.2.0.0 255.255.224.0 net-2-0-rtr.example.com 3; - -.fi -.SH VENDOR ENCAPSULATED OPTIONS -The DHCP protocol defines the \fB vendor-encapsulated-options\fR -option, which allows vendors to define their own options that will be -sent encapsulated in a standard DHCP option. The format of the -.B vendor-encapsulated-options -option is either a series of bytes whose format is not specified, or -a sequence of options, each of which consists of a single-byte -vendor-specific option code, followed by a single-byte length, -followed by as many bytes of data as are specified in the length (the -length does not include itself or the option code). -.PP -The value of this option can be set in one of two ways. The first -way is to simply specify the data directly, using a text string or a -colon-separated list of hexadecimal values. For example: -.PP -.nf -option vendor-encapsulated-options - 2:4:AC:11:41:1: - 3:12:73:75:6e:64:68:63:70:2d:73:65:72:76:65:72:31:37:2d:31: - 4:12:2f:65:78:70:6f:72:74:2f:72:6f:6f:74:2f:69:38:36:70:63; -.fi -.PP -The second way of setting the value of this option is to have the DHCP -server generate a vendor-specific option buffer. To do this, you -must do four things: define an option space, define some options in -that option space, provide values for them, and specify that that -option space should be used to generate the -.B vendor-encapsulated-options -option. -.PP -To define a new option space in which vendor options can be stored, -use the \fRoption space\fP statement: -.PP -.B option -.B space -.I name -.B ; -.PP -The name can then be used in option definitions, as described earlier in -this document. For example: -.nf - -option space SUNW; -option SUNW.server-address code 2 = ip-address; -option SUNW.server-name code 3 = text; -option SUNW.root-path code 4 = text; - -.fi -Once you have defined an option space and the format of some options, -you can set up scopes that define values for those options, and you -can say when to use them. For example, suppose you want to handle -two different classes of clients. Using the option space definition -shown in the previous example, you can send different option values to -different clients based on the vendor-class-identifier option that the -clients send, as follows: -.PP -.nf -class "vendor-classes" { - match option vendor-class-identifier; -} - -option SUNW.server-address 172.17.65.1; -option SUNW.server-name "sundhcp-server17-1"; - -subclass "vendor-classes" "SUNW.Ultra-5_10" { - vendor-option-space SUNW; - option SUNW.root-path "/export/root/sparc"; -} - -subclass "vendor-classes" "SUNW.i86pc" { - vendor-option-space SUNW; - option SUNW.root-path "/export/root/i86pc"; -} -.fi -.PP -As you can see in the preceding example, regular scoping rules apply, -so you can define values that are global in the global scope, and only -define values that are specific to a particular class in the local -scope. The \fBvendor-option-space\fR declaration tells the DHCP -server to use options in the SUNW option space to construct the -.B vendor-encapsulated-options -option. -.SH SEE ALSO -dhcpd.conf(5), dhcpd.leases(5), dhclient.conf(5), dhcp-eval(5), dhcpd(8), -dhclient(8), RFC2132, RFC2131, draft-ietf-dhc-agent-options-??.txt. -.SH AUTHOR -The Internet Systems Consortium DHCP Distribution was written by Ted -Lemon under a contract with Vixie Labs. Funding for -this project was provided through Internet Systems Consortium. -Information about Internet Systems Consortium can be found at -.B http://www.isc.org. diff --git a/contrib/dhcp-3.0/common/discover.c b/contrib/dhcp-3.0/common/discover.c deleted file mode 100644 index c2f9d47..0000000 --- a/contrib/dhcp-3.0/common/discover.c +++ /dev/null @@ -1,1138 +0,0 @@ -/* dispatch.c - - Network input dispatcher... */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1995-2003 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Internet Systems Consortium, Inc. - * 950 Charter Street - * Redwood City, CA 94063 - * - * http://www.isc.org/ - * - * This software has been written for Internet Systems Consortium - * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. - * To learn more about Internet Systems Consortium, see - * ``http://www.isc.org/''. To learn more about Vixie Enterprises, - * see ``http://www.vix.com''. To learn more about Nominum, Inc., see - * ``http://www.nominum.com''. - */ - -#ifndef lint -static char copyright[] = -"$Id: discover.c,v 1.42.2.15 2004/06/10 17:59:16 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" -#include - -struct interface_info *interfaces, *dummy_interfaces, *fallback_interface; -int interfaces_invalidated; -int quiet_interface_discovery; -u_int16_t local_port; -u_int16_t remote_port; -int (*dhcp_interface_setup_hook) (struct interface_info *, struct iaddr *); -int (*dhcp_interface_discovery_hook) (struct interface_info *); -isc_result_t (*dhcp_interface_startup_hook) (struct interface_info *); -int (*dhcp_interface_shutdown_hook) (struct interface_info *); - -struct in_addr limited_broadcast; -struct in_addr local_address; - -void (*bootp_packet_handler) PROTO ((struct interface_info *, - struct dhcp_packet *, unsigned, - unsigned int, - struct iaddr, struct hardware *)); - -omapi_object_type_t *dhcp_type_interface; -#if defined (TRACING) -trace_type_t *interface_trace; -trace_type_t *inpacket_trace; -trace_type_t *outpacket_trace; -#endif -struct interface_info **interface_vector; -int interface_count; -int interface_max; - -OMAPI_OBJECT_ALLOC (interface, struct interface_info, dhcp_type_interface) - -isc_result_t interface_setup () -{ - isc_result_t status; - status = omapi_object_type_register (&dhcp_type_interface, - "interface", - dhcp_interface_set_value, - dhcp_interface_get_value, - dhcp_interface_destroy, - dhcp_interface_signal_handler, - dhcp_interface_stuff_values, - dhcp_interface_lookup, - dhcp_interface_create, - dhcp_interface_remove, - 0, 0, 0, - sizeof (struct interface_info), - interface_initialize, RC_MISC); - if (status != ISC_R_SUCCESS) - log_fatal ("Can't register interface object type: %s", - isc_result_totext (status)); - - return status; -} - -#if defined (TRACING) -void interface_trace_setup () -{ - interface_trace = trace_type_register ("interface", (void *)0, - trace_interface_input, - trace_interface_stop, MDL); - inpacket_trace = trace_type_register ("inpacket", (void *)0, - trace_inpacket_input, - trace_inpacket_stop, MDL); - outpacket_trace = trace_type_register ("outpacket", (void *)0, - trace_outpacket_input, - trace_outpacket_stop, MDL); -} -#endif - -isc_result_t interface_initialize (omapi_object_t *ipo, - const char *file, int line) -{ - struct interface_info *ip = (struct interface_info *)ipo; - ip -> rfdesc = ip -> wfdesc = -1; - return ISC_R_SUCCESS; -} - -/* Use the SIOCGIFCONF ioctl to get a list of all the attached interfaces. - For each interface that's of type INET and not the loopback interface, - register that interface with the network I/O software, figure out what - subnet it's on, and add it to the list of interfaces. */ - -void discover_interfaces (state) - int state; -{ - struct interface_info *tmp, *ip; - struct interface_info *last, *next; - char buf [2048]; - struct ifconf ic; - struct ifreq ifr; - int i; - int sock; - int address_count = 0; - struct subnet *subnet; - struct shared_network *share; - struct sockaddr_in foo; - int ir; - struct ifreq *tif; -#ifdef ALIAS_NAMES_PERMUTED - char *s; -#endif - isc_result_t status; - static int setup_fallback = 0; - int wifcount = 0; - - /* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */ - if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) - log_fatal ("Can't create addrlist socket"); - - /* Get the interface configuration information... */ - -#ifdef SIOCGIFCONF_ZERO_PROBE - /* linux will only tell us how long a buffer it wants if we give it - * a null buffer first. So, do a dry run to figure out the length. - * - * XXX this code is duplicated from below because trying to fold - * the logic into the if statement and goto resulted in excesssive - * obfuscation. The intent is that unless you run Linux you shouldn't - * have to deal with this. */ - - ic.ifc_len = 0; - ic.ifc_ifcu.ifcu_buf = (caddr_t)NULL; -#else - /* otherwise, we just feed it a starting size, and it'll tell us if - * it needs more */ - - ic.ifc_len = sizeof buf; - ic.ifc_ifcu.ifcu_buf = (caddr_t)buf; -#endif - - gifconf_again: - i = ioctl(sock, SIOCGIFCONF, &ic); - - if (i < 0) - log_fatal ("ioctl: SIOCGIFCONF: %m"); - -#ifdef SIOCGIFCONF_ZERO_PROBE - /* Workaround for SIOCGIFCONF bug on some Linux versions. */ - if (ic.ifc_ifcu.ifcu_buf == 0 && ic.ifc_len == 0) { - ic.ifc_len = sizeof buf; - ic.ifc_ifcu.ifcu_buf = (caddr_t)buf; - goto gifconf_again; - } -#endif - - /* If the SIOCGIFCONF resulted in more data than would fit in - a buffer, allocate a bigger buffer. */ - if ((ic.ifc_ifcu.ifcu_buf == buf -#ifdef SIOCGIFCONF_ZERO_PROBE - || ic.ifc_ifcu.ifcu_buf == 0 -#endif - ) && ic.ifc_len > sizeof buf) { - ic.ifc_ifcu.ifcu_buf = dmalloc ((size_t)ic.ifc_len, MDL); - if (!ic.ifc_ifcu.ifcu_buf) - log_fatal ("Can't allocate SIOCGIFCONF buffer."); - goto gifconf_again; -#ifdef SIOCGIFCONF_ZERO_PROBE - } else if (ic.ifc_ifcu.ifcu_buf == 0) { - ic.ifc_ifcu.ifcu_buf = (caddr_t)buf; - ic.ifc_len = sizeof buf; - goto gifconf_again; -#endif - } - - - /* If we already have a list of interfaces, and we're running as - a DHCP server, the interfaces were requested. */ - if (interfaces && (state == DISCOVER_SERVER || - state == DISCOVER_RELAY || - state == DISCOVER_REQUESTED)) - ir = 0; - else if (state == DISCOVER_UNCONFIGURED) - ir = INTERFACE_REQUESTED | INTERFACE_AUTOMATIC; - else - ir = INTERFACE_REQUESTED; - - /* 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 - if (ifp -> ifr_addr.sa_len > sizeof (struct sockaddr)) - i += (sizeof ifp -> ifr_name) + ifp -> ifr_addr.sa_len; - else -#endif - i += sizeof *ifp; - -#ifdef ALIAS_NAMES_PERMUTED - if ((s = strrchr (ifp -> ifr_name, ':'))) { - *s = 0; - } -#endif - -#ifdef SKIP_DUMMY_INTERFACES - if (!strncmp (ifp -> ifr_name, "dummy", 5)) - continue; -#endif - - - /* See if this is the sort of interface we want to - deal with. */ - strcpy (ifr.ifr_name, ifp -> ifr_name); - if (ioctl (sock, SIOCGIFFLAGS, &ifr) < 0) - log_fatal ("Can't get interface flags for %s: %m", - ifr.ifr_name); - - /* See if we've seen an interface that matches this one. */ - for (tmp = interfaces; tmp; tmp = tmp -> next) - if (!strcmp (tmp -> name, ifp -> ifr_name)) - break; - - /* Skip non broadcast interfaces (plus loopback and - point-to-point in case an OS incorrectly marks them - as broadcast). Also skip down interfaces unless we're - trying to get a list of configurable interfaces. */ - if (((!(ifr.ifr_flags & IFF_BROADCAST) || - ifr.ifr_flags & IFF_LOOPBACK || - ifr.ifr_flags & IFF_POINTOPOINT) && !tmp) || - (!(ifr.ifr_flags & IFF_UP) && - state != DISCOVER_UNCONFIGURED)) - continue; - - /* If there isn't already an interface by this name, - allocate one. */ - if (!tmp) { - tmp = (struct interface_info *)0; - status = interface_allocate (&tmp, MDL); - if (status != ISC_R_SUCCESS) - log_fatal ("Error allocating interface %s: %s", - ifp -> ifr_name, - isc_result_totext (status)); - strcpy (tmp -> name, ifp -> ifr_name); - interface_snorf (tmp, ir); - interface_dereference (&tmp, MDL); - tmp = interfaces; /* XXX */ - } - - if (dhcp_interface_discovery_hook) - (*dhcp_interface_discovery_hook) (tmp); - - /* If we have the capability, extract link information - and record it in a linked list. */ -#ifdef HAVE_AF_LINK - if (ifp -> ifr_addr.sa_family == AF_LINK) { - struct sockaddr_dl *foo = ((struct sockaddr_dl *) - (&ifp -> ifr_addr)); -#if defined (HAVE_SIN_LEN) - tmp -> hw_address.hlen = foo -> sdl_alen; -#else - tmp -> hw_address.hlen = 6; /* XXX!!! */ -#endif - tmp -> hw_address.hbuf [0] = HTYPE_ETHER; /* XXX */ - memcpy (&tmp -> hw_address.hbuf [1], - LLADDR (foo), tmp -> hw_address.hlen); - tmp -> hw_address.hlen++; /* for type. */ - } else -#endif /* AF_LINK */ - - if (ifp -> ifr_addr.sa_family == AF_INET) { - struct iaddr addr; - - /* Get a pointer to the address... */ - memcpy (&foo, &ifp -> ifr_addr, - sizeof ifp -> ifr_addr); - - /* We don't want the loopback interface. */ - if (foo.sin_addr.s_addr == htonl (INADDR_LOOPBACK) && - ((tmp -> flags & INTERFACE_AUTOMATIC) && - state == DISCOVER_SERVER)) - continue; - - - /* If this is the first real IP address we've - found, keep a pointer to ifreq structure in - which we found it. */ - if (!tmp -> ifp) { -#ifdef HAVE_SA_LEN - unsigned len = ((sizeof ifp -> ifr_name) + - ifp -> ifr_addr.sa_len); -#else - unsigned len = sizeof *ifp; -#endif - tif = (struct ifreq *)dmalloc (len, MDL); - if (!tif) - log_fatal ("no space for ifp."); - memcpy (tif, ifp, len); - tmp -> ifp = tif; - tmp -> primary_address = foo.sin_addr; - } - - /* Grab the address... */ - addr.len = 4; - memcpy (addr.iabuf, &foo.sin_addr.s_addr, - addr.len); - if (dhcp_interface_setup_hook) - (*dhcp_interface_setup_hook) (tmp, &addr); - } - } - - /* If we allocated a buffer, free it. */ - if (ic.ifc_ifcu.ifcu_buf != buf) - dfree (ic.ifc_ifcu.ifcu_buf, MDL); - -#if defined (LINUX_SLASHPROC_DISCOVERY) - /* On Linux, interfaces that don't have IP addresses don't - show up in the SIOCGIFCONF syscall. 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. */ - - if (state == DISCOVER_UNCONFIGURED) { - FILE *proc_dev; - char buffer [256]; - int skip = 2; - - proc_dev = fopen (PROCDEV_DEVICE, "r"); - if (!proc_dev) - log_fatal ("%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, nothing more to do.. */ - if (tmp) - continue; - - /* Otherwise, allocate one. */ - tmp = (struct interface_info *)0; - status = interface_allocate (&tmp, MDL); - if (status != ISC_R_SUCCESS) - log_fatal ("Can't allocate interface %s: %s", - name, isc_result_totext (status)); - tmp -> flags = ir; - strncpy (tmp -> name, name, IFNAMSIZ); - if (interfaces) { - interface_reference (&tmp -> next, - interfaces, MDL); - interface_dereference (&interfaces, MDL); - } - interface_reference (&interfaces, tmp, MDL); - interface_dereference (&tmp, MDL); - tmp = interfaces; - - if (dhcp_interface_discovery_hook) - (*dhcp_interface_discovery_hook) (tmp); - - } - fclose (proc_dev); - } -#endif - - /* Now cycle through all the interfaces we found, looking for - hardware addresses. */ -#if defined (HAVE_SIOCGIFHWADDR) && !defined (HAVE_AF_LINK) - for (tmp = interfaces; tmp; tmp = tmp -> next) { - struct ifreq ifr; - struct sockaddr sa; - int b, sk; - - if (!tmp -> ifp) { - /* Make up an ifreq structure. */ - tif = (struct ifreq *)dmalloc (sizeof (struct ifreq), - MDL); - if (!tif) - log_fatal ("no space to remember ifp."); - memset (tif, 0, sizeof (struct ifreq)); - strcpy (tif -> ifr_name, tmp -> name); - tmp -> ifp = tif; - } - - /* 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 HAVE_ARPHRD_TUNNEL - case ARPHRD_TUNNEL: - /* ignore tunnel interfaces. */ -#endif -#ifdef HAVE_ARPHRD_ROSE - case ARPHRD_ROSE: -#endif -#ifdef HAVE_ARPHRD_LOOPBACK - case ARPHRD_LOOPBACK: - /* ignore loopback interface */ - break; -#endif - - case ARPHRD_ETHER: - tmp -> hw_address.hlen = 7; - tmp -> hw_address.hbuf [0] = ARPHRD_ETHER; - memcpy (&tmp -> hw_address.hbuf [1], sa.sa_data, 6); - break; - -#ifndef HAVE_ARPHRD_IEEE802 -# define ARPHRD_IEEE802 HTYPE_IEEE802 -#endif -#if defined (HAVE_ARPHRD_IEEE802_TR) - case ARPHRD_IEEE802_TR: -#endif - case ARPHRD_IEEE802: - tmp -> hw_address.hlen = 7; - tmp -> hw_address.hbuf [0] = ARPHRD_IEEE802; - memcpy (&tmp -> hw_address.hbuf [1], sa.sa_data, 6); - break; - -#ifndef HAVE_ARPHRD_FDDI -# define ARPHRD_FDDI HTYPE_FDDI -#endif - case ARPHRD_FDDI: - tmp -> hw_address.hlen = 17; - tmp -> hw_address.hbuf [0] = HTYPE_FDDI; /* XXX */ - memcpy (&tmp -> hw_address.hbuf [1], sa.sa_data, 16); - break; - -#ifdef HAVE_ARPHRD_METRICOM - case ARPHRD_METRICOM: - tmp -> hw_address.hlen = 7; - tmp -> hw_address.hbuf [0] = ARPHRD_METRICOM; - memcpy (&tmp -> hw_address.hbuf [0], sa.sa_data, 6); - break; -#endif - -#ifdef HAVE_ARPHRD_AX25 - case ARPHRD_AX25: - tmp -> hw_address.hlen = 7; - tmp -> hw_address.hbuf [0] = ARPHRD_AX25; - memcpy (&tmp -> hw_address.hbuf [1], sa.sa_data, 6); - break; -#endif - -#ifdef HAVE_ARPHRD_NETROM - case ARPHRD_NETROM: - tmp -> hw_address.hlen = 7; - tmp -> hw_address.hbuf [0] = ARPHRD_NETROM; - memcpy (&tmp -> hw_address.hbuf [1], sa.sa_data, 6); - break; -#endif - - default: - log_error ("%s: unknown hardware address type %d", - ifr.ifr_name, sa.sa_family); - break; - } - } -#endif /* defined (HAVE_SIOCGIFHWADDR) && !defined (HAVE_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) { - close (sock); - return; - } - - /* Weed out the interfaces that did not have IP addresses. */ - tmp = last = next = (struct interface_info *)0; - if (interfaces) - interface_reference (&tmp, interfaces, MDL); - while (tmp) { - if (next) - interface_dereference (&next, MDL); - if (tmp -> next) - interface_reference (&next, tmp -> next, MDL); - /* skip interfaces that are running already */ - if (tmp -> flags & INTERFACE_RUNNING) { - interface_dereference(&tmp, MDL); - if(next) - interface_reference(&tmp, next, MDL); - continue; - } - if ((tmp -> flags & INTERFACE_AUTOMATIC) && - state == DISCOVER_REQUESTED) - tmp -> flags &= ~(INTERFACE_AUTOMATIC | - INTERFACE_REQUESTED); - if (!tmp -> ifp || !(tmp -> flags & INTERFACE_REQUESTED)) { - if ((tmp -> flags & INTERFACE_REQUESTED) != ir) - log_fatal ("%s: not found", tmp -> name); - if (!last) { - if (interfaces) - interface_dereference (&interfaces, - MDL); - if (next) - interface_reference (&interfaces, next, MDL); - } else { - interface_dereference (&last -> next, MDL); - if (next) - interface_reference (&last -> next, - next, MDL); - } - if (tmp -> next) - interface_dereference (&tmp -> next, MDL); - - /* Remember the interface in case we need to know - about it later. */ - if (dummy_interfaces) { - interface_reference (&tmp -> next, - dummy_interfaces, MDL); - interface_dereference (&dummy_interfaces, MDL); - } - interface_reference (&dummy_interfaces, tmp, MDL); - interface_dereference (&tmp, MDL); - if (next) - interface_reference (&tmp, next, MDL); - continue; - } - last = tmp; - - memcpy (&foo, &tmp -> ifp -> ifr_addr, - sizeof tmp -> ifp -> ifr_addr); - - /* We must have a subnet declaration for each interface. */ - if (!tmp -> shared_network && (state == DISCOVER_SERVER)) { - log_error ("%s", ""); - log_error ("No subnet declaration for %s (%s).", - tmp -> name, inet_ntoa (foo.sin_addr)); - if (supports_multiple_interfaces (tmp)) { - log_error ("** Ignoring requests on %s. %s", - tmp -> name, "If this is not what"); - log_error (" you want, please write %s", - "a subnet declaration"); - log_error (" in your dhcpd.conf file %s", - "for the network segment"); - log_error (" to %s %s %s", - "which interface", - tmp -> name, "is attached. **"); - log_error ("%s", ""); - goto next; - } else { - log_error ("You must write a subnet %s", - " declaration for this"); - log_error ("subnet. You cannot prevent %s", - "the DHCP server"); - log_error ("from listening on this subnet %s", - "because your"); - log_fatal ("operating system does not %s.", - "support this capability"); - } - } - - /* Find subnets that don't have valid interface - addresses... */ - for (subnet = (tmp -> shared_network - ? tmp -> shared_network -> subnets - : (struct subnet *)0); - subnet; subnet = subnet -> next_sibling) { - if (!subnet -> interface_address.len) { - /* Set the interface address for this subnet - to the first address we found. */ - subnet -> interface_address.len = 4; - memcpy (subnet -> interface_address.iabuf, - &foo.sin_addr.s_addr, 4); - } - } - - /* Flag the index as not having been set, so that the - interface registerer can set it or not as it chooses. */ - tmp -> index = -1; - - /* Register the interface... */ - if_register_receive (tmp); - if_register_send (tmp); - - interface_stash (tmp); - wifcount++; -#if defined (HAVE_SETFD) - if (fcntl (tmp -> rfdesc, F_SETFD, 1) < 0) - log_error ("Can't set close-on-exec on %s: %m", - tmp -> name); - if (tmp -> rfdesc != tmp -> wfdesc) { - if (fcntl (tmp -> wfdesc, F_SETFD, 1) < 0) - log_error ("Can't set close-on-exec on %s: %m", - tmp -> name); - } -#endif - next: - interface_dereference (&tmp, MDL); - if (next) - interface_reference (&tmp, next, MDL); - } - - /* Now register all the remaining interfaces as protocols. */ - for (tmp = interfaces; tmp; tmp = tmp -> next) { - /* not if it's been registered before */ - if (tmp -> flags & INTERFACE_RUNNING) - continue; - if (tmp -> rfdesc == -1) - continue; - status = omapi_register_io_object ((omapi_object_t *)tmp, - if_readsocket, 0, - got_one, 0, 0); - if (status != ISC_R_SUCCESS) - log_fatal ("Can't register I/O handle for %s: %s", - tmp -> name, isc_result_totext (status)); - } - - close (sock); - - if (state == DISCOVER_SERVER && wifcount == 0) { - log_info ("%s", ""); - log_fatal ("Not configured to listen on any interfaces!"); - } - - if (!setup_fallback) { - setup_fallback = 1; - maybe_setup_fallback (); - } - -#if defined (HAVE_SETFD) - if (fallback_interface) { - if (fcntl (fallback_interface -> rfdesc, F_SETFD, 1) < 0) - log_error ("Can't set close-on-exec on fallback: %m"); - if (fallback_interface -> rfdesc != fallback_interface -> wfdesc) { - if (fcntl (fallback_interface -> wfdesc, F_SETFD, 1) < 0) - log_error ("Can't set close-on-exec on fallback: %m"); - } - } -#endif -} - -int if_readsocket (h) - omapi_object_t *h; -{ - struct interface_info *ip; - - if (h -> type != dhcp_type_interface) - return -1; - ip = (struct interface_info *)h; - return ip -> rfdesc; -} - -int setup_fallback (struct interface_info **fp, const char *file, int line) -{ - isc_result_t status; - - status = interface_allocate (&fallback_interface, file, line); - if (status != ISC_R_SUCCESS) - log_fatal ("Error allocating fallback interface: %s", - isc_result_totext (status)); - strcpy (fallback_interface -> name, "fallback"); - if (dhcp_interface_setup_hook) - (*dhcp_interface_setup_hook) (fallback_interface, - (struct iaddr *)0); - status = interface_reference (fp, fallback_interface, file, line); - - fallback_interface -> index = -1; - interface_stash (fallback_interface); - return status == ISC_R_SUCCESS; -} - -void reinitialize_interfaces () -{ - struct interface_info *ip; - - for (ip = interfaces; ip; ip = ip -> next) { - if_reinitialize_receive (ip); - if_reinitialize_send (ip); - } - - if (fallback_interface) - if_reinitialize_send (fallback_interface); - - interfaces_invalidated = 1; -} - -isc_result_t got_one (h) - omapi_object_t *h; -{ - struct sockaddr_in from; - struct hardware hfrom; - struct iaddr ifrom; - int result; - union { - unsigned char packbuf [4095]; /* Packet input buffer. - Must be as large as largest - possible MTU. */ - struct dhcp_packet packet; - } u; - struct interface_info *ip; - - if (h -> type != dhcp_type_interface) - return ISC_R_INVALIDARG; - ip = (struct interface_info *)h; - - again: - if ((result = - receive_packet (ip, u.packbuf, sizeof u, &from, &hfrom)) < 0) { - log_error ("receive_packet failed on %s: %m", ip -> name); - return ISC_R_UNEXPECTED; - } - if (result == 0) - return ISC_R_UNEXPECTED; - - /* If we didn't at least get the fixed portion of the BOOTP - packet, drop the packet. We're allowing packets with no - sname or filename, because we're aware of at least one - client that sends such packets, but this definitely falls - into the category of being forgiving. */ - if (result < DHCP_FIXED_NON_UDP - DHCP_SNAME_LEN - DHCP_FILE_LEN) - return ISC_R_UNEXPECTED; - - if (bootp_packet_handler) { - ifrom.len = 4; - memcpy (ifrom.iabuf, &from.sin_addr, ifrom.len); - - (*bootp_packet_handler) (ip, &u.packet, (unsigned)result, - from.sin_port, ifrom, &hfrom); - } - - /* If there is buffered data, read again. This is for, e.g., - bpf, which may return two packets at once. */ - if (ip -> rbuf_offset != ip -> rbuf_len) - goto again; - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_interface_set_value (omapi_object_t *h, - omapi_object_t *id, - omapi_data_string_t *name, - omapi_typed_data_t *value) -{ - struct interface_info *interface; - isc_result_t status; - int foo; - - if (h -> type != dhcp_type_interface) - return ISC_R_INVALIDARG; - interface = (struct interface_info *)h; - - if (!omapi_ds_strcmp (name, "name")) { - if ((value -> type == omapi_datatype_data || - value -> type == omapi_datatype_string) && - value -> u.buffer.len < sizeof interface -> name) { - memcpy (interface -> name, - value -> u.buffer.value, - value -> u.buffer.len); - interface -> name [value -> u.buffer.len] = 0; - } else - return ISC_R_INVALIDARG; - return ISC_R_SUCCESS; - } - - /* Try to find some inner object that can take the value. */ - if (h -> inner && h -> inner -> type -> set_value) { - status = ((*(h -> inner -> type -> set_value)) - (h -> inner, id, name, value)); - if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED) - return status; - } - - return ISC_R_NOTFOUND; -} - - -isc_result_t dhcp_interface_get_value (omapi_object_t *h, - omapi_object_t *id, - omapi_data_string_t *name, - omapi_value_t **value) -{ - return ISC_R_NOTIMPLEMENTED; -} - -isc_result_t dhcp_interface_destroy (omapi_object_t *h, - const char *file, int line) -{ - struct interface_info *interface; - isc_result_t status; - - if (h -> type != dhcp_type_interface) - return ISC_R_INVALIDARG; - interface = (struct interface_info *)h; - - if (interface -> ifp) { - dfree (interface -> ifp, file, line); - interface -> ifp = 0; - } - if (interface -> next) - interface_dereference (&interface -> next, file, line); - if (interface -> rbuf) { - dfree (interface -> rbuf, file, line); - interface -> rbuf = (unsigned char *)0; - } - if (interface -> client) - interface -> client = (struct client_state *)0; - - if (interface -> shared_network) - omapi_object_dereference ((omapi_object_t **) - &interface -> shared_network, MDL); - - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_interface_signal_handler (omapi_object_t *h, - const char *name, va_list ap) -{ - struct interface_info *ip, *interface; - struct client_config *config; - struct client_state *client; - isc_result_t status; - - if (h -> type != dhcp_type_interface) - return ISC_R_INVALIDARG; - interface = (struct interface_info *)h; - - /* If it's an update signal, see if the interface is dead right - now, or isn't known at all, and if that's the case, revive it. */ - if (!strcmp (name, "update")) { - for (ip = dummy_interfaces; ip; ip = ip -> next) - if (ip == interface) - break; - if (ip && dhcp_interface_startup_hook) - return (*dhcp_interface_startup_hook) (ip); - - for (ip = interfaces; ip; ip = ip -> next) - if (ip == interface) - break; - if (!ip && dhcp_interface_startup_hook) - return (*dhcp_interface_startup_hook) (ip); - } - - /* Try to find some inner object that can take the value. */ - if (h -> inner && h -> inner -> type -> get_value) { - status = ((*(h -> inner -> type -> signal_handler)) - (h -> inner, name, ap)); - if (status == ISC_R_SUCCESS) - return status; - } - return ISC_R_NOTFOUND; -} - -isc_result_t dhcp_interface_stuff_values (omapi_object_t *c, - omapi_object_t *id, - omapi_object_t *h) -{ - struct interface_info *interface; - isc_result_t status; - - if (h -> type != dhcp_type_interface) - return ISC_R_INVALIDARG; - interface = (struct interface_info *)h; - - /* Write out all the values. */ - - status = omapi_connection_put_name (c, "state"); - if (status != ISC_R_SUCCESS) - return status; - if (interface -> flags && INTERFACE_REQUESTED) - status = omapi_connection_put_string (c, "up"); - else - status = omapi_connection_put_string (c, "down"); - if (status != ISC_R_SUCCESS) - return status; - - /* Write out the inner object, if any. */ - if (h -> inner && h -> inner -> type -> stuff_values) { - status = ((*(h -> inner -> type -> stuff_values)) - (c, id, h -> inner)); - if (status == ISC_R_SUCCESS) - return status; - } - - return ISC_R_SUCCESS; -} - -isc_result_t dhcp_interface_lookup (omapi_object_t **ip, - omapi_object_t *id, - omapi_object_t *ref) -{ - omapi_value_t *tv = (omapi_value_t *)0; - isc_result_t status; - struct interface_info *interface; - - if (!ref) - return ISC_R_NOKEYS; - - /* First see if we were sent a handle. */ - status = omapi_get_value_str (ref, id, "handle", &tv); - if (status == ISC_R_SUCCESS) { - status = omapi_handle_td_lookup (ip, tv -> value); - - omapi_value_dereference (&tv, MDL); - if (status != ISC_R_SUCCESS) - return status; - - /* Don't return the object if the type is wrong. */ - if ((*ip) -> type != dhcp_type_interface) { - omapi_object_dereference (ip, MDL); - return ISC_R_INVALIDARG; - } - } - - /* Now look for an interface name. */ - status = omapi_get_value_str (ref, id, "name", &tv); - if (status == ISC_R_SUCCESS) { - char *s; - unsigned len; - for (interface = interfaces; interface; - interface = interface -> next) { - s = memchr (interface -> name, 0, IFNAMSIZ); - if (s) - len = s - &interface -> name [0]; - else - len = IFNAMSIZ; - if ((tv -> value -> u.buffer.len == len && - !memcmp (interface -> name, - (char *)tv -> value -> u.buffer.value, - len))) - break; - } - if (!interface) { - for (interface = dummy_interfaces; - interface; interface = interface -> next) { - s = memchr (interface -> name, 0, IFNAMSIZ); - if (s) - len = s - &interface -> name [0]; - else - len = IFNAMSIZ; - if ((tv -> value -> u.buffer.len == len && - !memcmp (interface -> name, - (char *) - tv -> value -> u.buffer.value, - len))) - break; - } - } - - omapi_value_dereference (&tv, MDL); - if (*ip && *ip != (omapi_object_t *)interface) { - omapi_object_dereference (ip, MDL); - return ISC_R_KEYCONFLICT; - } else if (!interface) { - if (*ip) - omapi_object_dereference (ip, MDL); - return ISC_R_NOTFOUND; - } else if (!*ip) - omapi_object_reference (ip, - (omapi_object_t *)interface, - MDL); - } - - /* If we get to here without finding an interface, no valid key was - specified. */ - if (!*ip) - return ISC_R_NOKEYS; - return ISC_R_SUCCESS; -} - -/* actually just go discover the interface */ -isc_result_t dhcp_interface_create (omapi_object_t **lp, - omapi_object_t *id) -{ - struct interface_info *hp; - isc_result_t status; - - hp = (struct interface_info *)0; - status = interface_allocate (&hp, MDL); - if (status != ISC_R_SUCCESS) - return status; - hp -> flags = INTERFACE_REQUESTED; - status = interface_reference ((struct interface_info **)lp, hp, MDL); - interface_dereference (&hp, MDL); - return status; -} - -isc_result_t dhcp_interface_remove (omapi_object_t *lp, - omapi_object_t *id) -{ - struct interface_info *interface, *ip, *last; - - interface = (struct interface_info *)lp; - - /* remove from interfaces */ - last = 0; - for (ip = interfaces; ip; ip = ip -> next) { - if (ip == interface) { - if (last) { - interface_dereference (&last -> next, MDL); - if (ip -> next) - interface_reference (&last -> next, - ip -> next, MDL); - } else { - interface_dereference (&interfaces, MDL); - if (ip -> next) - interface_reference (&interfaces, - ip -> next, MDL); - } - if (ip -> next) - interface_dereference (&ip -> next, MDL); - break; - } - last = ip; - } - if (!ip) - return ISC_R_NOTFOUND; - - /* add the interface to the dummy_interface list */ - if (dummy_interfaces) { - interface_reference (&interface -> next, - dummy_interfaces, MDL); - interface_dereference (&dummy_interfaces, MDL); - } - interface_reference (&dummy_interfaces, interface, MDL); - - /* do a DHCPRELEASE */ - if (dhcp_interface_shutdown_hook) - (*dhcp_interface_shutdown_hook) (interface); - - /* remove the io object */ - omapi_unregister_io_object ((omapi_object_t *)interface); - - if_deregister_send (interface); - if_deregister_receive (interface); - - return ISC_R_SUCCESS; -} - -void interface_stash (struct interface_info *tptr) -{ - struct interface_info **vec; - int delta; - - /* If the registerer didn't assign an index, assign one now. */ - if (tptr -> index == -1) { - tptr -> index = interface_count++; - while (tptr -> index < interface_max && - interface_vector [tptr -> index]) - tptr -> index = interface_count++; - } - - if (interface_max <= tptr -> index) { - delta = tptr -> index - interface_max + 10; - vec = dmalloc ((interface_max + delta) * - sizeof (struct interface_info *), MDL); - if (!vec) - return; - memset (&vec [interface_max], 0, - (sizeof (struct interface_info *)) * delta); - interface_max += delta; - if (interface_vector) { - memcpy (vec, interface_vector, - (interface_count * - sizeof (struct interface_info *))); - dfree (interface_vector, MDL); - } - interface_vector = vec; - } - interface_reference (&interface_vector [tptr -> index], tptr, MDL); - if (tptr -> index >= interface_count) - interface_count = tptr -> index + 1; -#if defined (TRACING) - trace_interface_register (interface_trace, tptr); -#endif -} - -void interface_snorf (struct interface_info *tmp, int ir) -{ - tmp -> circuit_id = (u_int8_t *)tmp -> name; - tmp -> circuit_id_len = strlen (tmp -> name); - tmp -> remote_id = 0; - tmp -> remote_id_len = 0; - tmp -> flags = ir; - if (interfaces) { - interface_reference (&tmp -> next, - interfaces, MDL); - interface_dereference (&interfaces, MDL); - } - interface_reference (&interfaces, tmp, MDL); -} diff --git a/contrib/dhcp-3.0/common/dispatch.c b/contrib/dhcp-3.0/common/dispatch.c deleted file mode 100644 index 01865dd..0000000 --- a/contrib/dhcp-3.0/common/dispatch.c +++ /dev/null @@ -1,219 +0,0 @@ -/* dispatch.c - - Network input dispatcher... */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1995-2003 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Internet Systems Consortium, Inc. - * 950 Charter Street - * Redwood City, CA 94063 - * - * http://www.isc.org/ - * - * This software has been written for Internet Systems Consortium - * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. - * To learn more about Internet Systems Consortium, see - * ``http://www.isc.org/''. To learn more about Vixie Enterprises, - * see ``http://www.vix.com''. To learn more about Nominum, Inc., see - * ``http://www.nominum.com''. - */ - -#ifndef lint -static char copyright[] = -"$Id: dispatch.c,v 1.63.2.4 2004/06/10 17:59:16 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" - -struct timeout *timeouts; -static struct timeout *free_timeouts; - -void set_time (u_int32_t t) -{ - /* Do any outstanding timeouts. */ - if (cur_time != t) { - cur_time = t; - process_outstanding_timeouts ((struct timeval *)0); - } -} - -struct timeval *process_outstanding_timeouts (struct timeval *tvp) -{ - /* Call any expired timeouts, and then if there's - still a timeout registered, time out the select - call then. */ - another: - if (timeouts) { - struct timeout *t; - if (timeouts -> when <= cur_time) { - t = timeouts; - timeouts = timeouts -> next; - (*(t -> func)) (t -> what); - if (t -> unref) - (*t -> unref) (&t -> what, MDL); - t -> next = free_timeouts; - free_timeouts = t; - goto another; - } - if (tvp) { - tvp -> tv_sec = timeouts -> when; - tvp -> tv_usec = 0; - } - return tvp; - } else - return (struct timeval *)0; -} - -/* 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 through the - bootp_packet_handler hook to try to do something with it. */ - -void dispatch () -{ - struct timeval tv, *tvp; - isc_result_t status; - - /* Wait for a packet or a timeout... XXX */ - do { - tvp = process_outstanding_timeouts (&tv); - status = omapi_one_dispatch (0, tvp); - } while (status == ISC_R_TIMEDOUT || status == ISC_R_SUCCESS); - log_fatal ("omapi_one_dispatch failed: %s -- exiting.", - isc_result_totext (status)); -} - -void add_timeout (when, where, what, ref, unref) - TIME when; - void (*where) PROTO ((void *)); - void *what; - tvref_t ref; - tvunref_t unref; -{ - struct timeout *t, *q; - - /* See if this timeout supersedes an existing timeout. */ - t = (struct timeout *)0; - for (q = timeouts; q; q = q -> next) { - if ((where == NULL || q -> func == where) && - q -> what == what) { - if (t) - t -> next = q -> next; - else - timeouts = q -> next; - break; - } - t = q; - } - - /* If we didn't supersede a timeout, allocate a timeout - structure now. */ - if (!q) { - if (free_timeouts) { - q = free_timeouts; - free_timeouts = q -> next; - } else { - q = ((struct timeout *) - dmalloc (sizeof (struct timeout), MDL)); - if (!q) - log_fatal ("add_timeout: no memory!"); - } - memset (q, 0, sizeof *q); - q -> func = where; - q -> ref = ref; - q -> unref = unref; - if (q -> ref) - (*q -> ref)(&q -> what, what, MDL); - else - q -> what = what; - } - - q -> when = when; - - /* Now sort this timeout into the timeout list. */ - - /* Beginning of list? */ - if (!timeouts || timeouts -> when > q -> when) { - q -> next = timeouts; - timeouts = q; - return; - } - - /* Middle of list? */ - for (t = timeouts; t -> next; t = t -> next) { - if (t -> next -> when > q -> when) { - q -> next = t -> next; - t -> next = q; - return; - } - } - - /* End of list. */ - t -> next = q; - q -> next = (struct timeout *)0; -} - -void cancel_timeout (where, what) - void (*where) PROTO ((void *)); - void *what; -{ - struct timeout *t, *q; - - /* Look for this timeout on the list, and unlink it if we find it. */ - t = (struct timeout *)0; - for (q = timeouts; q; q = q -> next) { - if (q -> func == where && q -> what == what) { - if (t) - t -> next = q -> next; - else - timeouts = q -> next; - break; - } - t = q; - } - - /* If we found the timeout, put it on the free list. */ - if (q) { - if (q -> unref) - (*q -> unref) (&q -> what, MDL); - q -> next = free_timeouts; - free_timeouts = q; - } -} - -#if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) -void cancel_all_timeouts () -{ - struct timeout *t, *n; - for (t = timeouts; t; t = n) { - n = t -> next; - if (t -> unref && t -> what) - (*t -> unref) (&t -> what, MDL); - t -> next = free_timeouts; - free_timeouts = t; - } -} - -void relinquish_timeouts () -{ - struct timeout *t, *n; - for (t = free_timeouts; t; t = n) { - n = t -> next; - dfree (t, MDL); - } -} -#endif diff --git a/contrib/dhcp-3.0/common/dlpi.c b/contrib/dhcp-3.0/common/dlpi.c deleted file mode 100644 index 83fc406..0000000 --- a/contrib/dhcp-3.0/common/dlpi.c +++ /dev/null @@ -1,1336 +0,0 @@ -/* dlpi.c - - Data Link Provider Interface (DLPI) network interface code. */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996-2003 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Internet Systems Consortium, Inc. - * 950 Charter Street - * Redwood City, CA 94063 - * - * http://www.isc.org/ - * - * This software was written for Internet Systems Consortium - * by Eric James Negaard, . To learn more about - * Internet Systems Consortium, see ``http://www.isc.org''. - * - * Joost Mulders has also done considerable work in debugging the DLPI API - * support on Solaris and getting this code to work properly on a variety - * of different Solaris platforms. - */ - -/* - * Based largely in part to the existing NIT code in nit.c. - * - * This code has been developed and tested on sparc-based machines running - * SunOS 5.5.1, with le and hme network interfaces. It should be pretty - * generic, though. - */ - -/* - * Implementation notes: - * - * I first tried to write this code to the "vanilla" DLPI 2.0 API. - * It worked on a Sun Ultra-1 with a hme interface, but didn't work - * on Sun SparcStation 5's with "le" interfaces (the packets sent out - * via dlpiunitdatareq contained an Ethernet type of 0x0000 instead - * of the expected 0x0800). - * - * Therefore I added the "DLPI_RAW" code which is a Sun extension to - * the DLPI standard. This code works on both of the above machines. - * This is configurable in the OS-dependent include file by defining - * USE_DLPI_RAW. - * - * It quickly became apparant that I should also use the "pfmod" - * STREAMS module to cut down on the amount of user level packet - * processing. I don't know how widely available "pfmod" is, so it's - * use is conditionally included. This is configurable in the - * OS-dependent include file by defining USE_DLPI_PFMOD. - * - * A major quirk on the Sun's at least, is that no packets seem to get - * sent out the interface until six seconds after the interface is - * first "attached" to [per system reboot] (it's actually from when - * the interface is attached, not when it is plumbed, so putting a - * sleep into the dhclient-script at PREINIT time doesn't help). I - * HAVE tried, without success to poll the fd to see when it is ready - * for writing. This doesn't help at all. If the sleeps are not done, - * the initial DHCPREQUEST or DHCPDISCOVER never gets sent out, so - * I've put them here, when register_send and register_receive are - * called (split up into two three-second sleeps between the notices, - * so that it doesn't seem like so long when you're watching :-). The - * amount of time to sleep is configurable in the OS-dependent include - * file by defining DLPI_FIRST_SEND_WAIT to be the number of seconds - * to sleep. - */ - -#ifndef lint -static char copyright[] = -"$Id: dlpi.c,v 1.28.2.3 2004/11/24 17:39:15 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" - -#if defined (USE_DLPI_SEND) || defined (USE_DLPI_RECEIVE) - -# include -# include -# include -# include -# ifdef USE_DLPI_PFMOD -# include -# endif -# ifdef USE_POLL -# include -# endif - -# include -# include "includes/netinet/ip.h" -# include "includes/netinet/udp.h" -# include "includes/netinet/if_ether.h" - -# ifdef USE_DLPI_PFMOD -# ifdef USE_DLPI_RAW -# define DLPI_MODNAME "DLPI+RAW+PFMOD" -# else -# define DLPI_MODNAME "DLPI+PFMOD" -# endif -# else -# ifdef USE_DLPI_RAW -# define DLPI_MODNAME "DLPI+RAW" -# else -# define DLPI_MODNAME "DLPI" -# endif -# endif - -# ifndef ABS -# define ABS(x) ((x) >= 0 ? (x) : 0-(x)) -# endif - -static int strioctl PROTO ((int fd, int cmd, int timeout, int len, char *dp)); - -#define DLPI_MAXDLBUF 8192 /* Buffer size */ -#define DLPI_MAXDLADDR 1024 /* Max address size */ -#define DLPI_DEVDIR "/dev/" /* Device directory */ - -static int dlpiopen PROTO ((char *ifname)); -static int dlpiunit PROTO ((char *ifname)); -static int dlpiinforeq PROTO ((int fd)); -static int dlpiphysaddrreq PROTO ((int fd, unsigned long addrtype)); -static int dlpiattachreq PROTO ((int fd, unsigned long ppa)); -static int dlpibindreq PROTO ((int fd, unsigned long sap, unsigned long max_conind, - unsigned long service_mode, unsigned long conn_mgmt, - unsigned long xidtest)); -static int dlpidetachreq PROTO ((int fd)); -static int dlpiunbindreq PROTO ((int fd)); -static int dlpiokack PROTO ((int fd, char *bufp)); -static int dlpiinfoack PROTO ((int fd, char *bufp)); -static int dlpiphysaddrack PROTO ((int fd, char *bufp)); -static int dlpibindack PROTO ((int fd, char *bufp)); -static int dlpiunitdatareq PROTO ((int fd, unsigned char *addr, - int addrlen, unsigned long minpri, - unsigned long maxpri, unsigned char *data, - int datalen)); -static int dlpiunitdataind PROTO ((int fd, - unsigned char *dstaddr, - unsigned long *dstaddrlen, - unsigned char *srcaddr, - unsigned long *srcaddrlen, - unsigned long *grpaddr, - unsigned char *data, - int datalen)); - -# ifndef USE_POLL -static void sigalrm PROTO ((int sig)); -# endif -static int expected PROTO ((unsigned long prim, union DL_primitives *dlp, - int msgflags)); -static int strgetmsg PROTO ((int fd, struct strbuf *ctlp, - struct strbuf *datap, int *flagsp, - char *caller)); - -/* Reinitializes the specified interface after an address change. This - is not required for packet-filter APIs. */ - -#ifdef USE_DLPI_SEND -void if_reinitialize_send (info) - struct interface_info *info; -{ -} -#endif - -#ifdef USE_DLPI_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_dlpi (info) - struct interface_info *info; -{ - int sock; - int unit; - long buf [DLPI_MAXDLBUF]; - union DL_primitives *dlp; - - dlp = (union DL_primitives *)buf; - - /* Open a DLPI device */ - if ((sock = dlpiopen (info -> name)) < 0) { - log_fatal ("Can't open DLPI device for %s: %m", info -> name); - } - - - /* - * Submit a DL_INFO_REQ request, to find the dl_mac_type and - * dl_provider_style - */ - if (dlpiinforeq(sock) < 0 || dlpiinfoack(sock, (char *)buf) < 0) { - log_fatal ("Can't get DLPI MAC type for %s: %m", info -> name); - } else { - switch (dlp -> info_ack.dl_mac_type) { - case DL_CSMACD: /* IEEE 802.3 */ - case DL_ETHER: - info -> hw_address.hbuf [0] = HTYPE_ETHER; - break; - /* adding token ring 5/1999 - mayer@ping.at */ - case DL_TPR: - info -> hw_address.hbuf [0] = HTYPE_IEEE802; - break; - case DL_FDDI: - info -> hw_address.hbuf [0] = HTYPE_FDDI; - break; - default: - log_fatal ("%s: unsupported DLPI MAC type %ld", - info -> name, dlp -> info_ack.dl_mac_type); - break; - } - /* - * copy the sap length and broadcast address of this interface - * to interface_info. This fixes nothing but seemed nicer than to - * assume -2 and ffffff. - */ - info -> dlpi_sap_length = dlp -> info_ack.dl_sap_length; - info -> dlpi_broadcast_addr.hlen = - dlp -> info_ack.dl_brdcst_addr_length; - memcpy (info -> dlpi_broadcast_addr.hbuf, - (char *)dlp + dlp -> info_ack.dl_brdcst_addr_offset, - dlp -> info_ack.dl_brdcst_addr_length); - } - - if (dlp -> info_ack.dl_provider_style == DL_STYLE2) { - /* - * Attach to the device. If this fails, the device - * does not exist. - */ - unit = dlpiunit (info -> name); - - if (dlpiattachreq (sock, unit) < 0 - || dlpiokack (sock, (char *)buf) < 0) { - log_fatal ("Can't attach DLPI device for %s: %m", info -> name); - } - } - - /* - * Bind to the IP service access point (SAP), connectionless (CLDLS). - */ - if (dlpibindreq (sock, ETHERTYPE_IP, 0, DL_CLDLS, 0, 0) < 0 - || dlpibindack (sock, (char *)buf) < 0) { - log_fatal ("Can't bind DLPI device for %s: %m", info -> name); - } - - /* - * Submit a DL_PHYS_ADDR_REQ request, to find - * the hardware address - */ - if (dlpiphysaddrreq (sock, DL_CURR_PHYS_ADDR) < 0 - || dlpiphysaddrack (sock, (char *)buf) < 0) { - log_fatal ("Can't get DLPI hardware address for %s: %m", - info -> name); - } - - info -> hw_address.hlen = dlp -> physaddr_ack.dl_addr_length + 1; - memcpy (&info -> hw_address.hbuf [1], - (char *)buf + dlp -> physaddr_ack.dl_addr_offset, - dlp -> physaddr_ack.dl_addr_length); - -#ifdef USE_DLPI_RAW - if (strioctl (sock, DLIOCRAW, INFTIM, 0, 0) < 0) { - log_fatal ("Can't set DLPI RAW mode for %s: %m", - info -> name); - } -#endif - -#ifdef USE_DLPI_PFMOD - if (ioctl (sock, I_PUSH, "pfmod") < 0) { - log_fatal ("Can't push packet filter onto DLPI for %s: %m", - info -> name); - } -#endif - - return sock; -} - -static int -strioctl (fd, cmd, timeout, len, dp) -int fd; -int cmd; -int timeout; -int len; -char *dp; -{ - struct strioctl sio; - int rslt; - - sio.ic_cmd = cmd; - sio.ic_timout = timeout; - sio.ic_len = len; - sio.ic_dp = dp; - - if ((rslt = ioctl (fd, I_STR, &sio)) < 0) { - return rslt; - } else { - return sio.ic_len; - } -} - -#ifdef USE_DLPI_SEND -void if_register_send (info) - struct interface_info *info; -{ - /* If we're using the DLPI API for sending and receiving, - we don't need to register this interface twice. */ -#ifndef USE_DLPI_RECEIVE -# ifdef USE_DLPI_PFMOD - struct packetfilt pf; -# endif - - info -> wfdesc = if_register_dlpi (info); - -# ifdef USE_DLPI_PFMOD - /* Set up an PFMOD filter that rejects everything... */ - pf.Pf_Priority = 0; - pf.Pf_FilterLen = 1; - pf.Pf_Filter [0] = ENF_PUSHZERO; - - /* Install the filter */ - if (strioctl (info -> wfdesc, PFIOCSETF, INFTIM, - sizeof (pf), (char *)&pf) < 0) { - log_fatal ("Can't set PFMOD send filter on %s: %m", info -> name); - } - -# endif /* USE_DLPI_PFMOD */ -#else /* !defined (USE_DLPI_RECEIVE) */ - /* - * If using DLPI for both send and receive, simply re-use - * the read file descriptor that was set up earlier. - */ - info -> wfdesc = info -> rfdesc; -#endif - - if (!quiet_interface_discovery) - log_info ("Sending on DLPI/%s/%s%s%s", - info -> name, - print_hw_addr (info -> hw_address.hbuf [0], - info -> hw_address.hlen - 1, - &info -> hw_address.hbuf [1]), - (info -> shared_network ? "/" : ""), - (info -> shared_network ? - info -> shared_network -> name : "")); - -#ifdef DLPI_FIRST_SEND_WAIT -/* See the implementation notes at the beginning of this file */ -# ifdef USE_DLPI_RECEIVE - sleep (DLPI_FIRST_SEND_WAIT - (DLPI_FIRST_SEND_WAIT / 2)); -# else - sleep (DLPI_FIRST_SEND_WAIT); -# endif -#endif -} - -void if_deregister_send (info) - struct interface_info *info; -{ - /* If we're using the DLPI API for sending and receiving, - we don't need to register this interface twice. */ -#ifndef USE_DLPI_RECEIVE - close (info -> wfdesc); -#endif - info -> wfdesc = -1; - - if (!quiet_interface_discovery) - log_info ("Disabling output on DLPI/%s/%s%s%s", - info -> name, - print_hw_addr (info -> hw_address.hbuf [0], - info -> hw_address.hlen - 1, - &info -> hw_address.hbuf [1]), - (info -> shared_network ? "/" : ""), - (info -> shared_network ? - info -> shared_network -> name : "")); -} -#endif /* USE_DLPI_SEND */ - -#ifdef USE_DLPI_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 NIT program! XXX */ - -void if_register_receive (info) - struct interface_info *info; -{ -#ifdef USE_DLPI_PFMOD - struct packetfilt pf; - struct ip iphdr; - u_int16_t offset; -#endif - - /* Open a DLPI device and hang it on this interface... */ - info -> rfdesc = if_register_dlpi (info); - -#ifdef USE_DLPI_PFMOD - /* Set up the PFMOD filter program. */ - /* XXX Unlike the BPF filter program, this one won't work if the - XXX IP packet is fragmented or if there are options on the IP - XXX header. */ - pf.Pf_Priority = 0; - pf.Pf_FilterLen = 0; - -#if defined (USE_DLPI_RAW) -# define ETHER_H_PREFIX (14) /* sizeof (ethernet_header) */ - /* - * ethertype == ETHERTYPE_IP - */ - offset = 12; - pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + (offset / 2); - pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT | ENF_CAND; - pf.Pf_Filter [pf.Pf_FilterLen++] = htons (ETHERTYPE_IP); -# else -# define ETHER_H_PREFIX (0) -# endif /* USE_DLPI_RAW */ - /* - * The packets that will be received on this file descriptor - * will be IP packets (due to the SAP that was specified in - * the dlbind call). There will be no ethernet header. - * Therefore, setup the packet filter to check the protocol - * field for UDP, and the destination port number equal - * to the local port. All offsets are relative to the start - * of an IP packet. - */ - - /* - * BOOTPS destination port - */ - offset = ETHER_H_PREFIX + sizeof (iphdr) + sizeof (u_int16_t); - pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + (offset / 2); - pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT | ENF_CAND; - pf.Pf_Filter [pf.Pf_FilterLen++] = local_port; - - /* - * protocol should be udp. this is a byte compare, test for - * endianess. - */ - offset = ETHER_H_PREFIX + ((u_int8_t *)&(iphdr.ip_p) - (u_int8_t *)&iphdr); - pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + (offset / 2); - pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT | ENF_AND; - pf.Pf_Filter [pf.Pf_FilterLen++] = htons (0x00FF); - pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT | ENF_CAND; - pf.Pf_Filter [pf.Pf_FilterLen++] = htons (IPPROTO_UDP); - - /* Install the filter... */ - if (strioctl (info -> rfdesc, PFIOCSETF, INFTIM, - sizeof (pf), (char *)&pf) < 0) { - log_fatal ("Can't set PFMOD receive filter on %s: %m", info -> name); - } -#endif /* USE_DLPI_PFMOD */ - - if (!quiet_interface_discovery) - log_info ("Listening on DLPI/%s/%s%s%s", - info -> name, - print_hw_addr (info -> hw_address.hbuf [0], - info -> hw_address.hlen - 1, - &info -> hw_address.hbuf [1]), - (info -> shared_network ? "/" : ""), - (info -> shared_network ? - info -> shared_network -> name : "")); - -#ifdef DLPI_FIRST_SEND_WAIT -/* See the implementation notes at the beginning of this file */ -# ifdef USE_DLPI_SEND - sleep (DLPI_FIRST_SEND_WAIT / 2); -# else - sleep (DLPI_FIRST_SEND_WAIT); -# endif -#endif -} - -void if_deregister_receive (info) - struct interface_info *info; -{ - /* If we're using the DLPI API for sending and receiving, - we don't need to register this interface twice. */ -#ifndef USE_DLPI_SEND - close (info -> rfdesc); -#endif - info -> rfdesc = -1; - - if (!quiet_interface_discovery) - log_info ("Disabling input on DLPI/%s/%s%s%s", - info -> name, - print_hw_addr (info -> hw_address.hbuf [0], - info -> hw_address.hlen - 1, - &info -> hw_address.hbuf [1]), - (info -> shared_network ? "/" : ""), - (info -> shared_network ? - info -> shared_network -> name : "")); -} -#endif /* USE_DLPI_RECEIVE */ - -#ifdef USE_DLPI_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; -{ - unsigned hbufp = 0; - double hh [32]; - double ih [1536 / sizeof (double)]; - unsigned char *dbuf = (unsigned char *)ih; - unsigned dbuflen; - unsigned char dstaddr [DLPI_MAXDLADDR]; - unsigned addrlen; - int result; - int fudge; - - if (!strcmp (interface -> name, "fallback")) - return send_fallback (interface, packet, raw, - len, from, to, hto); - - dbuflen = 0; - - /* Assemble the headers... */ -#ifdef USE_DLPI_RAW - assemble_hw_header (interface, (unsigned char *)hh, &dbuflen, hto); - if (dbuflen > sizeof hh) - log_fatal ("send_packet: hh buffer too small.\n"); - fudge = dbuflen % 4; /* IP header must be word-aligned. */