summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcvs2git <source@isc.org>1996-11-08 20:09:42 +0000
committercvs2git <source@isc.org>1996-11-08 20:09:42 +0000
commit753d3a8f6685898b7fcdfca7262576cf752c99d1 (patch)
tree498a0b40fbe3e73c76765340c71a91624fae663b
parent0b5d360d4b8b4b947c107f053042e55675eb9b1d (diff)
downloadisc-dhcp-753d3a8f6685898b7fcdfca7262576cf752c99d1.tar.gz
This commit was manufactured by cvs2git to create tag 'BETA_5_14'.BETA_5_14
-rw-r--r--client/dhclient.c402
-rw-r--r--common/alloc.c247
-rw-r--r--common/bpf.c370
-rw-r--r--common/conflex.c468
-rw-r--r--common/convert.c118
-rw-r--r--common/dispatch.c503
-rw-r--r--common/errwarn.c256
-rw-r--r--common/hash.c174
-rw-r--r--common/inet.c154
-rw-r--r--common/memory.c873
-rw-r--r--common/nit.c331
-rw-r--r--common/options.c536
-rw-r--r--common/packet.c314
-rw-r--r--common/print.c186
-rw-r--r--common/raw.c131
-rw-r--r--common/socket.c199
-rw-r--r--common/tables.c690
-rw-r--r--common/tree.c408
-rw-r--r--includes/cdefs.h57
-rw-r--r--includes/cf/alphaosf.h98
-rw-r--r--includes/cf/bsdos.h81
-rw-r--r--includes/cf/freebsd.h84
-rw-r--r--includes/cf/hpux.h78
-rw-r--r--includes/cf/linux.h95
-rw-r--r--includes/cf/netbsd.h81
-rw-r--r--includes/cf/qnx.h106
-rw-r--r--includes/cf/sample.h292
-rw-r--r--includes/cf/sco.h112
-rw-r--r--includes/cf/sunos4.h134
-rw-r--r--includes/cf/sunos5-5.h124
-rw-r--r--includes/cf/ultrix.h100
-rw-r--r--includes/dhcp.h166
-rw-r--r--includes/dhcpd.h586
-rw-r--r--includes/dhctoken.h97
-rw-r--r--includes/hash.h55
-rw-r--r--includes/inet.h47
-rw-r--r--includes/osdep.h185
-rw-r--r--includes/site.h100
-rw-r--r--includes/tree.h104
-rw-r--r--server/bootp.c288
-rw-r--r--server/confpars.c1808
-rw-r--r--server/db.c212
-rw-r--r--server/dhcp.c1162
-rw-r--r--server/dhcpd.8308
-rw-r--r--server/dhcpd.c260
-rw-r--r--server/dhcpd.cat8330
-rw-r--r--server/dhcpd.conf128
-rw-r--r--server/dhcpd.conf.51050
-rw-r--r--server/dhcpd.conf.cat51188
49 files changed, 0 insertions, 15876 deletions
diff --git a/client/dhclient.c b/client/dhclient.c
deleted file mode 100644
index 8bc551ef..00000000
--- a/client/dhclient.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/* dhcp.c
-
- DHCP Client (really lame DHCP client). */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: dhclient.c,v 1.21 1996/09/11 18:53:32 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-TIME cur_time;
-TIME default_lease_time = 43200; /* 12 hours... */
-TIME max_lease_time = 86400; /* 24 hours... */
-struct tree_cache *global_options [256];
-
-struct iaddr server_identifier;
-int server_identifier_matched;
-int log_perror = 1;
-
-#ifdef USE_FALLBACK
-struct interface_info fallback_interface;
-#endif
-
-u_int16_t server_port;
-int log_priority;
-
-int lexline, lexchar;
-char *tlname, *token_line;
-
-static void usage PROTO ((void));
-
-int main (argc, argv, envp)
- int argc;
- char **argv, **envp;
-{
- int i;
- struct servent *ent;
- struct interface_info *interface;
-
-#ifdef SYSLOG_4_2
- openlog ("dhclient", LOG_NDELAY);
- log_priority = LOG_DAEMON;
-#else
- openlog ("dhclient", LOG_NDELAY, LOG_DAEMON);
-#endif
-
-#ifndef NO_PUTENV
- /* ensure mktime() calls are processed in UTC */
- putenv("TZ=GMT0");
-#endif /* !NO_PUTENV */
-
-#if !(defined (DEBUG) || defined (SYSLOG_4_2))
- setlogmask (LOG_UPTO (LOG_INFO));
-#endif
-
- for (i = 1; i < argc; i++) {
- if (!strcmp (argv [i], "-p")) {
- if (++i == argc)
- usage ();
- server_port = htons (atoi (argv [i]));
- debug ("binding to user-specified port %d",
- ntohs (server_port));
- } else
- usage ();
- }
-
- /* Default to the DHCP/BOOTP port. */
- if (!server_port)
- {
- ent = getservbyname ("dhcpc", "udp");
- if (!ent)
- server_port = htons (68);
- else
- server_port = ent -> s_port;
- endservent ();
- }
-
- /* Get the current time... */
- GET_TIME (&cur_time);
-
- /* Discover all the network interfaces and initialize them. */
- discover_interfaces (0);
-
- for (interface = interfaces; interface; interface = interface -> next)
- send_discover (interface);
-
- /* Receive packets and dispatch them... */
- dispatch ();
-
- /* Not reached */
- return 0;
-}
-
-static void usage ()
-{
- error ("Usage: dhclient [-p <port>]");
-}
-
-void cleanup ()
-{
-}
-
-int commit_leases ()
-{
- return 0;
-}
-
-int write_lease (lease)
- struct lease *lease;
-{
- return 0;
-}
-
-void db_startup ()
-{
-}
-
-void bootp (packet)
- struct packet *packet;
-{
- note ("BOOTREPLY from %s",
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr));
-}
-
-void dhcp (packet)
- struct packet *packet;
-{
- switch (packet -> packet_type) {
- case DHCPOFFER:
- dhcpoffer (packet);
- break;
-
- case DHCPNAK:
- dhcpnak (packet);
- break;
-
- case DHCPACK:
- dhcpack (packet);
- break;
-
- default:
- break;
- }
-}
-
-void dhcpoffer (packet)
- struct packet *packet;
-{
- note ("DHCPOFFER from %s",
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr));
-
- dump_packet (packet);
- send_request (packet);
-}
-
-void dhcpack (packet)
- struct packet *packet;
-{
- note ("DHCPACK from %s",
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr));
- dump_packet (packet);
-}
-
-void dhcpnak (packet)
- struct packet *packet;
-{
- note ("DHCPNAK from %s",
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr));
-}
-
-static u_int8_t requested_options [] = {
- DHO_DHCP_REQUESTED_ADDRESS,
- DHO_SUBNET_MASK,
- DHO_ROUTERS,
- DHO_DOMAIN_NAME_SERVERS,
- DHO_HOST_NAME,
- DHO_DOMAIN_NAME,
- DHO_BROADCAST_ADDRESS };
-
-void send_discover (interface)
- struct interface_info *interface;
-{
- struct sockaddr_in to;
- int result;
- struct dhcp_packet raw;
- unsigned char discover = DHCPDISCOVER;
- struct packet outgoing;
-
- struct tree_cache *options [256];
- struct tree_cache dhcpdiscover_tree;
- struct tree_cache dhcprqo_tree;
-
- memset (options, 0, sizeof options);
- memset (&outgoing, 0, sizeof outgoing);
- memset (&raw, 0, sizeof raw);
- outgoing.raw = &raw;
-
- /* Set DHCP_MESSAGE_TYPE to DHCPNAK */
- options [DHO_DHCP_MESSAGE_TYPE] = &dhcpdiscover_tree;
- options [DHO_DHCP_MESSAGE_TYPE] -> value = &discover;
- options [DHO_DHCP_MESSAGE_TYPE] -> len = sizeof discover;
- options [DHO_DHCP_MESSAGE_TYPE] -> buf_size = sizeof discover;
- options [DHO_DHCP_MESSAGE_TYPE] -> timeout = 0xFFFFFFFF;
- options [DHO_DHCP_MESSAGE_TYPE] -> tree = (struct tree *)0;
-
- /* Set DHCP_MESSAGE to whatever the message is */
- options [DHO_DHCP_MESSAGE] = &dhcprqo_tree;
- options [DHO_DHCP_MESSAGE] -> value = requested_options;
- options [DHO_DHCP_MESSAGE] -> len = sizeof requested_options;
- options [DHO_DHCP_MESSAGE] -> buf_size = sizeof requested_options;
- options [DHO_DHCP_MESSAGE] -> timeout = 0xFFFFFFFF;
- options [DHO_DHCP_MESSAGE] -> tree = (struct tree *)0;
-
- /* Set up the option buffer... */
- cons_options ((struct packet *)0, &outgoing, options, 0, 0);
-
- memset (&raw.ciaddr, 0, sizeof raw.ciaddr);
- memset (&raw.siaddr, 0, sizeof raw.siaddr);
- memset (&raw.giaddr, 0, sizeof raw.giaddr);
- memcpy (raw.chaddr,
- interface -> hw_address.haddr, interface -> hw_address.hlen);
- raw.hlen = interface -> hw_address.hlen;
- raw.htype = interface -> hw_address.htype;
-
- raw.xid = random ();
- raw.secs = 1;
- raw.flags = htons (BOOTP_BROADCAST);
- raw.hops = 0;
- raw.op = BOOTREQUEST;
-
- /* Report what we're sending... */
- note ("DHCPDISCOVER to %s", interface -> name);
-
-#ifdef DEBUG_PACKET
- dump_packet (&outgoing);
- dump_raw ((unsigned char *)&raw, outgoing.packet_length);
-#endif
-
- /* Set up the common stuff... */
- to.sin_family = AF_INET;
-#ifdef HAVE_SA_LEN
- to.sin_len = sizeof to;
-#endif
- memset (to.sin_zero, 0, sizeof to.sin_zero);
-
- to.sin_addr.s_addr = htonl (INADDR_BROADCAST);
- to.sin_port = htons (ntohs (server_port) - 1); /* XXX */
-
- errno = 0;
- result = send_packet (interface, (struct packet *)0,
- &raw, outgoing.packet_length,
- raw.siaddr, &to, (struct hardware *)0);
- if (result < 0)
- warn ("send_packet: %m");
-}
-
-void send_request (packet)
- struct packet *packet;
-{
- struct sockaddr_in to;
- int result;
- struct dhcp_packet raw;
- unsigned char request = DHCPREQUEST;
- struct packet outgoing;
-
- struct tree_cache *options [256];
- struct tree_cache dhcprequest_tree;
- struct tree_cache dhcprqo_tree;
- struct tree_cache dhcprqa_tree;
- struct tree_cache dhcpsid_tree;
-
- memset (options, 0, sizeof options);
- memset (&outgoing, 0, sizeof outgoing);
- memset (&raw, 0, sizeof raw);
- outgoing.raw = &raw;
-
- /* Set DHCP_MESSAGE_TYPE to DHCPNAK */
- options [DHO_DHCP_MESSAGE_TYPE] = &dhcprequest_tree;
- options [DHO_DHCP_MESSAGE_TYPE] -> value = &request;
- options [DHO_DHCP_MESSAGE_TYPE] -> len = sizeof request;
- options [DHO_DHCP_MESSAGE_TYPE] -> buf_size = sizeof request;
- options [DHO_DHCP_MESSAGE_TYPE] -> timeout = 0xFFFFFFFF;
- options [DHO_DHCP_MESSAGE_TYPE] -> tree = (struct tree *)0;
-
- /* Set DHCP_MESSAGE to whatever the message is */
- options [DHO_DHCP_MESSAGE] = &dhcprqo_tree;
- options [DHO_DHCP_MESSAGE] -> value = requested_options;
- options [DHO_DHCP_MESSAGE] -> len = sizeof requested_options;
- options [DHO_DHCP_MESSAGE] -> buf_size = sizeof requested_options;
- options [DHO_DHCP_MESSAGE] -> timeout = 0xFFFFFFFF;
- options [DHO_DHCP_MESSAGE] -> tree = (struct tree *)0;
-
- /* Request the address we were offered... */
- options [DHO_DHCP_REQUESTED_ADDRESS] = &dhcprqa_tree;
- options [DHO_DHCP_REQUESTED_ADDRESS] -> value =
- (unsigned char *)&packet -> raw -> yiaddr;
- options [DHO_DHCP_REQUESTED_ADDRESS] -> len = 4;
- options [DHO_DHCP_REQUESTED_ADDRESS] -> buf_size = 4;
- options [DHO_DHCP_REQUESTED_ADDRESS] -> timeout = 0xFFFFFFFF;
- options [DHO_DHCP_REQUESTED_ADDRESS] -> tree = (struct tree *)0;
-
- /* Send back the server identifier... */
- options [DHO_DHCP_SERVER_IDENTIFIER] = &dhcpsid_tree;
- options [DHO_DHCP_SERVER_IDENTIFIER] -> value =
- packet -> options [DHO_DHCP_SERVER_IDENTIFIER].data;
- options [DHO_DHCP_SERVER_IDENTIFIER] -> len =
- packet -> options [DHO_DHCP_SERVER_IDENTIFIER].len;
- options [DHO_DHCP_SERVER_IDENTIFIER] -> buf_size =
- packet -> options [DHO_DHCP_SERVER_IDENTIFIER].len;
- options [DHO_DHCP_SERVER_IDENTIFIER] -> timeout = 0xFFFFFFFF;
- options [DHO_DHCP_SERVER_IDENTIFIER] -> tree = (struct tree *)0;
-
- /* Set up the option buffer... */
- cons_options ((struct packet *)0, &outgoing, options, 0, 0);
-
- memset (&raw.ciaddr, 0, sizeof raw.ciaddr);
- raw.siaddr = packet -> raw -> siaddr;
- raw.giaddr = packet -> raw -> giaddr;
- memcpy (raw.chaddr,
- packet -> interface -> hw_address.haddr,
- packet -> interface -> hw_address.hlen);
- raw.hlen = packet -> interface -> hw_address.hlen;
- raw.htype = packet -> interface -> hw_address.htype;
-
- raw.xid = packet -> raw -> xid;
- raw.secs = packet -> raw -> secs;
- raw.flags = htons (BOOTP_BROADCAST);
- raw.hops = packet -> raw -> hops;
- raw.op = BOOTREQUEST;
-
- /* Report what we're sending... */
- note ("DHCPREQUEST to %s", packet -> interface -> name);
-
-#ifdef DEBUG_PACKET
- dump_packet (&outgoing);
- dump_raw ((unsigned char *)&raw, outgoing.packet_length);
-#endif
-
- /* Set up the common stuff... */
- to.sin_family = AF_INET;
-#ifdef HAVE_SA_LEN
- to.sin_len = sizeof to;
-#endif
- memset (to.sin_zero, 0, sizeof to.sin_zero);
-
- to.sin_addr.s_addr = htonl (INADDR_BROADCAST);
- to.sin_port = htons (ntohs (server_port) - 1); /* XXX */
-
- errno = 0;
- result = send_packet (packet -> interface, (struct packet *)0,
- &raw, outgoing.packet_length,
- raw.siaddr, &to, (struct hardware *)0);
- if (result < 0)
- warn ("send_packet: %m");
-}
diff --git a/common/alloc.c b/common/alloc.c
deleted file mode 100644
index dcf4672d..00000000
--- a/common/alloc.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/* alloc.c
-
- Memory allocation... */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: alloc.c,v 1.9 1996/08/28 01:19:42 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-struct dhcp_packet *dhcp_free_list;
-struct packet *packet_free_list;
-
-VOIDPTR dmalloc (size, name)
- int size;
- char *name;
-{
- VOIDPTR foo = (VOIDPTR)malloc (size);
- if (!foo)
- warn ("No memory for %s.", name);
- memset (foo, 0, size);
- return foo;
-}
-
-void dfree (ptr, name)
- VOIDPTR ptr;
- char *name;
-{
- if (!ptr) {
- warn ("dfree %s: free on null pointer.", name);
- return;
- }
- free (ptr);
-}
-
-struct packet *new_packet (name)
- char *name;
-{
- struct packet *rval;
- rval = (struct packet *)dmalloc (sizeof (struct packet), name);
- return rval;
-}
-
-struct dhcp_packet *new_dhcp_packet (name)
- char *name;
-{
- struct dhcp_packet *rval;
- rval = (struct dhcp_packet *)dmalloc (sizeof (struct dhcp_packet),
- name);
- return rval;
-}
-
-struct tree *new_tree (name)
- char *name;
-{
- struct tree *rval = dmalloc (sizeof (struct tree), name);
- return rval;
-}
-
-struct tree_cache *new_tree_cache (name)
- char *name;
-{
- struct tree_cache *rval = dmalloc (sizeof (struct tree_cache), name);
- return rval;
-}
-
-struct hash_table *new_hash_table (count, name)
- int count;
- char *name;
-{
- struct hash_table *rval = dmalloc (sizeof (struct hash_table)
- - (DEFAULT_HASH_SIZE
- * sizeof (struct hash_bucket *))
- + (count
- * sizeof (struct hash_bucket *)),
- name);
- rval -> hash_count = count;
- return rval;
-}
-
-struct hash_bucket *new_hash_bucket (name)
- char *name;
-{
- struct hash_bucket *rval = dmalloc (sizeof (struct hash_bucket), name);
- return rval;
-}
-
-struct lease *new_leases (n, name)
- int n;
- char *name;
-{
- struct lease *rval = dmalloc (n * sizeof (struct lease), name);
- return rval;
-}
-
-struct lease *new_lease (name)
- char *name;
-{
- struct lease *rval = dmalloc (sizeof (struct lease), name);
- return rval;
-}
-
-struct subnet *new_subnet (name)
- char *name;
-{
- struct subnet *rval = dmalloc (sizeof (struct subnet), name);
- return rval;
-}
-
-struct class *new_class (name)
- char *name;
-{
- struct class *rval = dmalloc (sizeof (struct class), name);
- return rval;
-}
-
-struct shared_network *new_shared_network (name)
- char *name;
-{
- struct shared_network *rval =
- dmalloc (sizeof (struct shared_network), name);
- return rval;
-}
-
-struct group *new_group (name)
- char *name;
-{
- struct group *rval =
- dmalloc (sizeof (struct group), name);
- return rval;
-}
-
-void free_group (ptr, name)
- struct group *ptr;
- char *name;
-{
- dfree ((VOIDPTR)ptr, name);
-}
-
-void free_shared_network (ptr, name)
- struct shared_network *ptr;
- char *name;
-{
- dfree ((VOIDPTR)ptr, name);
-}
-
-void free_class (ptr, name)
- struct class *ptr;
- char *name;
-{
- dfree ((VOIDPTR)ptr, name);
-}
-
-void free_subnet (ptr, name)
- struct subnet *ptr;
- char *name;
-{
- dfree ((VOIDPTR)ptr, name);
-}
-
-void free_lease (ptr, name)
- struct lease *ptr;
- char *name;
-{
- dfree ((VOIDPTR)ptr, name);
-}
-
-void free_hash_bucket (ptr, name)
- struct hash_bucket *ptr;
- char *name;
-{
- dfree ((VOIDPTR)ptr, name);
-}
-
-void free_hash_table (ptr, name)
- struct hash_table *ptr;
- char *name;
-{
- dfree ((VOIDPTR)ptr, name);
-}
-
-void free_tree_cache (ptr, name)
- struct tree_cache *ptr;
- char *name;
-{
- dfree ((VOIDPTR)ptr, name);
-}
-
-void free_packet (ptr, name)
- struct packet *ptr;
- char *name;
-{
- dfree ((VOIDPTR)ptr, name);
-}
-
-void free_dhcp_packet (ptr, name)
- struct dhcp_packet *ptr;
- char *name;
-{
- dfree ((VOIDPTR)ptr, name);
-}
-
-void free_tree (ptr, name)
- struct tree *ptr;
- char *name;
-{
- dfree ((VOIDPTR)ptr, name);
-}
diff --git a/common/bpf.c b/common/bpf.c
deleted file mode 100644
index 1ef37958..00000000
--- a/common/bpf.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/* bpf.c
-
- BPF socket interface code, originally contributed by Archie Cobbs. */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: bpf.c,v 1.13 1996/09/02 21:14:58 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE)
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-
-#include <net/bpf.h>
-#ifdef NEED_OSF_PFILT_HACKS
-#include <net/pfilt.h>
-#endif
-#include <netinet/in_systm.h>
-#include "includes/netinet/ip.h"
-#include "includes/netinet/udp.h"
-#include "includes/netinet/if_ether.h"
-
-/* 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_bpf (info, ifp)
- struct interface_info *info;
- struct ifreq *ifp;
-{
- int sock;
- char filename[50];
- int b;
-
- /* Open a BPF device */
- for (b = 0; 1; b++) {
-#ifndef NO_SNPRINTF
- snprintf(filename, sizeof(filename), BPF_FORMAT, b);
-#else
- sprintf(filename, BPF_FORMAT, b);
-#endif
- sock = open (filename, O_RDWR, 0);
- if (sock < 0) {
- if (errno == EBUSY) {
- continue;
- } else {
- error ("Can't find free bpf: %m");
- }
- } else {
- break;
- }
- }
-
- /* Set the BPF device to point at this interface. */
- if (ioctl (sock, BIOCSETIF, ifp) < 0)
- error ("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, interface)
- struct interface_info *info;
- struct ifreq *interface;
-{
- /* 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
- note ("Sending on BPF/%s/%s/%s",
- info -> name,
- print_hw_addr (info -> hw_address.htype,
- info -> hw_address.hlen,
- info -> hw_address.haddr),
- (info -> shared_network ?
- info -> shared_network -> name : "unattached"));
-}
-#endif /* USE_BPF_SEND */
-
-#ifdef USE_BPF_RECEIVE
-/* Packet filter program...
- XXX Changes to the filter program may require changes to the constant
- offsets used in if_register_send to patch the BPF program! XXX */
-
-struct bpf_insn filter [] = {
- /* 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),
-};
-
-void if_register_receive (info, interface)
- struct interface_info *info;
- struct ifreq *interface;
-{
- int flag = 1;
- struct bpf_version v;
- u_int32_t addr;
- struct bpf_program p;
- u_int32_t bits;
-
- /* Open a BPF device and hang it on this interface... */
- info -> rfdesc = if_register_bpf (info, interface);
-
- /* Make sure the BPF version is in range... */
- if (ioctl (info -> rfdesc, BIOCVERSION, &v) < 0)
- error ("Can't get BPF version: %m");
-
- if (v.bv_major != BPF_MAJOR_VERSION ||
- v.bv_minor < BPF_MINOR_VERSION)
- error ("Kernel BPF version out of range - recompile dhcpd!");
-
- /* 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)
- error ("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)
- error ("Can't set ALLOWCOPYALL: %m");
-
- /* Clear all the packet filter mode bits first... */
- bits = 0;
- if (ioctl (info -> rfdesc, EIOCMBIS, &bits) < 0)
- error ("Can't clear pfilt bits: %m");
-
- /* Set the ENBATCH, ENCOPYALL, ENBPFHDR bits... */
- bits = ENBATCH | ENCOPYALL | ENBPFHDR;
- if (ioctl (info -> rfdesc, EIOCMBIS, &bits) < 0)
- error ("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)
- error ("Can't get bpf buffer length: %m");
- info -> rbuf = malloc (info -> rbuf_max);
- if (!info -> rbuf)
- error ("Can't allocate %d bytes for bpf input buffer.");
- info -> rbuf_offset = 0;
- info -> rbuf_len = 0;
-
- /* Set up the bpf filter program structure. */
- p.bf_len = sizeof filter / sizeof (struct bpf_insn);
- p.bf_insns = filter;
-
- /* Patch the server port into the BPF program...
- XXX changes to filter program may require changes
- to the insn number(s) used below! XXX */
- filter [8].k = ntohs (server_port);
-
- if (ioctl (info -> rfdesc, BIOCSETF, &p) < 0)
- error ("Can't install packet filter program: %m");
- note ("Listening on BPF/%s/%s/%s",
- info -> name,
- print_hw_addr (info -> hw_address.htype,
- info -> hw_address.hlen,
- info -> hw_address.haddr),
- (info -> shared_network ?
- info -> shared_network -> name : "unattached"));
-}
-#endif /* USE_BPF_RECEIVE */
-
-#ifdef USE_BPF_SEND
-size_t send_packet (interface, packet, raw, len, from, to, hto)
- struct interface_info *interface;
- struct packet *packet;
- struct dhcp_packet *raw;
- size_t len;
- struct in_addr from;
- struct sockaddr_in *to;
- struct hardware *hto;
-{
- int bufp = 0;
- unsigned char buf [256];
- struct iovec iov [2];
-
- /* Assemble the headers... */
- assemble_hw_header (interface, buf, &bufp, hto);
- assemble_udp_ip_header (interface, buf, &bufp, from.s_addr,
- to -> sin_addr.s_addr, to -> sin_port,
- (unsigned char *)raw, len);
-
- /* Fire it off */
- iov [0].iov_base = (char *)buf;
- iov [0].iov_len = bufp;
- iov [1].iov_base = (char *)raw;
- iov [1].iov_len = len;
-
- return writev(interface -> wfdesc, iov, 2);
-}
-#endif /* USE_BPF_SEND */
-
-#ifdef USE_BPF_RECEIVE
-size_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,
- interface -> rbuf_max);
- if (length <= 0)
- return length;
- interface -> rbuf_offset = 0;
- interface -> rbuf_len = 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 +=
- 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 += 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,
- (unsigned char *)0,
- hdr.bh_caplen);
-
- /* If the IP or UDP checksum was bad, skip the packet... */
- if (offset < 0) {
- interface -> rbuf_offset += hdr.bh_caplen;
- continue;
- }
- 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 += hdr.bh_caplen;
- continue;
- }
-
- /* Copy out the data in the packet... */
- memcpy (buf, interface -> rbuf + interface -> rbuf_offset,
- hdr.bh_caplen);
- interface -> rbuf_offset += hdr.bh_caplen;
- return hdr.bh_caplen;
- } while (!length);
- return 0;
-}
-#endif
diff --git a/common/conflex.c b/common/conflex.c
deleted file mode 100644
index b8b6a195..00000000
--- a/common/conflex.c
+++ /dev/null
@@ -1,468 +0,0 @@
-/* conflex.c
-
- Lexical scanner for dhcpd config file... */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: conflex.c,v 1.19 1996/09/09 07:04:28 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-#include "dhctoken.h"
-#include <ctype.h>
-
-int lexline;
-int lexchar;
-char *token_line;
-char *prev_line;
-char *cur_line;
-char *tlname;
-
-static char line1 [81];
-static char line2 [81];
-static int lpos;
-static int line;
-static int tlpos;
-static int tline;
-static int token;
-static int ugflag;
-static char *tval;
-static char tokbuf [1500];
-
-#ifdef OLD_LEXER
-char comments [4096];
-int comment_index;
-#endif
-
-
-static int get_char PROTO ((FILE *));
-static int get_token PROTO ((FILE *));
-static void skip_to_eol PROTO ((FILE *));
-static int read_string PROTO ((FILE *));
-static int read_number PROTO ((int, FILE *));
-static int read_num_or_name PROTO ((int, FILE *));
-static int intern PROTO ((char *, int));
-
-void new_parse (name)
- char *name;
-{
- tlname = name;
- lpos = line = 1;
- cur_line = line1;
- prev_line = line2;
- token_line = cur_line;
- cur_line [0] = prev_line [0] = 0;
- warnings_occurred = 0;
-}
-
-static int get_char (cfile)
- FILE *cfile;
-{
- int c = getc (cfile);
- if (!ugflag) {
- if (c == EOL) {
- if (cur_line == line1) {
- cur_line = line2;
- prev_line = line1;
- } else {
- cur_line = line2;
- prev_line = line1;
- }
- line++;
- lpos = 1;
- cur_line [0] = 0;
- } else if (c != EOF) {
- if (lpos <= 81) {
- cur_line [lpos - 1] = c;
- cur_line [lpos] = 0;
- }
- lpos++;
- }
- } else
- ugflag = 0;
- return c;
-}
-
-static int get_token (cfile)
- FILE *cfile;
-{
- int c;
- int ttok;
- static char tb [2];
- int l, p, u;
-
- do {
- l = line;
- p = lpos;
- u = ugflag;
-
- c = get_char (cfile);
-#ifdef OLD_LEXER
- if (c == '\n' && p == 1 && !u
- && comment_index < sizeof comments)
- comments [comment_index++] = '\n';
-#endif
-
- if (isascii (c) && isspace (c))
- continue;
- if (c == '#') {
-#ifdef OLD_LEXER
- if (comment_index < sizeof comments)
- comments [comment_index++] = '#';
-#endif
- skip_to_eol (cfile);
- continue;
- }
- if (c == '"') {
- lexline = l;
- lexchar = p;
- ttok = read_string (cfile);
- break;
- }
- if ((isascii (c) && isdigit (c)) || c == '-') {
- lexline = l;
- lexchar = p;
- ttok = read_number (c, cfile);
- break;
- } else if (isascii (c) && isalpha (c)) {
- lexline = l;
- lexchar = p;
- ttok = read_num_or_name (c, cfile);
- break;
- } else {
- lexline = l;
- lexchar = p;
- tb [0] = c;
- tb [1] = 0;
- tval = tb;
- ttok = c;
- break;
- }
- } while (1);
- return ttok;
-}
-
-int next_token (rval, cfile)
- char **rval;
- FILE *cfile;
-{
- int rv;
-
- if (token) {
- if (lexline != tline)
- token_line = cur_line;
- lexchar = tlpos;
- lexline = tline;
- rv = token;
- token = 0;
- } else {
- rv = get_token (cfile);
- token_line = cur_line;
- }
- if (rval)
- *rval = tval;
-#ifdef DEBUG_TOKENS
- fprintf (stderr, "%s:%d ", tval, rv);
-#endif
- return rv;
-}
-
-int peek_token (rval, cfile)
- char **rval;
- FILE *cfile;
-{
- int x;
-
- if (!token) {
- tlpos = lexchar;
- tline = lexline;
- token = get_token (cfile);
- if (lexline != tline)
- token_line = prev_line;
- x = lexchar; lexchar = tlpos; tlpos = x;
- x = lexline; lexline = tline; tline = x;
- }
- if (rval)
- *rval = tval;
-#ifdef DEBUG_TOKENS
- fprintf (stderr, "(%s:%d) ", tval, token);
-#endif
- return token;
-}
-
-static void skip_to_eol (cfile)
- FILE *cfile;
-{
- int c;
- do {
- c = get_char (cfile);
- if (c == EOF)
- return;
-#ifdef OLD_LEXER
- if (comment_index < sizeof (comments))
- comments [comment_index++] = c;
-#endif
- if (c == EOL) {
- return;
- }
- } while (1);
-}
-
-static int read_string (cfile)
- FILE *cfile;
-{
- int i;
- int bs = 0;
- int c;
-
- for (i = 0; i < sizeof tokbuf; i++) {
- c = get_char (cfile);
- if (c == EOF) {
- parse_warn ("eof in string constant");
- break;
- }
- if (bs) {
- bs = 0;
- tokbuf [i] = c;
- } else if (c == '\\')
- bs = 1;
- else if (c == '"')
- break;
- else
- 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 tokbuf) {
- parse_warn ("string constant larger than internal buffer");
- --i;
- }
- tokbuf [i] = 0;
- tval = tokbuf;
- return STRING;
-}
-
-static int read_number (c, cfile)
- int c;
- FILE *cfile;
-{
- int seenx = 0;
- int i = 0;
- int token = NUMBER;
-
- tokbuf [i++] = c;
- for (; i < sizeof 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)) {
- ungetc (c, cfile);
- ugflag = 1;
- break;
- }
- tokbuf [i] = c;
- }
- if (i == sizeof tokbuf) {
- parse_warn ("numeric token larger than internal buffer");
- --i;
- }
- tokbuf [i] = 0;
- tval = tokbuf;
- return token;
-}
-
-static int read_num_or_name (c, cfile)
- int c;
- FILE *cfile;
-{
- int i = 0;
- int rv = NUMBER_OR_NAME;
- tokbuf [i++] = c;
- for (; i < sizeof tokbuf; i++) {
- c = get_char (cfile);
- if (!isascii (c) ||
- (c != '-' && c != '_' && !isalnum (c))) {
- ungetc (c, cfile);
- ugflag = 1;
- break;
- }
- if (!isxdigit (c))
- rv = NAME;
- tokbuf [i] = c;
- }
- if (i == sizeof tokbuf) {
- parse_warn ("token larger than internal buffer");
- --i;
- }
- tokbuf [i] = 0;
- tval = tokbuf;
- return intern (tval, rv);
-}
-
-static int intern (atom, dfv)
- char *atom;
- int dfv;
-{
- if (!isascii (atom [0]))
- return dfv;
-
- switch (tolower (atom [0])) {
- case 'b':
- if (!strcasecmp (atom + 1, "oot-unknown-clients"))
- return BOOT_UNKNOWN_CLIENTS;
- case 'c':
- if (!strcasecmp (atom + 1, "lass"))
- return CLASS;
- if (!strcasecmp (atom + 1, "iaddr"))
- return CIADDR;
- break;
- case 'd':
- if (!strcasecmp (atom + 1, "efault-lease-time"))
- return DEFAULT_LEASE_TIME;
- if (!strncasecmp (atom + 1, "ynamic-bootp", 12)) {
- if (!atom [13])
- return DYNAMIC_BOOTP;
- else if (!strcasecmp (atom + 13, "-lease-cutoff"))
- return DYNAMIC_BOOTP_LEASE_CUTOFF;
- else if (!strcasecmp (atom + 13, "-lease-length"))
- return DYNAMIC_BOOTP_LEASE_LENGTH;
- }
- break;
- case 'e':
- if (!strcasecmp (atom + 1, "thernet"))
- return ETHERNET;
- if (!strcasecmp (atom + 1, "nds"))
- return ENDS;
- break;
- case 'f':
- if (!strcasecmp (atom + 1, "ilename"))
- return FILENAME;
- if (!strcasecmp (atom + 1, "ixed-address"))
- return FIXED_ADDR;
- 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, "ost"))
- return HOST;
- if (!strcasecmp (atom + 1, "ardware"))
- return HARDWARE;
- break;
- case 'l':
- if (!strcasecmp (atom + 1, "ease"))
- return LEASE;
- break;
- case 'm':
- if (!strcasecmp (atom + 1, "ax-lease-time"))
- return MAX_LEASE_TIME;
- break;
- case 'n':
- if (!strcasecmp (atom + 1, "etmask"))
- return NETMASK;
- if (!strcasecmp (atom + 1, "ext-server"))
- return NEXT_SERVER;
- break;
- case 'o':
- if (!strcasecmp (atom + 1, "ption"))
- return OPTION;
- if (!strcasecmp (atom + 1, "ne-lease-per-client"))
- return ONE_LEASE_PER_CLIENT;
- break;
- case 'p':
- if (!strcasecmp (atom + 1, "acket"))
- return PACKET;
- break;
- case 'r':
- if (!strcasecmp (atom + 1, "ange"))
- return RANGE;
- break;
- case 's':
- if (!strcasecmp (atom + 1, "tarts"))
- return STARTS;
- if (!strcasecmp (atom + 1, "iaddr"))
- return SIADDR;
- if (!strcasecmp (atom + 1, "ubnet"))
- return SUBNET;
- if (!strcasecmp (atom + 1, "hared-network"))
- return SHARED_NETWORK;
- if (!strcasecmp (atom + 1, "erver-name"))
- return SERVER_NAME;
- if (!strcasecmp (atom + 1, "erver-identifier"))
- return SERVER_IDENTIFIER;
- break;
- case 't':
- if (!strcasecmp (atom + 1, "imestamp"))
- return TIMESTAMP;
- if (!strcasecmp (atom + 1, "oken-ring"))
- return TOKEN_RING;
- break;
- case 'u':
- if (!strcasecmp (atom + 1, "id"))
- return UID;
- if (!strcasecmp (atom + 1, "ser-class"))
- return USER_CLASS;
- if (!strcasecmp (atom + 1, "se-host-decl-names"))
- return USE_HOST_DECL_NAMES;
- break;
- case 'v':
- if (!strcasecmp (atom + 1, "endor-class"))
- return VENDOR_CLASS;
- break;
- case 'y':
- if (!strcasecmp (atom + 1, "iaddr"))
- return YIADDR;
- break;
- }
- return dfv;
-}
diff --git a/common/convert.c b/common/convert.c
deleted file mode 100644
index 64f3f15c..00000000
--- a/common/convert.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/* convert.c
-
- Safe copying of option values into and out of the option buffer, which
- can't be assumed to be aligned. */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: convert.c,v 1.3 1996/08/27 09:41:28 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-u_int32_t getULong (buf)
- unsigned char *buf;
-{
- unsigned long ibuf;
-
- memcpy (&ibuf, buf, sizeof (u_int32_t));
- return ntohl (ibuf);
-}
-
-int32_t getLong (buf)
- unsigned char *buf;
-{
- long ibuf;
-
- memcpy (&ibuf, buf, sizeof (int32_t));
- return ntohl (ibuf);
-}
-
-u_int16_t getUShort (buf)
- unsigned char *buf;
-{
- unsigned short ibuf;
-
- memcpy (&ibuf, buf, sizeof (u_int16_t));
- return ntohs (ibuf);
-}
-
-int16_t getShort (buf)
- unsigned char *buf;
-{
- short ibuf;
-
- memcpy (&ibuf, buf, sizeof (int16_t));
- return ntohs (ibuf);
-}
-
-void putULong (obuf, val)
- unsigned char *obuf;
- u_int32_t val;
-{
- u_int32_t tmp = htonl (val);
- memcpy (obuf, &tmp, sizeof tmp);
-}
-
-void putLong (obuf, val)
- unsigned char *obuf;
- int32_t val;
-{
- int32_t tmp = htonl (val);
- memcpy (obuf, &tmp, sizeof tmp);
-}
-
-void putUShort (obuf, val)
- unsigned char *obuf;
- u_int16_t val;
-{
- u_int16_t tmp = htonl (val);
- memcpy (obuf, &tmp, sizeof tmp);
-}
-
-void putShort (obuf, val)
- unsigned char *obuf;
- int16_t val;
-{
- int16_t tmp = htonl (val);
- memcpy (obuf, &tmp, sizeof tmp);
-}
-
diff --git a/common/dispatch.c b/common/dispatch.c
deleted file mode 100644
index 1985fb4e..00000000
--- a/common/dispatch.c
+++ /dev/null
@@ -1,503 +0,0 @@
-/* dispatch.c
-
- Network input dispatcher... */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: dispatch.c,v 1.27 1996/11/08 20:06:29 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-#include <sys/ioctl.h>
-
-struct interface_info *interfaces;
-
-static void got_one PROTO ((struct interface_info *));
-
-/* 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 (serverP)
- int serverP;
-{
- struct interface_info *tmp;
- struct interface_info *last;
- char buf [8192];
- 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;
-#ifdef ALIAS_NAMES_PERMUTED
- char *s;
-#endif
-#ifdef USE_FALLBACK
- static struct shared_network fallback_network;
-#endif
-
- /* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */
- if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
- error ("Can't create addrlist socket");
-
- /* Get the interface configuration information... */
- ic.ifc_len = sizeof buf;
- ic.ifc_ifcu.ifcu_buf = (caddr_t)buf;
- i = ioctl(sock, SIOCGIFCONF, &ic);
-
- if (i < 0)
- error ("ioctl: SIOCGIFCONF: %m");
-
- if (interfaces)
- ir = 0;
- else
- ir = INTERFACE_REQUESTED;
-
- /* Cycle through the list of interfaces looking for IP addresses.
- Go through twice; once to count the number if addresses, and a
- second time to copy them into an array of addresses. */
- for (i = 0; i < ic.ifc_len;) {
- struct ifreq *ifp = (struct ifreq *)((caddr_t)ic.ifc_req + i);
-#ifdef HAVE_SA_LEN
- i += (sizeof ifp -> ifr_name) + ifp -> ifr_addr.sa_len;
-#else
- i += sizeof *ifp;
-#endif
-
-#ifdef ALIAS_NAMES_PERMUTED
- if ((s = strrchr (ifp -> ifr_name, ':'))) {
- *s = 0;
- }
-#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)
- error ("Can't get interface flags for %s: %m",
- ifr.ifr_name);
-
- /* Skip loopback, point-to-point and down interfaces. */
- if ((ifr.ifr_flags & IFF_LOOPBACK) ||
- (ifr.ifr_flags & IFF_POINTOPOINT) ||
- !(ifr.ifr_flags & IFF_UP))
- continue;
-
- /* 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;
-
- /* If there isn't already an interface by this name,
- allocate one. */
- if (!tmp) {
- tmp = ((struct interface_info *)
- dmalloc (sizeof *tmp, "get_interface_list"));
- if (!tmp)
- error ("Insufficient memory to %s %s",
- "record interface", ifp -> ifr_name);
- strcpy (tmp -> name, ifp -> ifr_name);
- tmp -> next = interfaces;
- tmp -> flags = ir;
- interfaces = tmp;
- }
-
- /* If we have the capability, extract link information
- and record it in a linked list. */
-#ifdef AF_LINK
- if (ifp -> ifr_addr.sa_family == AF_LINK) {
- struct sockaddr_dl *foo = ((struct sockaddr_dl *)
- (&ifp -> ifr_addr));
- tmp -> hw_address.hlen = foo -> sdl_alen;
- tmp -> hw_address.htype = HTYPE_ETHER; /* XXX */
- memcpy (tmp -> hw_address.haddr,
- LLADDR (foo), foo -> sdl_alen);
- } 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))
- 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 -> tif)
- tmp -> tif = ifp;
-
- /* Grab the address... */
- addr.len = 4;
- memcpy (addr.iabuf, &foo.sin_addr.s_addr,
- addr.len);
-
- /* If this address matches the server identifier,
- make a note of it. */
- if (addr_eq (addr, server_identifier))
- server_identifier_matched = 1;
-
- /* If there's a registered subnet for this address,
- connect it together... */
- if ((subnet = find_subnet (addr))) {
- /* If this interface has multiple aliases
- on the same subnet, ignore all but the
- first we encounter. */
- if (!subnet -> interface) {
- subnet -> interface = tmp;
- subnet -> interface_address = addr;
- } else if (subnet -> interface != tmp) {
- warn ("Multiple %s %s: %s %s",
- "interfaces match the",
- "same subnet",
- subnet -> interface -> name,
- tmp -> name);
- }
- share = subnet -> shared_network;
- if (tmp -> shared_network &&
- tmp -> shared_network != share) {
- warn ("Interface %s matches %s",
- tmp -> name,
- "multiple shared networks");
- } else {
- tmp -> shared_network = share;
- }
-
- if (!share -> interface) {
- share -> interface = tmp;
- } else if (share -> interface != tmp) {
- warn ("Multiple %s %s: %s %s",
- "interfaces match the",
- "same shared network",
- share -> interface -> name,
- tmp -> name);
- }
- }
- }
- }
-
- /* Weed out the interfaces that did not have IP addresses. */
- last = (struct interface_info *)0;
- for (tmp = interfaces; tmp; tmp = tmp -> next) {
- if (!tmp -> tif || !(tmp -> flags & INTERFACE_REQUESTED)) {
- if ((tmp -> flags & INTERFACE_REQUESTED) != ir)
- error ("%s: not found", tmp -> name);
- if (!last)
- interfaces = interfaces -> next;
- else
- last -> next = tmp -> next;
- continue;
- }
- last = tmp;
-
- memcpy (&foo, &tmp -> tif -> ifr_addr,
- sizeof tmp -> tif -> ifr_addr);
-
- /* We must have a subnet declaration for each interface. */
- if (!tmp -> shared_network && serverP)
- error ("No subnet declaration for %s (%s).",
- tmp -> name, inet_ntoa (foo.sin_addr));
-
- /* 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);
- }
- }
-
- /* If a server identifier wasn't specified, take it
- from the first IP address we see... */
- if (!server_identifier.len) {
- if (address_count > 1)
- warn ("no server identifier specified.");
- server_identifier.len = 4;
- memcpy (server_identifier.iabuf,
- &foo.sin_addr.s_addr, 4);
- /* Flag the server identifier as having matched,
- so we don't generate a spurious warning. */
- server_identifier_matched = 1;
- }
-
-
- /* Register the interface... */
- if_register_receive (tmp, tmp -> tif);
- if_register_send (tmp, tmp -> tif);
-
- tmp -> tif = (struct ifreq *)0; /* Can't keep this. */
- }
- if (!server_identifier_matched && serverP)
- warn ("no interface address matches server identifier");
-
- close (sock);
-
-#ifdef USE_FALLBACK
- strcpy (fallback_interface.name, "fallback");
- fallback_interface.shared_network = &fallback_network;
- fallback_network.name = "fallback-net";
- if_register_fallback (&fallback_interface, (struct ifreq *)0);
-#endif
-}
-
-#ifdef USE_POLL
-/* Wait for packets to come in using poll(). Anyway, when a packet
- comes in, call receive_packet to receive the packet and possibly
- strip hardware addressing information from it, and then call
- do_packet to try to do something with it.
-
- As you can see by comparing this with the code that uses select(),
- below, this is gratuitously complex. Quelle surprise, eh? This is
- SysV we're talking about, after all, and even in the 90's, it
- wouldn't do for SysV to make networking *easy*, would it? Rant,
- rant... */
-
-void dispatch ()
-{
- struct interface_info *l;
- int nfds = 0;
- struct pollfd *fds;
- int count;
- int i;
-
- nfds = 0;
- for (l = interfaces; l; l = l -> next) {
- ++nfds;
- }
-#ifdef USE_FALLBACK
- ++nfds;
-#endif
- fds = (struct pollfd *)malloc ((nfds) * sizeof (struct pollfd));
- if (!fds)
- error ("Can't allocate poll structures.");
-
- i = 0;
- for (l = interfaces; l; l = l -> next) {
- fds [i].fd = l -> rfdesc;
- fds [i].events = POLLIN;
- fds [i].revents = 0;
- ++i;
- }
-
-#ifdef USE_FALLBACK
- fds [i].fd = fallback_interface.wfdesc;
- fds [i].events = POLLIN;
- fds [i].revents = 0;
- ++i;
-#endif
-
- do {
- /* Wait for a packet or a timeout... XXX */
- count = poll (fds, nfds, -1);
-
- /* Get the current time... */
- GET_TIME (&cur_time);
-
- /* Not likely to be transitory... */
- if (count < 0)
- error ("poll: %m");
-
- i = 0;
- for (l = interfaces; l; l = l -> next) {
- if ((fds [i].revents & POLLIN)) {
- fds [i].revents = 0;
- got_one (l);
- }
- ++i;
- }
-#ifdef USE_FALLBACK
- if (fds [i].revents & POLLIN)
- fallback_discard (&fallback_interface);
-#endif
- } while (1);
-}
-#else
-/* Wait for packets to come in using select(). When one does, call
- receive_packet to receive the packet and possibly strip hardware
- addressing information from it, and then call do_packet to try to
- do something with it. */
-
-void dispatch ()
-{
- fd_set r, w, x;
- struct interface_info *l;
- int max = 0;
- int count;
-
- FD_ZERO (&r);
- FD_ZERO (&w);
- FD_ZERO (&x);
-
- do {
- /* Set up the read mask. */
- for (l = interfaces; l; l = l -> next) {
- FD_SET (l -> rfdesc, &r);
- FD_SET (l -> rfdesc, &x);
- if (l -> rfdesc > max)
- max = l -> rfdesc;
- }
-#ifdef USE_FALLBACK
- FD_SET (fallback_interface.wfdesc, &r);
- if (fallback_interface.wfdesc > max)
- max = fallback_interface.wfdesc;
-#endif
-
- /* Wait for a packet or a timeout... XXX */
- count = select (max + 1, &r, &w, &x, (struct timeval *)0);
-
- /* Get the current time... */
- GET_TIME (&cur_time);
-
- /* Not likely to be transitory... */
- if (count < 0)
- error ("select: %m");
-
- for (l = interfaces; l; l = l -> next) {
- if (!FD_ISSET (l -> rfdesc, &r))
- continue;
- got_one (l);
- }
-#ifdef USE_FALLBACK
- if (FD_ISSET (fallback_interface.wfdesc, &r))
- fallback_discard (&fallback_interface);
-#endif
- } while (1);
-}
-#endif /* USE_POLL */
-
-static void got_one (l)
- struct interface_info *l;
-{
- struct sockaddr_in from;
- struct hardware hfrom;
- struct iaddr ifrom;
- int result;
- static unsigned char packbuf [4095]; /* Packet input buffer.
- Must be as large as largest
- possible MTU. */
-
- if ((result = receive_packet (l, packbuf, sizeof packbuf,
- &from, &hfrom)) < 0) {
- warn ("receive_packet failed on %s: %m", l -> name);
- return;
- }
- if (result == 0)
- return;
-
- ifrom.len = 4;
- memcpy (ifrom.iabuf, &from.sin_addr, ifrom.len);
-
- do_packet (l, packbuf, result,
- from.sin_port, ifrom, &hfrom);
-}
-
-void do_packet (interface, packbuf, len, from_port, from, hfrom)
- struct interface_info *interface;
- unsigned char *packbuf;
- int len;
- unsigned short from_port;
- struct iaddr from;
- struct hardware *hfrom;
-{
- struct packet tp;
- struct dhcp_packet tdp;
-
- memcpy (&tdp, packbuf, len);
- memset (&tp, 0, sizeof tp);
- tp.raw = &tdp;
- tp.packet_length = len;
- tp.client_port = from_port;
- tp.client_addr = from;
- tp.interface = interface;
- tp.haddr = hfrom;
-
- parse_options (&tp);
- if (tp.options_valid &&
- tp.options [DHO_DHCP_MESSAGE_TYPE].data)
- tp.packet_type =
- tp.options [DHO_DHCP_MESSAGE_TYPE].data [0];
- if (tp.packet_type)
- dhcp (&tp);
- else if (tdp.op == BOOTREQUEST)
- bootp (&tp);
-}
-
-int locate_network (packet)
- struct packet *packet;
-{
- struct iaddr ia;
-
- /* If this came through a gateway, find the corresponding subnet... */
- if (packet -> raw -> giaddr.s_addr) {
- struct subnet *subnet;
- ia.len = 4;
- memcpy (ia.iabuf, &packet -> raw -> giaddr, 4);
- subnet = find_subnet (ia);
- if (subnet)
- packet -> shared_network = subnet -> shared_network;
- else
- packet -> shared_network = (struct shared_network *)0;
- } else {
- packet -> shared_network =
- packet -> interface -> shared_network;
- }
- if (packet -> shared_network)
- return 1;
- return 0;
-}
diff --git a/common/errwarn.c b/common/errwarn.c
deleted file mode 100644
index 34f965a0..00000000
--- a/common/errwarn.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/* errwarn.c
-
- Errors and warnings... */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium.
- * All Rights Reserved.
- * Copyright (c) 1995 RadioMail Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of RadioMail Corporation, the Internet Software
- * Consortium nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RADIOMAIL CORPORATION, THE INTERNET
- * SOFTWARE CONSORTIUM AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL RADIOMAIL CORPORATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software was written for RadioMail Corporation by Ted Lemon
- * under a contract with Vixie Enterprises. Further modifications have
- * been made for the Internet Software Consortium under a contract
- * with Vixie Laboratories.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: errwarn.c,v 1.12 1996/11/08 20:07:31 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-#include <errno.h>
-
-static void do_percentm PROTO ((char *obuf, char *ibuf));
-
-static char mbuf [1024];
-static char fbuf [1024];
-
-int warnings_occurred;
-
-/* Log an error message, then exit... */
-
-void error (ANSI_DECL(char *) fmt, VA_DOTDOTDOT)
- KandR (char *fmt;)
- va_dcl
-{
- va_list list;
- extern int logged_in;
-
- do_percentm (fbuf, fmt);
-
- VA_start (list, fmt);
- vsnprintf (mbuf, sizeof mbuf, fbuf, list);
- va_end (list);
-
-#ifndef DEBUG
- syslog (log_priority | LOG_ERR, mbuf);
-#endif
-
- /* Also log it to stderr? */
- if (log_perror) {
- write (2, mbuf, strlen (mbuf));
- write (2, "\n", 1);
- }
-
- cleanup ();
- exit (1);
-}
-
-/* Log a warning message... */
-
-int warn (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
- KandR (char *fmt;)
- va_dcl
-{
- va_list list;
-
- do_percentm (fbuf, fmt);
-
- VA_start (list, fmt);
- vsnprintf (mbuf, sizeof mbuf, fbuf, list);
- va_end (list);
-
-#ifndef DEBUG
- syslog (log_priority | LOG_ERR, mbuf);
-#endif
-
- if (log_perror) {
- write (2, mbuf, strlen (mbuf));
- write (2, "\n", 1);
- }
-
- return 0;
-}
-
-/* Log a note... */
-
-int note (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
- KandR (char *fmt;)
- va_dcl
-{
- va_list list;
-
- do_percentm (fbuf, fmt);
-
- VA_start (list, fmt);
- vsnprintf (mbuf, sizeof mbuf, fbuf, list);
- va_end (list);
-
-#ifndef DEBUG
- syslog (log_priority | LOG_INFO, mbuf);
-#endif
-
- if (log_perror) {
- write (2, mbuf, strlen (mbuf));
- write (2, "\n", 1);
- }
-
- return 0;
-}
-
-/* Log a debug message... */
-
-int debug (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
- KandR (char *fmt;)
- va_dcl
-{
- va_list list;
-
- do_percentm (fbuf, fmt);
-
- VA_start (list, fmt);
- vsnprintf (mbuf, sizeof mbuf, fbuf, list);
- va_end (list);
-
-#ifndef DEBUG
- syslog (log_priority | LOG_DEBUG, mbuf);
-#endif
-
- if (log_perror) {
- write (2, mbuf, strlen (mbuf));
- write (2, "\n", 1);
- }
-
- return 0;
-}
-
-/* Find %m in the input string and substitute an error message string. */
-
-static void do_percentm (obuf, ibuf)
- char *obuf;
- char *ibuf;
-{
- char *s = ibuf;
- char *p = obuf;
- int infmt = 0;
-
- while (*s)
- {
- if (infmt)
- {
- if (*s == 'm')
- {
- strcpy (p - 1, strerror (errno));
- p += strlen (p);
- ++s;
- }
- else
- *p++ = *s++;
- infmt = 0;
- }
- else
- {
- if (*s == '%')
- infmt = 1;
- *p++ = *s++;
- }
- }
- *p = 0;
-}
-
-
-int parse_warn (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
- KandR (char *fmt;)
- va_dcl
-{
- va_list list;
- static char spaces [] = " ";
-
- do_percentm (mbuf, fmt);
-#ifndef NO_SNPRINTF
- snprintf (fbuf, sizeof fbuf, "%s line %d: %s",
- tlname, lexline, mbuf);
-#else
- sprintf (fbuf, "%s line %d: %s",
- tlname, lexline, mbuf);
-#endif
-
- VA_start (list, fmt);
- vsnprintf (mbuf, sizeof mbuf, fbuf, list);
- va_end (list);
-
-#ifndef DEBUG
- syslog (log_priority | LOG_ERR, mbuf);
- syslog (log_priority | LOG_ERR, token_line);
- if (lexline < 81)
- syslog (log_priority | LOG_ERR,
- "%s^", &spaces [sizeof spaces - lexchar]);
-#endif
-
- if (log_perror) {
- write (2, mbuf, strlen (mbuf));
- write (2, "\n", 1);
- write (2, token_line, strlen (token_line));
- write (2, "\n", 1);
- write (2, spaces, lexchar - 1);
- write (2, "^\n", 2);
- }
-
- warnings_occurred = 1;
-
- return 0;
-}
-
-#ifdef NO_STRERROR
-char *strerror (err)
- int err;
-{
- extern char *sys_errlist [];
- extern int sys_nerr;
- static char errbuf [128];
-
- if (err < 0 || err >= sys_nerr) {
- sprintf (errbuf, "Error %d", err);
- return errbuf;
- }
- return sys_errlist [err];
-}
-#endif /* NO_STRERROR */
diff --git a/common/hash.c b/common/hash.c
deleted file mode 100644
index e8e93752..00000000
--- a/common/hash.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/* hash.c
-
- Routines for manipulating hash tables... */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: hash.c,v 1.9 1996/09/09 07:04:45 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-static INLINE int do_hash PROTO ((char *, int, int));
-
-struct hash_table *new_hash ()
-{
- struct hash_table *rv = new_hash_table (DEFAULT_HASH_SIZE, "new_hash");
- if (!rv)
- return rv;
- memset (&rv -> buckets [0], 0,
- DEFAULT_HASH_SIZE * sizeof (struct hash_bucket *));
- return rv;
-}
-
-static INLINE int do_hash (name, len, size)
- char *name;
- int len;
- int size;
-{
- register int accum = 0;
- register unsigned char *s = (unsigned char *)name;
- int i = len;
- if (i) {
- while (i--) {
- /* Add the character in... */
- accum += *s++;
- /* Add carry back in... */
- while (accum > 255) {
- accum = (accum & 255) + (accum >> 8);
- }
- }
- } else {
- while (*s) {
- /* Add the character in... */
- accum += *s++;
- /* Add carry back in... */
- while (accum > 255) {
- accum = (accum & 255) + (accum >> 8);
- }
- }
- }
- return accum % size;
-}
-
-void add_hash (table, name, len, pointer)
- struct hash_table *table;
- int len;
- char *name;
- unsigned char *pointer;
-{
- int hashno;
- struct hash_bucket *bp;
-
- if (!table)
- return;
-
- hashno = do_hash (name, len, table -> hash_count);
- bp = new_hash_bucket ("add_hash");
-
- if (!bp) {
- warn ("Can't add %s to hash table.", name);
- return;
- }
- bp -> name = name;
- bp -> value = pointer;
- bp -> next = table -> buckets [hashno];
- bp -> len = len;
- table -> buckets [hashno] = bp;
-}
-
-void delete_hash_entry (table, name, len)
- struct hash_table *table;
- int len;
- char *name;
-{
- int hashno;
- struct hash_bucket *bp, *pbp = (struct hash_bucket *)0;
-
- if (!table)
- return;
-
- hashno = do_hash (name, len, table -> hash_count);
-
- /* Go through the list looking for an entry that matches;
- if we find it, delete it. */
- for (bp = table -> buckets [hashno]; bp; bp = bp -> next) {
- if ((!bp -> len && !strcmp (bp -> name, name)) ||
- (bp -> len == len &&
- !memcmp (bp -> name, name, len))) {
- if (pbp) {
- pbp -> next = bp -> next;
- } else {
- table -> buckets [hashno] = bp -> next;
- }
- free_hash_bucket (bp, "delete_hash_entry");
- break;
- }
- pbp = bp; /* jwg, 9/6/96 - nice catch! */
- }
-}
-
-unsigned char *hash_lookup (table, name, len)
- struct hash_table *table;
- char *name;
- int len;
-{
- int hashno;
- struct hash_bucket *bp;
-
- if (!table)
- return (unsigned char *)0;
- hashno = do_hash (name, len, table -> hash_count);
-
- if (len) {
- for (bp = table -> buckets [hashno]; bp; bp = bp -> next) {
- if (len == bp -> len
- && !memcmp (bp -> name, name, len))
- return bp -> value;
- }
- } else {
- for (bp = table -> buckets [hashno]; bp; bp = bp -> next)
- if (!strcmp (bp -> name, name))
- return bp -> value;
- }
- return (unsigned char *)0;
-}
-
diff --git a/common/inet.c b/common/inet.c
deleted file mode 100644
index 000d9718..00000000
--- a/common/inet.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* inet.c
-
- Subroutines to manipulate internet addresses in a safely portable
- way... */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#include "dhcpd.h"
-
-/* Return just the network number of an internet address... */
-
-struct iaddr subnet_number (addr, mask)
- struct iaddr addr;
- struct iaddr mask;
-{
- int i;
- struct iaddr rv;
-
- rv.len = 0;
-
- /* Both addresses must have the same length... */
- if (addr.len != mask.len)
- return rv;
-
- rv.len = addr.len;
- for (i = 0; i < rv.len; i++)
- rv.iabuf [i] = addr.iabuf [i] & mask.iabuf [i];
- return rv;
-}
-
-/* Combine a network number and a integer to produce an internet address.
- This won't work for subnets with more than 32 bits of host address, but
- maybe this isn't a problem. */
-
-struct iaddr ip_addr (subnet, mask, host_address)
- struct iaddr subnet;
- struct iaddr mask;
- u_int32_t host_address;
-{
- int i, j, k;
- u_int32_t swaddr;
- struct iaddr rv;
- unsigned char habuf [sizeof swaddr];
-
- swaddr = htonl (host_address);
- memcpy (habuf, &swaddr, sizeof swaddr);
-
- /* Combine the subnet address and the host address. If
- the host address is bigger than can fit in the subnet,
- return a zero-length iaddr structure. */
- rv = subnet;
- j = rv.len - sizeof habuf;
- for (i = sizeof habuf - 1; i >= 0; i--) {
- if (mask.iabuf [i + j]) {
- if (habuf [i] > (mask.iabuf [i + j] ^ 0xFF)) {
- rv.len = 0;
- return rv;
- }
- for (k = i - 1; k >= 0; k--) {
- if (habuf [k]) {
- rv.len = 0;
- return rv;
- }
- }
- rv.iabuf [i + j] |= habuf [i];
- break;
- } else
- rv.iabuf [i + j] = habuf [i];
- }
-
- return rv;
-}
-
-u_int32_t host_addr (addr, mask)
- struct iaddr addr;
- struct iaddr mask;
-{
- int i;
- u_int32_t swaddr;
- struct iaddr rv;
-
- rv.len = 0;
-
- /* Mask out the network bits... */
- rv.len = addr.len;
- for (i = 0; i < rv.len; i++)
- rv.iabuf [i] = addr.iabuf [i] & ~mask.iabuf [i];
-
- /* Copy out up to 32 bits... */
- memcpy (&swaddr, &rv.iabuf [rv.len - sizeof swaddr], sizeof swaddr);
-
- /* Swap it and return it. */
- return ntohl (swaddr);
-}
-
-int addr_eq (addr1, addr2)
- struct iaddr addr1, addr2;
-{
- if (addr1.len != addr2.len)
- return 0;
- return memcmp (addr1.iabuf, addr2.iabuf, addr1.len) == 0;
-}
-
-char *piaddr (addr)
- struct iaddr addr;
-{
- static char pbuf [4 * 16];
- char *s = pbuf;
- int i;
-
- if (addr.len == 0) {
- strcpy (s, "<null address>");
- }
- for (i = 0; i < addr.len; i++) {
- sprintf (s, "%s%d", i ? "." : "", addr.iabuf [i]);
- s += strlen (s);
- }
- return pbuf;
-}
diff --git a/common/memory.c b/common/memory.c
deleted file mode 100644
index 6f7617c2..00000000
--- a/common/memory.c
+++ /dev/null
@@ -1,873 +0,0 @@
-/* memory.c
-
- Memory-resident database... */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: memory.c,v 1.22 1996/11/08 20:09:10 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-static struct subnet *subnets;
-static struct shared_network *shared_networks;
-static struct hash_table *host_hw_addr_hash;
-static struct hash_table *host_uid_hash;
-static struct hash_table *lease_uid_hash;
-static struct hash_table *lease_ip_addr_hash;
-static struct hash_table *lease_hw_addr_hash;
-static struct lease *dangling_leases;
-
-static struct hash_table *vendor_class_hash;
-static struct hash_table *user_class_hash;
-
-void enter_host (hd)
- struct host_decl *hd;
-{
- struct host_decl *hp = (struct host_decl *)0;
- struct host_decl *np = (struct host_decl *)0;
-
- hd -> n_ipaddr = (struct host_decl *)0;
-
- if (hd -> interface.hlen) {
- if (!host_hw_addr_hash)
- host_hw_addr_hash = new_hash ();
- else
- hp = (struct host_decl *)
- hash_lookup (host_hw_addr_hash,
- hd -> interface.haddr,
- hd -> interface.hlen);
-
- /* If there isn't already a host decl matching this
- address, add it to the hash table. */
- if (!hp)
- add_hash (host_hw_addr_hash,
- hd -> interface.haddr, hd -> interface.hlen,
- (unsigned char *)hd);
- }
-
- /* If there was already a host declaration for this hardware
- address, add this one to the end of the list. */
-
- if (hp) {
- for (np = hp; np -> n_ipaddr; np = np -> n_ipaddr)
- ;
- np -> n_ipaddr = hd;
- }
-
- if (hd -> group -> options [DHO_DHCP_CLIENT_IDENTIFIER]) {
- if (!tree_evaluate (hd -> group -> options
- [DHO_DHCP_CLIENT_IDENTIFIER]))
- return;
-
- /* If there's no uid hash, make one; otherwise, see if
- there's already an entry in the hash for this host. */
- if (!host_uid_hash) {
- host_uid_hash = new_hash ();
- hp = (struct host_decl *)0;
- } else
- hp = (struct host_decl *) hash_lookup
- (host_uid_hash,
- hd -> group -> options
- [DHO_DHCP_CLIENT_IDENTIFIER] -> value,
- hd -> group -> options
- [DHO_DHCP_CLIENT_IDENTIFIER] -> len);
-
- /* If there's already a host declaration for this
- client identifier, add this one to the end of the
- list. Otherwise, add it to the hash table. */
- if (hp) {
- /* Don't link it in twice... */
- if (!np) {
- for (np = hp; np -> n_ipaddr;
- np = np -> n_ipaddr)
- ;
- np -> n_ipaddr = hd;
- }
- } else {
- add_hash (host_uid_hash,
- hd -> group -> options
- [DHO_DHCP_CLIENT_IDENTIFIER] -> value,
- hd -> group -> options
- [DHO_DHCP_CLIENT_IDENTIFIER] -> len,
- (unsigned char *)hd);
- }
- }
-}
-
-struct host_decl *find_hosts_by_haddr (htype, haddr, hlen)
- int htype;
- unsigned char *haddr;
- int hlen;
-{
- struct host_decl *foo;
-
- foo = (struct host_decl *)hash_lookup (host_hw_addr_hash,
- haddr, hlen);
- return foo;
-}
-
-struct host_decl *find_hosts_by_uid (data, len)
- unsigned char *data;
- int len;
-{
- struct host_decl *foo;
-
- foo = (struct host_decl *)hash_lookup (host_uid_hash, data, len);
- return foo;
-}
-
-/* More than one host_decl can be returned by find_hosts_by_haddr or
- find_hosts_by_uid, and each host_decl can have multiple addresses.
- Loop through the list of hosts, and then for each host, through the
- list of addresses, looking for an address that's in the same shared
- network as the one specified. Store the matching address through
- the addr pointer, update the host pointer to point at the host_decl
- that matched, and return the subnet that matched. */
-
-struct subnet *find_host_for_network (host, addr, share)
- struct host_decl **host;
- struct iaddr *addr;
- struct shared_network *share;
-{
- int i;
- struct subnet *subnet;
- struct iaddr ip_address;
- struct host_decl *hp;
-
- for (hp = *host; hp; hp = hp -> n_ipaddr) {
- if (!hp -> fixed_addr || !tree_evaluate (hp -> fixed_addr))
- continue;
- for (i = 0; i < hp -> fixed_addr -> len; i += 4) {
- ip_address.len = 4;
- memcpy (ip_address.iabuf,
- hp -> fixed_addr -> value + i, 4);
- subnet = find_grouped_subnet (share, ip_address);
- if (subnet) {
- *addr = ip_address;
- *host = hp;
- return subnet;
- }
- }
- }
- return (struct subnet *)0;
-}
-
-void new_address_range (low, high, subnet, dynamic)
- struct iaddr low, high;
- struct subnet *subnet;
- int dynamic;
-{
- struct lease *address_range, *lp, *plp;
- struct iaddr net;
- int min, max, i;
- char lowbuf [16], highbuf [16], netbuf [16];
- struct shared_network *share = subnet -> shared_network;
- struct hostent *h;
- struct in_addr ia;
-
- /* All subnets should have attached shared network structures. */
- if (!share) {
- strcpy (netbuf, piaddr (subnet -> net));
- error ("No shared network for network %s (%s)",
- netbuf, piaddr (subnet -> netmask));
- }
-
- /* Initialize the hash table if it hasn't been done yet. */
- if (!lease_uid_hash)
- lease_uid_hash = new_hash ();
- if (!lease_ip_addr_hash)
- lease_ip_addr_hash = new_hash ();
- if (!lease_hw_addr_hash)
- lease_hw_addr_hash = new_hash ();
-
- /* Make sure that high and low addresses are in same subnet. */
- net = subnet_number (low, subnet -> netmask);
- if (!addr_eq (net, subnet_number (high, subnet -> netmask))) {
- strcpy (lowbuf, piaddr (low));
- strcpy (highbuf, piaddr (high));
- strcpy (netbuf, piaddr (subnet -> netmask));
- error ("Address range %s to %s, netmask %s spans %s!",
- lowbuf, highbuf, netbuf, "multiple subnets");
- }
-
- /* Get the high and low host addresses... */
- max = host_addr (high, subnet -> netmask);
- min = host_addr (low, subnet -> netmask);
-
- /* Allow range to be specified high-to-low as well as low-to-high. */
- if (min > max) {
- max = min;
- min = host_addr (high, subnet -> netmask);
- }
-
- /* Get a lease structure for each address in the range. */
- address_range = new_leases (max - min + 1, "new_address_range");
- if (!address_range) {
- strcpy (lowbuf, piaddr (low));
- strcpy (highbuf, piaddr (high));
- error ("No memory for address range %s-%s.", lowbuf, highbuf);
- }
- memset (address_range, 0, (sizeof *address_range) * (max - min + 1));
-
- /* Fill in the last lease if it hasn't been already... */
- if (!share -> last_lease) {
- share -> last_lease = &address_range [0];
- }
-
- /* Fill out the lease structures with some minimal information. */
- for (i = 0; i < max - min + 1; i++) {
- address_range [i].ip_addr =
- ip_addr (subnet -> net, subnet -> netmask, i + min);
- address_range [i].starts =
- address_range [i].timestamp = MIN_TIME;
- address_range [i].ends = MIN_TIME;
- address_range [i].subnet = subnet;
- address_range [i].shared_network = share;
- address_range [i].flags = dynamic ? DYNAMIC_BOOTP_OK : 0;
-
- memcpy (&ia, address_range [i].ip_addr.iabuf, 4);
-
- if (subnet -> group -> get_lease_hostnames) {
- h = gethostbyaddr ((char *)&ia, sizeof ia, AF_INET);
- if (!h)
- warn ("No hostname for %s", inet_ntoa (ia));
- else {
- address_range [i].hostname =
- malloc (strlen (h -> h_name) + 1);
- if (!address_range [i].hostname)
- error ("no memory for hostname %s.",
- h -> h_name);
- strcpy (address_range [i].hostname,
- h -> h_name);
- }
- }
-
- /* Link this entry into the list. */
- address_range [i].next = share -> leases;
- address_range [i].prev = (struct lease *)0;
- share -> leases = &address_range [i];
- if (address_range [i].next)
- address_range [i].next -> prev = share -> leases;
- add_hash (lease_ip_addr_hash,
- address_range [i].ip_addr.iabuf,
- address_range [i].ip_addr.len,
- (unsigned char *)&address_range [i]);
- }
-
- /* Find out if any dangling leases are in range... */
- plp = (struct lease *)0;
- for (lp = dangling_leases; lp; lp = lp -> next) {
- struct iaddr lnet;
- int lhost;
-
- lnet = subnet_number (lp -> ip_addr, subnet -> netmask);
- lhost = host_addr (lp -> ip_addr, subnet -> netmask);
-
- /* If it's in range, fill in the real lease structure with
- the dangling lease's values, and remove the lease from
- the list of dangling leases. */
- if (addr_eq (lnet, subnet -> net) &&
- lhost >= i && lhost <= max) {
- if (plp) {
- plp -> next = lp -> next;
- } else {
- dangling_leases = lp -> next;
- }
- lp -> next = (struct lease *)0;
- supersede_lease (&address_range [lhost - i], lp, 0);
- free_lease (lp, "new_address_range");
- } else
- plp = lp;
- }
-}
-
-struct subnet *find_subnet (addr)
- struct iaddr addr;
-{
- struct subnet *rv;
-
- for (rv = subnets; rv; rv = rv -> next_subnet) {
- if (addr_eq (subnet_number (addr, rv -> netmask), rv -> net))
- return rv;
- }
- return (struct subnet *)0;
-}
-
-struct subnet *find_grouped_subnet (share, addr)
- struct shared_network *share;
- struct iaddr addr;
-{
- struct subnet *rv;
-
- for (rv = share -> subnets; rv; rv = rv -> next_sibling) {
- if (addr_eq (subnet_number (addr, rv -> netmask), rv -> net))
- return rv;
- }
- return (struct subnet *)0;
-}
-
-/* Enter a new subnet into the subnet list. */
-
-void enter_subnet (subnet)
- struct subnet *subnet;
-{
- struct subnet *scan;
-
- /* Check for duplicates... */
- for (scan = subnets; scan; scan = scan -> next_subnet) {
- if (addr_eq (subnet_number (subnet -> net, scan -> netmask),
- scan -> net) ||
- addr_eq (subnet_number (scan -> net, subnet -> netmask),
- subnet -> net)) {
- char n1buf [16];
- int i, j;
- for (i = 0; i < 32; i++)
- if (subnet -> netmask.iabuf [3 - (i >> 3)]
- & (1 << (i & 7)))
- break;
- for (j = 0; j < 32; j++)
- if (scan -> netmask.iabuf [3 - (j >> 3)]
- & (1 << (j & 7)))
- break;
- strcpy (n1buf, piaddr (subnet -> net));
- error ("subnet %s/%d conflicts with subnet %s/%d",
- n1buf, i, piaddr (scan -> net), j);
- }
- }
-
- /* XXX Sort the nets into a balanced tree to make searching quicker. */
- subnet -> next_subnet = subnets;
- subnets = subnet;
-}
-
-/* Enter a new shared network into the shared network list. */
-
-void enter_shared_network (share)
- struct shared_network *share;
-{
- /* XXX Sort the nets into a balanced tree to make searching quicker. */
- share -> next = shared_networks;
- shared_networks = share;
-}
-
-/* Enter a lease into the system. This is called by the parser each
- time it reads in a new lease. If the subnet for that lease has
- already been read in (usually the case), just update that lease;
- otherwise, allocate temporary storage for the lease and keep it around
- until we're done reading in the config file. */
-
-void enter_lease (lease)
- struct lease *lease;
-{
- struct lease *comp = find_lease_by_ip_addr (lease -> ip_addr);
-
- /* If we don't have a place for this lease yet, save it for
- later. */
- if (!comp) {
- comp = new_lease ("enter_lease");
- if (!comp) {
- error ("No memory for lease %s\n",
- piaddr (lease -> ip_addr));
- }
- *comp = *lease;
- lease -> next = dangling_leases;
- lease -> prev = (struct lease *)0;
- dangling_leases = lease;
- } else {
- supersede_lease (comp, lease, 0);
- }
-}
-
-/* Replace the data in an existing lease with the data in a new lease;
- adjust hash tables to suit, and insertion sort the lease into the
- list of leases by expiry time so that we can always find the oldest
- lease. */
-
-int supersede_lease (comp, lease, commit)
- struct lease *comp, *lease;
- int commit;
-{
- int enter_uid = 0;
- int enter_hwaddr = 0;
- struct lease *lp;
-
- /* Static leases are not currently kept in the database... */
- if (lease -> flags & STATIC_LEASE)
- return 1;
-
- /* If the existing lease hasn't expired and has a different
- unique identifier or, if it doesn't have a unique
- identifier, a different hardware address, then the two
- leases are in conflict. If the existing lease has a uid
- and the new one doesn't, but they both have the same
- hardware address, and dynamic bootp is allowed on this
- lease, then we allow that, in case a dynamic BOOTP lease is
- requested *after* a DHCP lease has been assigned. */
-
- if (comp -> ends > cur_time &&
- ((comp -> uid && (lease -> uid ||
- !(lease -> flags & DYNAMIC_BOOTP_OK)) &&
- (comp -> uid_len != lease -> uid_len ||
- memcmp (comp -> uid, lease -> uid, comp -> uid_len))) ||
- (!comp -> uid &&
- ((comp -> hardware_addr.htype !=
- lease -> hardware_addr.htype) ||
- (comp -> hardware_addr.hlen !=
- lease -> hardware_addr.hlen) ||
- memcmp (comp -> hardware_addr.haddr,
- lease -> hardware_addr.haddr,
- comp -> hardware_addr.hlen))))) {
- warn ("Lease conflict at %s",
- piaddr (comp -> ip_addr));
- return 0;
- } else {
- /* If there's a Unique ID, dissociate it from the hash
- table if necessary, and always free it. */
- if (comp -> uid) {
- if (comp -> uid != lease -> uid) {
- uid_hash_delete (comp);
- enter_uid = 1;
- free (comp -> uid);
- comp -> uid = (unsigned char *)0;
- }
- } else
- enter_uid = 1;
-
- if (comp -> hardware_addr.htype &&
- ((comp -> hardware_addr.hlen !=
- lease -> hardware_addr.hlen) ||
- (comp -> hardware_addr.htype !=
- lease -> hardware_addr.htype) ||
- memcmp (comp -> hardware_addr.haddr,
- lease -> hardware_addr.haddr,
- comp -> hardware_addr.hlen))) {
- hw_hash_delete (comp);
- enter_hwaddr = 1;
- } else if (!comp -> hardware_addr.htype)
- enter_hwaddr = 1;
-
- /* Copy the data files, but not the linkages. */
- comp -> starts = lease -> starts;
- comp -> offered_expiry = lease -> offered_expiry;
- comp -> timestamp = lease -> timestamp;
- comp -> uid = lease -> uid;
- comp -> uid_len = lease -> uid_len;
- comp -> host = lease -> host;
- comp -> hardware_addr = lease -> hardware_addr;
- comp -> state = lease -> state;
- comp -> flags = ((lease -> flags & ~PERSISTENT_FLAGS) |
- (comp -> flags & ~EPHEMERAL_FLAGS));
-
- /* Record the lease in the uid hash if necessary. */
- if (enter_uid && lease -> uid) {
- uid_hash_add (comp);
- }
-
- /* Record it in the hardware address hash if necessary. */
- if (enter_hwaddr && lease -> hardware_addr.htype) {
- hw_hash_add (comp);
- }
-
- /* Remove the lease from its current place in the
- timeout sequence. */
- if (comp -> prev) {
- comp -> prev -> next = comp -> next;
- } else {
- comp -> shared_network -> leases = comp -> next;
- }
- if (comp -> next) {
- comp -> next -> prev = comp -> prev;
- }
- if (comp -> shared_network -> last_lease == comp) {
- comp -> shared_network -> last_lease = comp -> prev;
- }
-
- /* Find the last insertion point... */
- if (comp == comp -> shared_network -> insertion_point ||
- !comp -> shared_network -> insertion_point) {
- lp = comp -> shared_network -> leases;
- } else {
- lp = comp -> shared_network -> insertion_point;
- }
-
- if (!lp) {
- /* Nothing on the list yet? Just make comp the
- head of the list. */
- comp -> shared_network -> leases = comp;
- comp -> shared_network -> last_lease = comp;
- } else if (lp -> ends > lease -> ends) {
- /* Skip down the list until we run out of list
- or find a place for comp. */
- while (lp -> next && lp -> ends > lease -> ends) {
- lp = lp -> next;
- }
- if (lp -> ends > lease -> ends) {
- /* If we ran out of list, put comp
- at the end. */
- lp -> next = comp;
- comp -> prev = lp;
- comp -> next = (struct lease *)0;
- comp -> shared_network -> last_lease = comp;
- } else {
- /* If we didn't, put it between lp and
- the previous item on the list. */
- if ((comp -> prev = lp -> prev))
- comp -> prev -> next = comp;
- comp -> next = lp;
- lp -> prev = comp;
- }
- } else {
- /* Skip up the list until we run out of list
- or find a place for comp. */
- while (lp -> prev && lp -> ends < lease -> ends) {
- lp = lp -> prev;
- }
- if (lp -> ends < lease -> ends) {
- /* If we ran out of list, put comp
- at the beginning. */
- lp -> prev = comp;
- comp -> next = lp;
- comp -> prev = (struct lease *)0;
- comp -> shared_network -> leases = comp;
- } else {
- /* If we didn't, put it between lp and
- the next item on the list. */
- if ((comp -> next = lp -> next))
- comp -> next -> prev = comp;
- comp -> prev = lp;
- lp -> next = comp;
- }
- }
- comp -> shared_network -> insertion_point = comp;
- comp -> ends = lease -> ends;
- }
-
- /* Return zero if we didn't commit the lease to permanent storage;
- nonzero if we did. */
- return commit && write_lease (comp) && commit_leases ();
-}
-
-/* Release the specified lease and re-hash it as appropriate. */
-
-void release_lease (lease)
- struct lease *lease;
-{
- struct lease lt;
-
- lt = *lease;
- lt.ends = cur_time;
- supersede_lease (lease, &lt, 1);
-}
-
-/* Abandon the specified lease (set its timeout to infinity and its
- particulars to zero, and re-hash it as appropriate. */
-
-void abandon_lease (lease)
- struct lease *lease;
-{
- struct lease lt;
-
- lt = *lease;
- lt.ends = 0xFFFFFFFF;
- warn ("Abandoning IP address %s\n",
- piaddr (lease -> ip_addr));
- lt.hardware_addr.htype = -1;
- lt.hardware_addr.hlen = 0;
- lt.uid = (unsigned char *)0;
- lt.uid_len = 0;
- supersede_lease (lease, &lt, 1);
-}
-
-/* Locate the lease associated with a given IP address... */
-
-struct lease *find_lease_by_ip_addr (addr)
- struct iaddr addr;
-{
- struct lease *lease = (struct lease *)hash_lookup (lease_ip_addr_hash,
- addr.iabuf,
- addr.len);
- return lease;
-}
-
-struct lease *find_lease_by_uid (uid, len)
- unsigned char *uid;
- int len;
-{
- struct lease *lease = (struct lease *)hash_lookup (lease_uid_hash,
- uid, len);
- return lease;
-}
-
-struct lease *find_lease_by_hw_addr (hwaddr, hwlen)
- unsigned char *hwaddr;
- int hwlen;
-{
- struct lease *lease = (struct lease *)hash_lookup (lease_hw_addr_hash,
- hwaddr, hwlen);
- return lease;
-}
-
-/* Add the specified lease to the uid hash. */
-
-void uid_hash_add (lease)
- struct lease *lease;
-{
- struct lease *head =
- find_lease_by_uid (lease -> uid, lease -> uid_len);
- struct lease *scan;
-
-#ifdef DEBUG
- if (lease -> n_uid)
- abort ();
-#endif
-
- /* If it's not in the hash, just add it. */
- if (!head)
- add_hash (lease_uid_hash, lease -> uid,
- lease -> uid_len, (unsigned char *)lease);
- else {
- /* Otherwise, attach it to the end of the list. */
- for (scan = head; scan -> n_uid; scan = scan -> n_uid)
-#ifdef DEBUG
- if (scan == lease)
- abort ()
-#endif
- ;
- scan -> n_uid = lease;
- }
-}
-
-/* Delete the specified lease from the uid hash. */
-
-void uid_hash_delete (lease)
- struct lease *lease;
-{
- struct lease *head =
- find_lease_by_uid (lease -> uid, lease -> uid_len);
- struct lease *scan;
-
- /* If it's not in the hash, we have no work to do. */
- if (!head) {
- lease -> n_uid = (struct lease *)0;
- return;
- }
-
- /* If the lease we're freeing is at the head of the list,
- remove the hash table entry and add a new one with the
- next lease on the list (if there is one). */
- if (head == lease) {
- delete_hash_entry (lease_uid_hash,
- lease -> uid, lease -> uid_len);
- if (lease -> n_uid)
- add_hash (lease_uid_hash,
- lease -> n_uid -> uid,
- lease -> n_uid -> uid_len,
- (unsigned char *)(lease -> n_uid));
- } else {
- /* Otherwise, look for the lease in the list of leases
- attached to the hash table entry, and remove it if
- we find it. */
- for (scan = head; scan -> n_uid; scan = scan -> n_uid) {
- if (scan -> n_uid == lease) {
- scan -> n_uid = scan -> n_uid -> n_uid;
- break;
- }
- }
- }
- lease -> n_uid = (struct lease *)0;
-}
-
-/* Add the specified lease to the hardware address hash. */
-
-void hw_hash_add (lease)
- struct lease *lease;
-{
- struct lease *head =
- find_lease_by_hw_addr (lease -> hardware_addr.haddr,
- lease -> hardware_addr.hlen);
- struct lease *scan;
-
- /* If it's not in the hash, just add it. */
- if (!head)
- add_hash (lease_hw_addr_hash,
- lease -> hardware_addr.haddr,
- lease -> hardware_addr.hlen,
- (unsigned char *)lease);
- else {
- /* Otherwise, attach it to the end of the list. */
- for (scan = head; scan -> n_hw; scan = scan -> n_hw)
- ;
- scan -> n_hw = lease;
- }
-}
-
-/* Delete the specified lease from the hardware address hash. */
-
-void hw_hash_delete (lease)
- struct lease *lease;
-{
- struct lease *head =
- find_lease_by_hw_addr (lease -> hardware_addr.haddr,
- lease -> hardware_addr.hlen);
- struct lease *scan;
-
- /* If it's not in the hash, we have no work to do. */
- if (!head) {
- lease -> n_hw = (struct lease *)0;
- return;
- }
-
- /* If the lease we're freeing is at the head of the list,
- remove the hash table entry and add a new one with the
- next lease on the list (if there is one). */
- if (head == lease) {
- delete_hash_entry (lease_hw_addr_hash,
- lease -> hardware_addr.haddr,
- lease -> hardware_addr.hlen);
- if (lease -> n_hw)
- add_hash (lease_hw_addr_hash,
- lease -> n_hw -> hardware_addr.haddr,
- lease -> n_hw -> hardware_addr.hlen,
- (unsigned char *)(lease -> n_hw));
- } else {
- /* Otherwise, look for the lease in the list of leases
- attached to the hash table entry, and remove it if
- we find it. */
- for (scan = head; scan -> n_hw; scan = scan -> n_hw) {
- if (scan -> n_hw == lease) {
- scan -> n_hw = scan -> n_hw -> n_hw;
- break;
- }
- }
- }
- lease -> n_hw = (struct lease *)0;
-}
-
-
-struct class *add_class (type, name)
- int type;
- char *name;
-{
- struct class *class = new_class ("add_class");
- char *tname = (char *)malloc (strlen (name) + 1);
-
- if (!vendor_class_hash)
- vendor_class_hash = new_hash ();
- if (!user_class_hash)
- user_class_hash = new_hash ();
-
- if (!tname || !class || !vendor_class_hash || !user_class_hash)
- return (struct class *)0;
-
- memset (class, 0, sizeof *class);
- strcpy (tname, name);
- class -> name = tname;
-
- if (type)
- add_hash (user_class_hash,
- tname, strlen (tname), (unsigned char *)class);
- else
- add_hash (user_class_hash,
- tname, strlen (tname), (unsigned char *)class);
- return class;
-}
-
-struct class *find_class (type, name, len)
- int type;
- char *name;
- int len;
-{
- struct class *class =
- (struct class *)hash_lookup (type
- ? user_class_hash
- : vendor_class_hash, name, len);
- return class;
-}
-
-struct group *clone_group (group, caller)
- struct group *group;
- char *caller;
-{
- struct group *g = new_group (caller);
- if (!g)
- error ("%s: can't allocate new group", caller);
- *g = *group;
- return g;
-}
-
-/* Write all interesting leases to permanent storage. */
-
-void write_leases ()
-{
- struct lease *l;
- struct shared_network *s;
-
- for (s = shared_networks; s; s = s -> next) {
- for (l = s -> leases; l; l = l -> next) {
- if (l -> hardware_addr.hlen || l -> uid_len)
- if (!write_lease (l))
- error ("Can't rewrite lease database");
- }
- }
- if (!commit_leases ())
- error ("Can't commit leases to new database: %m");
-}
-
-void dump_subnets ()
-{
- struct lease *l;
- struct shared_network *s;
- struct subnet *n;
-
- for (s = shared_networks; s; s = s -> next) {
- for (n = subnets; n; n = n -> next_sibling) {
- debug ("Subnet %s", piaddr (n -> net));
- debug (" netmask %s",
- piaddr (n -> netmask));
- }
- for (l = s -> leases; l; l = l -> next) {
- print_lease (l);
- }
- debug ("Last Lease:");
- print_lease (s -> last_lease);
- }
-}
diff --git a/common/nit.c b/common/nit.c
deleted file mode 100644
index 43fa7e49..00000000
--- a/common/nit.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/* nit.c
-
- Network Interface Tap (NIT) network interface code, by Ted Lemon
- with one crucial tidbit of help from Stu Grossmen. */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''. */
-
-#ifndef lint
-static char copyright[] =
-"$Id: nit.c,v 1.9 1996/09/05 23:56:52 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-#if defined (USE_NIT_SEND) || defined (USE_NIT_RECEIVE)
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-
-#include <sys/time.h>
-#include <net/nit.h>
-#include <net/nit_if.h>
-#include <net/nit_pf.h>
-#include <net/nit_buf.h>
-#include <sys/stropts.h>
-#include <net/packetfilt.h>
-
-#include <netinet/in_systm.h>
-#include "includes/netinet/ip.h"
-#include "includes/netinet/udp.h"
-#include "includes/netinet/if_ether.h"
-
-/* 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_nit (info, ifp)
- struct interface_info *info;
- struct ifreq *ifp;
-{
- int sock;
- char filename[50];
- struct ifreq ifr;
- struct strioctl sio;
-
- /* Open a NIT device */
- sock = open ("/dev/nit", O_RDWR);
- if (sock < 0)
- error ("Can't open NIT device for %s: %m", info -> name);
-
- /* Set the NIT device to point at this interface. */
- sio.ic_cmd = NIOCBIND;
- sio.ic_len = sizeof *ifp;
- sio.ic_dp = (char *)ifp;
- sio.ic_timout = INFTIM;
- if (ioctl (sock, I_STR, &sio) < 0)
- error ("Can't attach interface %s to nit device: %m",
- info -> name);
-
- /* Get the low-level address... */
- sio.ic_cmd = SIOCGIFADDR;
- sio.ic_len = sizeof ifr;
- sio.ic_dp = (char *)&ifr;
- sio.ic_timout = INFTIM;
- if (ioctl (sock, I_STR, &sio) < 0)
- error ("Can't get physical layer address for %s: %m",
- info -> name);
-
- /* XXX code below assumes ethernet interface! */
- info -> hw_address.hlen = 6;
- info -> hw_address.htype = ARPHRD_ETHER;
- memcpy (info -> hw_address.haddr, ifr.ifr_ifru.ifru_addr.sa_data, 6);
-
- if (ioctl (sock, I_PUSH, "pf") < 0)
- error ("Can't push packet filter onto NIT for %s: %m",
- info -> name);
-
- return sock;
-}
-#endif /* USE_NIT_SEND || USE_NIT_RECEIVE */
-
-#ifdef USE_NIT_SEND
-void if_register_send (info, interface)
- struct interface_info *info;
- struct ifreq *interface;
-{
- /* If we're using the nit API for sending and receiving,
- we don't need to register this interface twice. */
-#ifndef USE_NIT_RECEIVE
- struct packetfilt pf;
- struct strioctl sio;
-
- info -> wfdesc = if_register_nit (info, interface);
-
- pf.Pf_Priority = 0;
- pf.Pf_FilterLen = 1;
- pf.Pf_Filter [0] = ENF_PUSHZERO;
-
- /* Set up an NIT filter that rejects everything... */
- sio.ic_cmd = NIOCSETF;
- sio.ic_len = sizeof pf;
- sio.ic_dp = (char *)&pf;
- sio.ic_timout = INFTIM;
- if (ioctl (info -> wfdesc, I_STR, &sio) < 0)
- error ("Can't set NIT filter: %m");
-#else
- info -> wfdesc = info -> rfdesc;
-#endif
- note ("Sending on NIT/%s/%s",
- print_hw_addr (info -> hw_address.htype,
- info -> hw_address.hlen,
- info -> hw_address.haddr),
- (info -> shared_network ?
- info -> shared_network -> name : "unattached"));
-}
-#endif /* USE_NIT_SEND */
-
-#ifdef USE_NIT_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, interface)
- struct interface_info *info;
- struct ifreq *interface;
-{
- int flag = 1;
- u_int32_t x;
- struct packetfilt pf;
- struct strioctl sio;
- u_int16_t addr [2];
- struct timeval t;
-
- /* Open a NIT device and hang it on this interface... */
- info -> rfdesc = if_register_nit (info, interface);
-
- /* Set the snap length to 0, which means always take the whole
- packet. */
- x = 0;
- if (ioctl (info -> rfdesc, NIOCSSNAP, &x) < 0)
- error ("Can't set NIT snap length on %s: %m", info -> name);
-
- /* Set the stream to byte stream mode */
- if (ioctl (info -> rfdesc, I_SRDOPT, RMSGN) != 0)
- note ("I_SRDOPT failed on %s: %m", info -> name);
-
-#if 0
- /* Push on the chunker... */
- if (ioctl (info -> rfdesc, I_PUSH, "nbuf") < 0)
- error ("Can't push chunker onto NIT STREAM: %m");
-
- /* Set the timeout to zero. */
- t.tv_sec = 0;
- t.tv_usec = 0;
- if (ioctl (info -> rfdesc, NIOCSTIME, &t) < 0)
- error ("Can't set chunk timeout: %m");
-#endif
-
- /* Ask for no header... */
- x = 0;
- if (ioctl (info -> rfdesc, NIOCSFLAGS, &x) < 0)
- error ("Can't set NIT flags on %s: %m", info -> name);
-
- /* Set up the NIT 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;
-
- pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 6;
- pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
- pf.Pf_Filter [pf.Pf_FilterLen++] = htons (ETHERTYPE_IP);
- pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT;
- pf.Pf_Filter [pf.Pf_FilterLen++] = htons (IPPROTO_UDP);
- pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 11;
- pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_AND;
- pf.Pf_Filter [pf.Pf_FilterLen++] = htons (0xFF);
- pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_CAND;
- pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 18;
- pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
- pf.Pf_Filter [pf.Pf_FilterLen++] = server_port;
-
- /* Install the filter... */
- sio.ic_cmd = NIOCSETF;
- sio.ic_len = sizeof pf;
- sio.ic_dp = (char *)&pf;
- sio.ic_timout = INFTIM;
- if (ioctl (info -> rfdesc, I_STR, &sio) < 0)
- error ("Can't set NIT filter on %s: %m", info -> name);
-
- note ("Listening on NIT/%s/%s",
- print_hw_addr (info -> hw_address.htype,
- info -> hw_address.hlen,
- info -> hw_address.haddr),
- (info -> shared_network ?
- info -> shared_network -> name : "unattached"));
-}
-#endif /* USE_NIT_RECEIVE */
-
-#ifdef USE_NIT_SEND
-size_t send_packet (interface, packet, raw, len, from, to, hto)
- struct interface_info *interface;
- struct packet *packet;
- struct dhcp_packet *raw;
- size_t len;
- struct in_addr from;
- struct sockaddr_in *to;
- struct hardware *hto;
-{
- int bufp;
- unsigned char buf [1536 + sizeof (struct sockaddr)];
- struct sockaddr *junk;
- struct strbuf ctl, data;
- int hw_end;
- struct sockaddr_in foo;
-
- /* Start with the sockaddr struct... */
- junk = (struct sockaddr *)&buf [0];
- bufp = ((unsigned char *)&junk -> sa_data [0]) - &buf [0];
-
- /* Assemble the headers... */
- assemble_hw_header (interface, buf, &bufp, hto);
- hw_end = bufp;
- assemble_udp_ip_header (interface, buf, &bufp, from.s_addr,
- to -> sin_addr.s_addr, to -> sin_port,
- raw, len);
-
- /* Copy the data into the buffer (yuk). */
- memcpy (buf + bufp, raw, len);
-
- /* Set up the sockaddr structure... */
-#if USE_SIN_LEN
- junk -> sa_len = hw_end - 2; /* XXX */
-#endif
- junk -> sa_family = AF_UNSPEC;
-
-#if 0 /* Already done. */
- memcpy (junk.sa_data, buf, hw_len);
-#endif
-
- /* Set up the msg_buf structure... */
- ctl.buf = (char *)&buf [0];
- ctl.maxlen = ctl.len = hw_end;
- data.buf = (char *)&buf [hw_end];
- data.maxlen = data.len = bufp + len - hw_end;
-
- return putmsg (interface -> wfdesc, &ctl, &data, 0);
-}
-#endif /* USE_NIT_SEND */
-
-#ifdef USE_NIT_RECEIVE
-size_t receive_packet (interface, buf, len, from, hfrom)
- struct interface_info *interface;
- unsigned char *buf;
- size_t len;
- struct sockaddr_in *from;
- struct hardware *hfrom;
-{
- int nread;
- int length = 0;
- int offset = 0;
- unsigned char ibuf [1536];
- int bufix = 0;
-
- length = read (interface -> rfdesc, ibuf, sizeof ibuf);
- if (length <= 0)
- return length;
-
- /* Decode the physical header... */
- offset = decode_hw_header (interface, ibuf, bufix, hfrom);
-
- /* If a physical layer checksum failed (dunno of any
- physical layer that supports this, but WTH), skip this
- packet. */
- if (offset < 0) {
- return 0;
- }
-
- bufix += offset;
- length -= offset;
-
- /* Decode the IP and UDP headers... */
- offset = decode_udp_ip_header (interface, ibuf, bufix,
- from, (unsigned char *)0, length);
-
- /* If the IP or UDP checksum was bad, skip the packet... */
- if (offset < 0)
- return 0;
-
- bufix += offset;
- length -= offset;
-
- /* Copy out the data in the packet... */
- memcpy (buf, &ibuf [bufix], length);
- return length;
-}
-#endif
diff --git a/common/options.c b/common/options.c
deleted file mode 100644
index 53dd0224..00000000
--- a/common/options.c
+++ /dev/null
@@ -1,536 +0,0 @@
-/* options.c
-
- DHCP options parsing and reassembly. */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: options.c,v 1.19 1996/09/11 05:52:18 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#define DHCP_OPTION_DATA
-#include "dhcpd.h"
-
-/* Parse all available options out of the specified packet. */
-
-void parse_options (packet)
- struct packet *packet;
-{
- /* Initially, zero all option pointers. */
- memset (packet -> options, 0, sizeof (packet -> options));
-
- /* If we don't see the magic cookie, there's nothing to parse. */
- if (memcmp (packet -> raw -> options, DHCP_OPTIONS_COOKIE, 4)) {
- packet -> options_valid = 0;
- return;
- }
-
- /* Go through the options field, up to the end of the packet
- or the End field. */
- parse_option_buffer (packet, &packet -> raw -> options [4],
- packet -> packet_length - DHCP_FIXED_NON_UDP - 4);
- /* If we parsed a DHCP Option Overload option, parse more
- options out of the buffer(s) containing them. */
- if (packet -> options_valid
- && packet -> options [DHO_DHCP_OPTION_OVERLOAD].data) {
- if (packet -> options [DHO_DHCP_OPTION_OVERLOAD].data [0] & 1)
- parse_option_buffer (packet,
- packet -> raw -> file,
- sizeof packet -> raw -> file);
- if (packet -> options [DHO_DHCP_OPTION_OVERLOAD].data [0] & 2)
- parse_option_buffer (packet,
- packet -> raw -> sname,
- sizeof packet -> raw -> sname);
- }
-}
-
-/* Parse options out of the specified buffer, storing addresses of option
- values in packet -> options and setting packet -> options_valid if no
- errors are encountered. */
-
-void parse_option_buffer (packet, buffer, length)
- struct packet *packet;
- unsigned char *buffer;
- int length;
-{
- unsigned char *s, *t;
- unsigned char *end = buffer + length;
- int len;
- int code;
-
- for (s = buffer; *s != DHO_END && s < end; ) {
- code = s [0];
- /* Pad options don't have a length - just skip them. */
- if (code == DHO_PAD) {
- ++s;
- continue;
- }
- /* All other fields (except end, see above) have a
- one-byte length. */
- len = s [1];
-
- /* If the length is outrageous, the options are bad. */
- if (s + len + 2 > end) {
- warn ("Option %s length %d overflows input buffer.",
- dhcp_options [code].name,
- len);
- packet -> options_valid = 0;
- return;
- }
- /* If we haven't seen this option before, just make
- space for it and copy it there. */
- if (!packet -> options [code].data) {
- if (!(t = (unsigned char *)malloc (len + 1)))
- error ("Can't allocate storage for option %s.",
- dhcp_options [code].name);
- /* Copy and NUL-terminate the option (in case it's an
- ASCII string. */
- memcpy (t, &s [2], len);
- t [len] = 0;
- packet -> options [code].len = len;
- packet -> options [code].data = t;
- } else {
- /* If it's a repeat, concatenate it to whatever
- we last saw. This is really only required
- for clients, but what the heck... */
- t = (unsigned char *)
- malloc (len
- + packet -> options [code].len
- + 1);
- if (!t)
- error ("Can't expand storage for option %s.",
- dhcp_options [code].name);
- memcpy (t, packet -> options [code].data,
- packet -> options [code].len);
- memcpy (t + packet -> options [code].len,
- &s [2], len);
- packet -> options [code].len += len;
- t [packet -> options [code].len] = 0;
- free (packet -> options [code].data);
- packet -> options [code].data = t;
- }
- s += len + 2;
- }
- packet -> options_valid = 1;
-}
-
-/* cons options into a big buffer, and then split them out into the
- three seperate buffers if needed. This allows us to cons up a set
- of vendor options using the same routine. */
-
-void cons_options (inpacket, outpacket, options, overload, terminate)
- struct packet *inpacket;
- struct packet *outpacket;
- struct tree_cache **options;
- int overload; /* Overload flags that may be set. */
- int terminate;
-{
- unsigned char priority_list [300];
- int priority_len;
- unsigned char buffer [4096]; /* Really big buffer... */
- int main_buffer_size;
- int mainbufix, bufix;
- int option_size;
-
- /* If the client has provided a maximum DHCP message size,
- use that. Otherwise, we use the default MTU size (576 bytes). */
- /* XXX Maybe it would be safe to assume that we can send a packet
- to the client that's as big as the one it sent us, even if it
- didn't specify a large MTU. */
- if (inpacket && inpacket -> options [DHO_DHCP_MAX_MESSAGE_SIZE].data) {
- main_buffer_size =
- (getUShort (inpacket -> options
- [DHO_DHCP_MAX_MESSAGE_SIZE].data)
- - DHCP_FIXED_LEN);
- /* Enforce a minimum packet size... */
- if (main_buffer_size < (576 - DHCP_FIXED_LEN))
- main_buffer_size = 576 - DHCP_FIXED_LEN;
- } else
- main_buffer_size = 576 - DHCP_FIXED_LEN;
-
- /* Preload the option priority list with mandatory options. */
- priority_len = 0;
- priority_list [priority_len++] = DHO_DHCP_MESSAGE_TYPE;
- priority_list [priority_len++] = DHO_DHCP_SERVER_IDENTIFIER;
- priority_list [priority_len++] = DHO_DHCP_LEASE_TIME;
- priority_list [priority_len++] = DHO_DHCP_MESSAGE;
-
- /* If the client has provided a list of options that it wishes
- returned, use it to prioritize. Otherwise, prioritize
- based on the default priority list. */
-
- if (inpacket &&
- inpacket -> options [DHO_DHCP_PARAMETER_REQUEST_LIST].data) {
- memcpy (&priority_list [priority_len],
- inpacket -> options
- [DHO_DHCP_PARAMETER_REQUEST_LIST].data,
- inpacket -> options
- [DHO_DHCP_PARAMETER_REQUEST_LIST].len);
- priority_len +=
- inpacket -> options
- [DHO_DHCP_PARAMETER_REQUEST_LIST].len;
- } else {
- memcpy (&priority_list [priority_len],
- dhcp_option_default_priority_list,
- sizeof_dhcp_option_default_priority_list);
- priority_len += sizeof_dhcp_option_default_priority_list;
- }
-
- /* Copy the options into the big buffer... */
- option_size = store_options (buffer,
- (main_buffer_size - 7 +
- ((overload & 1) ? DHCP_FILE_LEN : 0) +
- ((overload & 2) ? DHCP_SNAME_LEN : 0)),
- options, priority_list, priority_len,
- main_buffer_size,
- (main_buffer_size +
- ((overload & 1) ? DHCP_FILE_LEN : 0)),
- terminate);
-
- /* Put the cookie up front... */
- memcpy (outpacket -> raw -> options, DHCP_OPTIONS_COOKIE, 4);
- mainbufix = 4;
-
- /* If we're going to have to overload, store the overload
- option at the beginning. If we can, though, just store the
- whole thing in the packet's option buffer and leave it at
- that. */
- if (option_size <= main_buffer_size - mainbufix) {
- memcpy (&outpacket -> raw -> options [mainbufix],
- buffer, option_size);
- mainbufix += option_size;
- if (mainbufix < main_buffer_size)
- outpacket -> raw -> options [mainbufix++]
- = DHO_END;
- outpacket -> packet_length = DHCP_FIXED_NON_UDP + mainbufix;
- } else {
- outpacket -> raw -> options [mainbufix++] =
- DHO_DHCP_OPTION_OVERLOAD;
- outpacket -> raw -> options [mainbufix++] = 1;
- if (option_size > main_buffer_size - mainbufix + DHCP_FILE_LEN)
- outpacket -> raw -> options [mainbufix++] = 3;
- else
- outpacket -> raw -> options [mainbufix++] = 1;
-
- memcpy (&outpacket -> raw -> options [mainbufix],
- buffer, main_buffer_size - mainbufix);
- bufix = main_buffer_size - mainbufix;
- outpacket -> packet_length = DHCP_FIXED_NON_UDP + mainbufix;
- if (overload & 1) {
- if (option_size - bufix <= DHCP_FILE_LEN) {
- memcpy (outpacket -> raw -> file,
- &buffer [bufix], option_size - bufix);
- mainbufix = option_size - bufix;
- if (mainbufix < DHCP_FILE_LEN)
- outpacket -> raw -> file [mainbufix++]
- = DHO_END;
- while (mainbufix < DHCP_FILE_LEN)
- outpacket -> raw -> file [mainbufix++]
- = DHO_PAD;
- } else {
- memcpy (outpacket -> raw -> file,
- &buffer [bufix], DHCP_FILE_LEN);
- bufix += DHCP_FILE_LEN;
- }
- }
- if ((overload & 2) && option_size < bufix) {
- memcpy (outpacket -> raw -> sname,
- &buffer [bufix], option_size - bufix);
-
- mainbufix = option_size - bufix;
- if (mainbufix < DHCP_SNAME_LEN)
- outpacket -> raw -> file [mainbufix++]
- = DHO_END;
- while (mainbufix < DHCP_SNAME_LEN)
- outpacket -> raw -> file [mainbufix++]
- = DHO_PAD;
- }
- }
- return;
-}
-
-/* Store all the requested options into the requested buffer. */
-
-int store_options (buffer, buflen, options, priority_list, priority_len,
- first_cutoff, second_cutoff, terminate)
- unsigned char *buffer;
- int buflen;
- struct tree_cache **options;
- unsigned char *priority_list;
- int priority_len;
- int first_cutoff, second_cutoff;
- int terminate;
-{
- int bufix = 0;
- int option_stored [256];
- int i;
- int ix;
- int tto;
-
- /* Zero out the stored-lengths array. */
- memset (option_stored, 0, sizeof option_stored);
-
- /* Copy out the options in the order that they appear in the
- priority list... */
- for (i = 0; i < priority_len; i++) {
- /* Code for next option to try to store. */
- int code = priority_list [i];
- int optstart;
-
- /* Number of bytes left to store (some may already
- have been stored by a previous pass). */
- int length;
-
- /* If no data is available for this option, skip it. */
- if (!options [code]) {
- continue;
- }
-
- /* The client could ask for things that are mandatory,
- in which case we should avoid storing them twice... */
- if (option_stored [code])
- continue;
- option_stored [code] = 1;
-
- /* Find the value of the option... */
- if (!tree_evaluate (options [code])) {
- continue;
- }
-
- /* We should now have a constant length for the option. */
- length = options [code] -> len;
-
- /* Do we add a NUL? */
- if (terminate && dhcp_options [code].format [0] == 't') {
- length++;
- tto = 1;
- } else {
- tto = 0;
- }
-
- /* Try to store the option. */
-
- /* If the option's length is more than 255, we must store it
- in multiple hunks. Store 255-byte hunks first. However,
- in any case, if the option data will cross a buffer
- boundary, split it across that boundary. */
-
- ix = 0;
-
- optstart = bufix;
- while (length) {
- unsigned char incr = length > 255 ? 255 : length;
-
- /* If this hunk of the buffer will cross a
- boundary, only go up to the boundary in this
- pass. */
- if (bufix < first_cutoff &&
- bufix + incr > first_cutoff)
- incr = first_cutoff - bufix;
- else if (bufix < second_cutoff &&
- bufix + incr > second_cutoff)
- incr = second_cutoff - bufix;
-
- /* If this option is going to overflow the buffer,
- skip it. */
- if (bufix + 2 + incr > buflen) {
- bufix = optstart;
- break;
- }
-
- /* Everything looks good - copy it in! */
- buffer [bufix] = code;
- buffer [bufix + 1] = incr;
- if (tto && incr == length) {
- memcpy (buffer + bufix + 2,
- options [code] -> value + ix,
- incr - 1);
- buffer [bufix + 2 + incr - 1] = 0;
- } else {
- memcpy (buffer + bufix + 2,
- options [code] -> value + ix, incr);
- }
- length -= incr;
- ix += incr;
- bufix += 2 + incr;
- }
- }
- return bufix;
-}
-
-/* Format the specified option so that a human can easily read it. */
-
-char *pretty_print_option (code, data, len)
- unsigned char code;
- unsigned char *data;
- int len;
-{
- static char optbuf [32768]; /* XXX */
- int hunksize = 0;
- int numhunk = -1;
- int numelem = 0;
- char fmtbuf [32];
- int i, j;
- char *op = optbuf;
- unsigned char *dp = data;
- struct in_addr foo;
-
- /* Figure out the size of the data. */
- for (i = 0; dhcp_options [code].format [i]; i++) {
- if (!numhunk) {
- warn ("%s: Excess information in format string: %s\n",
- dhcp_options [code].name,
- &(dhcp_options [code].format [i]));
- break;
- }
- numelem++;
- fmtbuf [i] = dhcp_options [code].format [i];
- switch (dhcp_options [code].format [i]) {
- case 'A':
- --numelem;
- fmtbuf [i] = 0;
- numhunk = 0;
- break;
- case 't':
- fmtbuf [i] = 't';
- fmtbuf [i + 1] = 0;
- numhunk = -2;
- break;
- case 'I':
- case 'l':
- case 'L':
- hunksize += 4;
- break;
- case 's':
- case 'S':
- hunksize += 2;
- break;
- case 'b':
- case 'B':
- case 'f':
- hunksize++;
- break;
- case 'e':
- break;
- default:
- warn ("%s: garbage in format string: %s\n",
- dhcp_options [code].name,
- &(dhcp_options [code].format [i]));
- break;
- }
- }
-
- /* Check for too few bytes... */
- if (hunksize > len) {
- warn ("%s: expecting at least %d bytes; got %d",
- dhcp_options [code].name,
- hunksize, len);
- return "<error>";
- }
- /* Check for too many bytes... */
- if (numhunk == -1 && hunksize < len)
- warn ("%s: %d extra bytes",
- dhcp_options [code].name,
- len - hunksize);
-
- /* If this is an array, compute its size. */
- if (!numhunk)
- numhunk = len / hunksize;
- /* See if we got an exact number of hunks. */
- if (numhunk > 0 && numhunk * hunksize < len)
- warn ("%s: %d extra bytes at end of array\n",
- dhcp_options [code].name,
- len - numhunk * hunksize);
-
- /* A one-hunk array prints the same as a single hunk. */
- if (numhunk < 0)
- numhunk = 1;
-
- /* Cycle through the array (or hunk) printing the data. */
- for (i = 0; i < numhunk; i++) {
- for (j = 0; j < numelem; j++) {
- switch (fmtbuf [j]) {
- case 't':
- strcpy (op, dp);
- break;
- case 'I':
- foo.s_addr = htonl (getULong (dp));
- strcpy (op, inet_ntoa (foo));
- dp += 4;
- break;
- case 'l':
- sprintf (op, "%ld", (long)getLong (dp));
- dp += 4;
- break;
- case 'L':
- sprintf (op, "%ld",
- (unsigned long)getULong (dp));
- dp += 4;
- break;
- case 's':
- sprintf (op, "%d", getShort (dp));
- dp += 2;
- break;
- case 'S':
- sprintf (op, "%d", getUShort (dp));
- dp += 2;
- break;
- case 'b':
- sprintf (op, "%d", *(char *)dp++);
- break;
- case 'B':
- sprintf (op, "%d", *dp++);
- break;
- case 'f':
- strcpy (op, *dp++ ? "true" : "false");
- break;
- default:
- warn ("Unexpected format code %c", fmtbuf [j]);
- }
- op += strlen (op);
- *op++ = ' ';
- }
- }
- *--op = 0;
- return optbuf;
-}
-
-
-
diff --git a/common/packet.c b/common/packet.c
deleted file mode 100644
index 2d6238b4..00000000
--- a/common/packet.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/* packet.c
-
- Packet assembly code, originally contributed by Archie Cobbs. */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: packet.c,v 1.11 1996/08/27 09:53:14 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-#if defined (PACKET_ASSEMBLY) || defined (PACKET_DECODING)
-#include <netinet/in_systm.h>
-#include "includes/netinet/ip.h"
-#include "includes/netinet/udp.h"
-#include "includes/netinet/if_ether.h"
-
-static u_int32_t checksum PROTO ((unsigned char *, int, u_int32_t));
-static u_int32_t wrapsum PROTO ((u_int32_t));
-
-/* Compute the easy part of the checksum on a range of bytes. */
-
-static u_int32_t checksum (buf, nbytes, sum)
- unsigned char *buf;
- int nbytes;
- u_int32_t sum;
-{
- int i;
-
-#ifdef DEBUG_CHECKSUM
- debug ("checksum (%x %d %x)", buf, nbytes, sum);
-#endif
-
- /* Checksum all the pairs of bytes first... */
- for (i = 0; i < (nbytes & ~1); i += 2) {
-#ifdef DEBUG_CHECKSUM_VERBOSE
- debug ("sum = %x", sum);
-#endif
- sum += (u_int16_t) ntohs(*((u_int16_t *)buf)++);
- }
-
- /* If there's a single byte left over, checksum it, too. Network
- byte order is big-endian, so the remaining byte is the high byte. */
- if (i < nbytes) {
-#ifdef DEBUG_CHECKSUM_VERBOSE
- debug ("sum = %x", sum);
-#endif
- sum += (*buf) << 8;
- }
-
- return sum;
-}
-
-/* Fold the upper sixteen bits of the checksum down into the lower bits,
- complement the sum, and then put it into network byte order. */
-
-static u_int32_t wrapsum (sum)
- u_int32_t sum;
-{
-#ifdef DEBUG_CHECKSUM
- debug ("wrapsum (%x)", sum);
-#endif
-
- while (sum > 0x10000) {
- sum = (sum >> 16) + (sum & 0xFFFF);
-#ifdef DEBUG_CHECKSUM_VERBOSE
- debug ("sum = %x", sum);
-#endif
- sum += (sum >> 16);
-#ifdef DEBUG_CHECKSUM_VERBOSE
- debug ("sum = %x", sum);
-#endif
- }
- sum = sum ^ 0xFFFF;
-#ifdef DEBUG_CHECKSUM_VERBOSE
- debug ("sum = %x", sum);
-#endif
-
-#ifdef DEBUG_CHECKSUM
- debug ("wrapsum returns %x", htons (sum));
-#endif
- return htons(sum);
-}
-#endif /* PACKET_ASSEMBLY || PACKET_DECODING */
-
-#ifdef PACKET_ASSEMBLY
-/* Assemble an hardware header... */
-/* XXX currently only supports ethernet; doesn't check for other types. */
-
-void assemble_hw_header (interface, buf, bufix, to)
- struct interface_info *interface;
- unsigned char *buf;
- int *bufix;
- struct hardware *to;
-{
- struct ether_header eh;
-
- if (to && to -> hlen == 6) /* XXX */
- memcpy (eh.ether_dhost, to -> haddr, sizeof eh.ether_dhost);
- else
- memset (eh.ether_dhost, 0xff, sizeof (eh.ether_dhost));
- if (interface -> hw_address.hlen == sizeof (eh.ether_shost))
- memcpy (eh.ether_shost, interface -> hw_address.haddr,
- sizeof (eh.ether_shost));
- else
- memset (eh.ether_shost, 0x00, sizeof (eh.ether_shost));
-
-#ifdef BROKEN_FREEBSD_BPF /* Fixed in FreeBSD 2.2 */
- eh.ether_type = ETHERTYPE_IP;
-#else
- eh.ether_type = htons (ETHERTYPE_IP);
-#endif
-
- memcpy (&buf [*bufix], &eh, sizeof eh);
- *bufix += sizeof eh;
-}
-
-/* UDP header and IP header assembled together for convenience. */
-
-void assemble_udp_ip_header (interface, buf, bufix,
- from, to, port, data, len)
- struct interface_info *interface;
- unsigned char *buf;
- int *bufix;
- u_int32_t from;
- u_int32_t to;
- u_int16_t port;
- unsigned char *data;
- int len;
-{
- struct ip ip;
- struct udphdr udp;
-
- /* Fill out the IP header */
- ip.ip_v = 4;
- ip.ip_hl = 5;
- ip.ip_tos = IPTOS_LOWDELAY;
- ip.ip_len = htons(sizeof(ip) + sizeof(udp) + len);
- ip.ip_id = 0;
- ip.ip_off = 0;
- ip.ip_ttl = 16;
- ip.ip_p = IPPROTO_UDP;
- ip.ip_sum = 0;
- ip.ip_src.s_addr = from;
- ip.ip_dst.s_addr = to;
-
- /* Checksum the IP header... */
- ip.ip_sum = wrapsum (checksum ((unsigned char *)&ip, sizeof ip, 0));
-
- /* Copy the ip header into the buffer... */
- memcpy (&buf [*bufix], &ip, sizeof ip);
- *bufix += sizeof ip;
-
- /* Fill out the UDP header */
- udp.uh_sport = server_port; /* XXX */
- udp.uh_dport = port; /* XXX */
- udp.uh_ulen = htons(sizeof(udp) + len);
- memset (&udp.uh_sum, 0, sizeof udp.uh_sum);
-
- /* Compute UDP checksums, including the ``pseudo-header'', the UDP
- header and the data. */
-
-#if 0
- udp.uh_sum =
- wrapsum (checksum ((unsigned char *)&udp, sizeof udp,
- checksum (data, len,
- checksum ((unsigned char *)
- &ip.ip_src,
- sizeof ip.ip_src,
- IPPROTO_UDP +
- (u_int32_t)
- ntohs (udp.uh_ulen)))));
-#endif
-
- /* Copy the udp header into the buffer... */
- memcpy (&buf [*bufix], &udp, sizeof udp);
- *bufix += sizeof udp;
-}
-#endif /* PACKET_ASSEMBLY */
-
-#ifdef PACKET_DECODING
-/* Decode a hardware header... */
-/* XXX currently only supports ethernet; doesn't check for other types. */
-
-size_t decode_hw_header (interface, buf, bufix, from)
- struct interface_info *interface;
- unsigned char *buf;
- int bufix;
- struct hardware *from;
-{
- struct ether_header eh;
-
- memcpy (&eh, buf + bufix, sizeof eh);
-
-#ifdef USERLAND_FILTER
- if (ntohs (eh.ether_type) != ETHERTYPE_IP)
- return -1;
-#endif
- memcpy (from -> haddr, eh.ether_shost, sizeof (eh.ether_shost));
- from -> htype = ARPHRD_ETHER;
- from -> hlen = sizeof eh.ether_shost;
-
- return sizeof eh;
-}
-
-/* UDP header and IP header decoded together for convenience. */
-
-size_t decode_udp_ip_header (interface, buf, bufix, from, data, len)
- struct interface_info *interface;
- unsigned char *buf;
- int bufix;
- struct sockaddr_in *from;
- unsigned char *data;
- int len;
-{
- struct ip *ip;
- struct udphdr *udp;
- u_int32_t ip_len = (buf [bufix] & 0xf) << 2;
- u_int32_t sum, usum;
-
- ip = (struct ip *)(buf + bufix);
- udp = (struct udphdr *)(buf + bufix + ip_len);
-
-#ifdef USERLAND_FILTER
- /* Is it a UDP packet? */
- if (ip -> ip_p != IPPROTO_UDP)
- return -1;
-
- /* Is it to the port we're serving? */
- if (udp -> uh_dport != server_port)
- return -1;
-#endif /* USERLAND_FILTER */
-
- /* Check the IP header checksum - it should be zero. */
- if (wrapsum (checksum (buf + bufix, ip_len, 0))) {
- note ("Bad IP checksum: %x",
- wrapsum (checksum (buf + bufix, sizeof *ip, 0)));
- return -1;
- }
-
- /* Copy out the IP source address... */
- memcpy (&from -> sin_addr, &ip -> ip_src, 4);
-
- /* Compute UDP checksums, including the ``pseudo-header'', the UDP
- header and the data. If the UDP checksum field is zero, we're
- not supposed to do a checksum. */
-
- if (!data) {
- data = buf + bufix + ip_len + sizeof *udp;
- len -= ip_len + sizeof *udp;
- }
-
-#if 0
- usum = udp -> uh_sum;
- udp -> uh_sum = 0;
-
- sum = wrapsum (checksum ((unsigned char *)udp, sizeof *udp,
- checksum (data, len,
- checksum ((unsigned char *)
- &ip -> ip_src,
- sizeof ip -> ip_src,
- IPPROTO_UDP +
- (u_int32_t)
- ntohs (udp -> uh_ulen)))));
-
- if (usum && usum != sum) {
- note ("Bad udp checksum: %x %x", usum, sum);
- return -1;
- }
-#endif
-
- /* Copy out the port... */
- memcpy (&from -> sin_port, &udp -> uh_sport, sizeof udp -> uh_sport);
-
- return ip_len + sizeof *udp;
-}
-#endif /* PACKET_DECODING */
diff --git a/common/print.c b/common/print.c
deleted file mode 100644
index 90b5532a..00000000
--- a/common/print.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/* print.c
-
- Turn data structures into printable text. */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: print.c,v 1.11 1996/08/27 09:53:30 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-char *print_hw_addr (htype, hlen, data)
- int htype;
- int hlen;
- unsigned char *data;
-{
- static char habuf [49];
- char *s;
- int i;
-
- if (htype == 0 || hlen == 0) {
- strcpy (habuf, "<null>");
- } else {
- s = habuf;
- for (i = 0; i < hlen; i++) {
- sprintf (s, "%x", data [i]);
- s += strlen (s);
- *s++ = ':';
- }
- *--s = 0;
- }
- return habuf;
-}
-
-void print_lease (lease)
- struct lease *lease;
-{
- struct tm *t;
- char tbuf [32];
-
- debug (" Lease %s",
- piaddr (lease -> ip_addr));
-
- t = gmtime (&lease -> starts);
- strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t);
- debug (" start %s", tbuf);
-
- t = gmtime (&lease -> ends);
- strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t);
- debug (" end %s", tbuf);
-
- t = gmtime (&lease -> timestamp);
- strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t);
- debug (" stamp %s", tbuf);
-
- debug (" hardware addr = %s",
- print_hw_addr (lease -> hardware_addr.htype,
- lease -> hardware_addr.hlen,
- lease -> hardware_addr.haddr));
- debug (" host %s state %x",
- lease -> host ? lease -> host -> name : "<none>",
- lease -> state);
-}
-
-void dump_packet (tp)
- struct packet *tp;
-{
- struct dhcp_packet *tdp = tp -> raw;
-
- debug ("packet length %d", tp -> packet_length);
- debug ("op = %d htype = %d hlen = %d hops = %d",
- tdp -> op, tdp -> htype, tdp -> hlen, tdp -> hops);
- debug ("xid = %x secs = %d flags = %x",
- tdp -> xid, tdp -> secs, tdp -> flags);
- debug ("ciaddr = %s", inet_ntoa (tdp -> ciaddr));
- debug ("yiaddr = %s", inet_ntoa (tdp -> yiaddr));
- debug ("siaddr = %s", inet_ntoa (tdp -> siaddr));
- debug ("giaddr = %s", inet_ntoa (tdp -> giaddr));
- debug ("chaddr = %02.2x:%02.2x:%02.2x:%02.2x:%02.2x:%02.2x",
- ((unsigned char *)(tdp -> chaddr)) [0],
- ((unsigned char *)(tdp -> chaddr)) [1],
- ((unsigned char *)(tdp -> chaddr)) [2],
- ((unsigned char *)(tdp -> chaddr)) [3],
- ((unsigned char *)(tdp -> chaddr)) [4],
- ((unsigned char *)(tdp -> chaddr)) [5]);
- debug ("filename = %s", tdp -> file);
- debug ("server_name = %s", tdp -> sname);
- if (tp -> options_valid) {
- int i;
-
- for (i = 0; i < 256; i++) {
- if (tp -> options [i].data)
- debug (" %s = %s",
- dhcp_options [i].name,
- pretty_print_option
- (i, tp -> options [i].data,
- tp -> options [i].len));
- }
- }
- debug ("");
-}
-
-void dump_raw (buf, len)
- unsigned char *buf;
- int len;
-{
- int i;
- char lbuf [80];
- int lbix = 0;
-
- lbuf [0] = 0;
-
- for (i = 0; i < len; i++) {
- if ((i & 15) == 0) {
- if (lbix)
- note (lbuf);
- sprintf (lbuf, "%03x:", i);
- lbix = 4;
- } else if ((i & 7) == 0)
- lbuf [lbix++] = ' ';
- sprintf (&lbuf [lbix], " %02x", buf [i]);
- lbix += 3;
- }
- note (lbuf);
-}
-
-void hash_dump (table)
- struct hash_table *table;
-{
- int i;
- struct hash_bucket *bp;
-
- if (!table)
- return;
-
- for (i = 0; i < table -> hash_count; i++) {
- if (!table -> buckets [i])
- continue;
- note ("hash bucket %d:", i);
- for (bp = table -> buckets [i]; bp; bp = bp -> next) {
- if (bp -> len)
- dump_raw (bp -> name, bp -> len);
- else
- note (bp -> name);
- }
- }
-}
-
diff --git a/common/raw.c b/common/raw.c
deleted file mode 100644
index b49d4d94..00000000
--- a/common/raw.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/* socket.c
-
- BSD raw socket interface code... */
-
-/* XXX
-
- It's not clear how this should work, and that lack of clarity is
- terribly detrimental to the NetBSD 1.1 kernel - it crashes and
- burns.
-
- Using raw sockets ought to be a big win over using BPF or something
- like it, because you don't need to deal with the complexities of
- the physical layer, but it appears not to be possible with existing
- raw socket implementations. This may be worth revisiting in the
- future. For now, this code can probably be considered a curiosity.
- Sigh. */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''. */
-
-#ifndef lint
-static char copyright[] =
-"$Id: raw.c,v 1.8 1996/09/04 07:06:39 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-#if defined (USE_RAW_SEND)
-#include <sys/uio.h>
-
-/* Generic interface registration routine... */
-void if_register_send (info, interface)
- struct interface_info *info;
- struct ifreq *interface;
-{
- struct sockaddr_in name;
- int sock;
- struct socklist *tmp;
- int flag;
-
- /* Set up the address we're going to connect to. */
- name.sin_family = AF_INET;
- name.sin_port = server_port;
- name.sin_addr.s_addr = htonl (INADDR_BROADCAST);
- memset (name.sin_zero, 0, sizeof (name.sin_zero));
-
- /* List addresses on which we're listening. */
- note ("Sending on %s, port %d",
- piaddr (info -> address), htons (server_port));
- if ((sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
- error ("Can't create dhcp socket: %m");
-
- /* Set the BROADCAST option so that we can broadcast DHCP responses. */
- flag = 1;
- if (setsockopt (sock, SOL_SOCKET, SO_BROADCAST,
- &flag, sizeof flag) < 0)
- error ("Can't set SO_BROADCAST option on dhcp socket: %m");
-
- /* Set the IP_HDRINCL flag so that we can supply our own IP
- headers... */
- if (setsockopt (sock, IPPROTO_IP, IP_HDRINCL, &flag, sizeof flag) < 0)
- error ("Can't set IP_HDRINCL flag: %m");
-
- info -> wfdesc = sock;
- note ("Sending on Raw/%s/%s",
- info -> name,
- (info -> shared_network ?
- info -> shared_network -> name : "unattached"));
-}
-
-size_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 char buf [256];
- int bufp = 0;
- struct iovec iov [2];
-
- /* Assemble the headers... */
- assemble_udp_ip_header (interface, buf, &bufp, from.s_addr,
- to -> sin_addr.s_addr, to -> sin_port,
- (unsigned char *)raw, len);
-
- /* Fire it off */
- iov [0].iov_base = (char *)buf;
- iov [0].iov_len = bufp;
- iov [1].iov_base = (char *)raw;
- iov [1].iov_len = len;
-
- return writev(interface -> wfdesc, iov, 2);
-}
-#endif /* USE_SOCKET_SEND */
diff --git a/common/socket.c b/common/socket.c
deleted file mode 100644
index dcd758a5..00000000
--- a/common/socket.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/* socket.c
-
- BSD socket interface code... */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: socket.c,v 1.16 1996/08/27 09:54:48 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-#ifdef USE_SOCKET_FALLBACK
-# define USE_SOCKET_SEND
-# define if_register_send if_register_fallback
-# define send_packet send_fallback
-#endif
-
-#if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_RECEIVE)
-/* Generic interface registration routine... */
-int if_register_socket (info, interface)
- struct interface_info *info;
- struct ifreq *interface;
-{
- struct sockaddr_in name;
- int sock;
- int flag;
- static int once = 0;
-
- /* Make sure only one interface is registered. */
- if (once)
- error ("The standard socket API can only support %s%s%s%s%s",
- "hosts with a single network interface. If you must ",
- "run dhcpd on a host with multiple interfaces, ",
- "you must compile in BPF or NIT support. If neither ",
- "option is supported on your system, please let us ",
- "know.");
-
- /* Technically, we need to know what interface every packet
- comes in on, which means that we can only operate on a
- machine with a single interface configured. However,
- we generally don't expect to get broadcast packets on
- point-to-point interfaces, so we can bend the rules a bit
- and not count them. This won't allow DHCP-over-PPP,
- but it's probably right in a lot of cases, and the issue
- will have to be revisited when DHCP-over-PPP support is
- done. Currently we determine whether an interface is
- point-to-point by seeing if it has a link-level address.
- This only works on 4.4BSD and derivative networking. */
-#ifdef AF_LINK
- if (info -> hw_address.hlen) /* XXX */
-#endif
- once = 1;
-
- /* Set up the address we're going to bind to. */
- name.sin_family = AF_INET;
- name.sin_port = server_port;
- name.sin_addr.s_addr = INADDR_ANY;
- memset (name.sin_zero, 0, sizeof (name.sin_zero));
-
- /* Make a socket... */
- if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
- error ("Can't create dhcp socket: %m");
-
- /* Set the REUSEADDR option so that we don't fail to start if
- we're being restarted. */
- flag = 1;
- if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR,
- (char *)&flag, sizeof flag) < 0)
- error ("Can't set SO_REUSEADDR option on dhcp socket: %m");
-
- /* Set the BROADCAST option so that we can broadcast DHCP responses. */
- if (setsockopt (sock, SOL_SOCKET, SO_BROADCAST,
- (char *)&flag, sizeof flag) < 0)
- error ("Can't set SO_BROADCAST option on dhcp socket: %m");
-
- /* Bind the socket to this interface's IP address. */
- if (bind (sock, (struct sockaddr *)&name, sizeof name) < 0)
- error ("Can't bind to dhcp address: %m");
-
- return sock;
-}
-#endif /* USE_SOCKET_SEND || USE_SOCKET_RECEIVE */
-
-#ifdef USE_SOCKET_SEND
-void if_register_send (info, interface)
- struct interface_info *info;
- struct ifreq *interface;
-
-{
-#ifndef USE_SOCKET_RECEIVE
- info -> wfdesc = if_register_socket (info, interface);
-#else
- info -> wfdesc = info -> rfdesc;
-#endif
- note ("Sending on Socket/%s/%s",
- info -> name,
- (info -> shared_network ?
- info -> shared_network -> name : "unattached"));
-
-}
-#endif /* USE_SOCKET_SEND */
-
-#ifdef USE_SOCKET_RECEIVE
-void if_register_receive (info, interface)
- struct interface_info *info;
- struct ifreq *interface;
-{
- /* If we're using the socket API for sending and receiving,
- we don't need to register this interface twice. */
- info -> rfdesc = if_register_socket (info, interface);
- note ("Listening on Socket/%s/%s",
- info -> name,
- (info -> shared_network ?
- info -> shared_network -> name : "unattached"));
-}
-#endif /* USE_SOCKET_RECEIVE */
-
-#ifdef USE_SOCKET_SEND
-size_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;
-{
- return sendto (interface -> wfdesc, (char *)raw, len, 0,
- (struct sockaddr *)to, sizeof *to);
-}
-#endif /* USE_SOCKET_SEND */
-
-#ifdef USE_SOCKET_RECEIVE
-size_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 flen = sizeof *from;
-
- return recvfrom (interface -> rfdesc, buf, len, 0,
- (struct sockaddr *)from, &flen);
-}
-#endif /* USE_SOCKET_RECEIVE */
-
-#ifdef USE_SOCKET_FALLBACK
-/* This just reads in a packet and silently discards it. */
-
-size_t fallback_discard (interface)
- struct interface_info *interface;
-{
- char buf [1540];
- struct sockaddr_in from;
- int flen = sizeof from;
-
- return recvfrom (interface -> wfdesc, buf, sizeof buf, 0,
- (struct sockaddr *)&from, &flen);
-}
-#endif /* USE_SOCKET_RECEIVE */
diff --git a/common/tables.c b/common/tables.c
deleted file mode 100644
index e5c6ca27..00000000
--- a/common/tables.c
+++ /dev/null
@@ -1,690 +0,0 @@
-/* tables.c
-
- Tables of information... */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: tables.c,v 1.11 1996/09/11 06:34:25 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-/* DHCP Option names, formats and codes, from RFC1533.
-
- Format codes:
-
- e - end of data
- I - IP address
- l - 32-bit signed integer
- L - 32-bit unsigned integer
- s - 16-bit signed integer
- S - 16-bit unsigned integer
- b - 8-bit signed integer
- B - 8-bit unsigned integer
- t - ASCII text
- f - flag (true or false)
- A - array of whatever precedes (e.g., IA means array of IP addresses)
-*/
-
-struct universe dhcp_universe;
-struct option dhcp_options [256] = {
- { "pad", "", &dhcp_universe, 0 },
- { "subnet-mask", "I", &dhcp_universe, 1 },
- { "time-offset", "l", &dhcp_universe, 2 },
- { "routers", "IA", &dhcp_universe, 3 },
- { "time-servers", "IA", &dhcp_universe, 4 },
- { "name-servers", "IA", &dhcp_universe, 5 },
- { "domain-name-servers", "IA", &dhcp_universe, 6 },
- { "log-servers", "IA", &dhcp_universe, 7 },
- { "cookie-servers", "IA", &dhcp_universe, 8 },
- { "lpr-servers", "IA", &dhcp_universe, 9 },
- { "impress-servers", "IA", &dhcp_universe, 10 },
- { "resource-location-servers", "IA", &dhcp_universe, 11 },
- { "host-name", "t", &dhcp_universe, 12 },
- { "boot-size", "S", &dhcp_universe, 13 },
- { "merit-dump", "t", &dhcp_universe, 14 },
- { "domain-name", "t", &dhcp_universe, 15 },
- { "swap-server", "I", &dhcp_universe, 16 },
- { "root-path", "t", &dhcp_universe, 17 },
- { "extensions-path", "t", &dhcp_universe, 18 },
- { "ip-forwarding", "f", &dhcp_universe, 19 },
- { "non-local-source-routing", "f", &dhcp_universe, 20 },
- { "policy-filter", "IIA", &dhcp_universe, 21 },
- { "max-dgram-reassembly", "S", &dhcp_universe, 22 },
- { "default-ip-ttl", "B", &dhcp_universe, 23 },
- { "path-mtu-aging-timeout", "L", &dhcp_universe, 24 },
- { "path-mtu-plateau-table", "SA", &dhcp_universe, 25 },
- { "interface-mtu", "S", &dhcp_universe, 26 },
- { "all-subnets-local", "f", &dhcp_universe, 27 },
- { "broadcast-address", "I", &dhcp_universe, 28 },
- { "perform-mask-discovery", "f", &dhcp_universe, 29 },
- { "mask-supplier", "f", &dhcp_universe, 30 },
- { "router-discovery", "f", &dhcp_universe, 31 },
- { "router-solicitation-address", "I", &dhcp_universe, 32 },
- { "static-routes", "IIA", &dhcp_universe, 33 },
- { "trailer-encapsulation", "f", &dhcp_universe, 34 },
- { "arp-cache-timeout", "L", &dhcp_universe, 35 },
- { "ieee802-3-encapsulation", "f", &dhcp_universe, 36 },
- { "default-tcp-ttl", "B", &dhcp_universe, 37 },
- { "tcp-keepalive-interval", "L", &dhcp_universe, 38 },
- { "tcp-keepalive-garbage", "f", &dhcp_universe, 39 },
- { "nis-domain", "t", &dhcp_universe, 40 },
- { "nis-servers", "IA", &dhcp_universe, 41 },
- { "ntp-servers", "IA", &dhcp_universe, 42 },
- { "vendor-encapsulated-options", "t", &dhcp_universe, 43 },
- { "netbios-name-servers", "IA", &dhcp_universe, 44 },
- { "netbios-dd-server", "IA", &dhcp_universe, 45 },
- { "netbios-node-type", "B", &dhcp_universe, 46 },
- { "netbios-scope", "t", &dhcp_universe, 47 },
- { "font-servers", "IA", &dhcp_universe, 48 },
- { "x-display-manager", "IA", &dhcp_universe, 49 },
- { "dhcp-requested-address", "I", &dhcp_universe, 50 },
- { "dhcp-lease-time", "L", &dhcp_universe, 51 },
- { "dhcp-option-overload", "B", &dhcp_universe, 52 },
- { "dhcp-message-type", "B", &dhcp_universe, 53 },
- { "dhcp-server-identifier", "I", &dhcp_universe, 54 },
- { "dhcp-parameter-request-list", "BA", &dhcp_universe, 55 },
- { "dhcp-message", "t", &dhcp_universe, 56 },
- { "dhcp-max-message-size", "S", &dhcp_universe, 57 },
- { "dhcp-renewal-time", "L", &dhcp_universe, 58 },
- { "dhcp-rebinding-time", "L", &dhcp_universe, 59 },
- { "dhcp-class-identifier", "t", &dhcp_universe, 60 },
- { "dhcp-client-identifier", "X", &dhcp_universe, 61 },
- { "option-62", "X", &dhcp_universe, 62 },
- { "option-63", "X", &dhcp_universe, 63 },
- { "option-64", "X", &dhcp_universe, 64 },
- { "option-65", "X", &dhcp_universe, 65 },
- { "option-66", "X", &dhcp_universe, 66 },
- { "option-67", "X", &dhcp_universe, 67 },
- { "option-68", "X", &dhcp_universe, 68 },
- { "option-69", "X", &dhcp_universe, 69 },
- { "option-70", "X", &dhcp_universe, 70 },
- { "option-71", "X", &dhcp_universe, 71 },
- { "option-72", "X", &dhcp_universe, 72 },
- { "option-73", "X", &dhcp_universe, 73 },
- { "option-74", "X", &dhcp_universe, 74 },
- { "option-75", "X", &dhcp_universe, 75 },
- { "option-76", "X", &dhcp_universe, 76 },
- { "dhcp-user-class-identifier", "t", &dhcp_universe, 77 },
- { "option-78", "X", &dhcp_universe, 78 },
- { "option-79", "X", &dhcp_universe, 79 },
- { "option-80", "X", &dhcp_universe, 80 },
- { "option-81", "X", &dhcp_universe, 81 },
- { "option-82", "X", &dhcp_universe, 82 },
- { "option-83", "X", &dhcp_universe, 83 },
- { "option-84", "X", &dhcp_universe, 84 },
- { "option-85", "X", &dhcp_universe, 85 },
- { "option-86", "X", &dhcp_universe, 86 },
- { "option-87", "X", &dhcp_universe, 87 },
- { "option-88", "X", &dhcp_universe, 88 },
- { "option-89", "X", &dhcp_universe, 89 },
- { "option-90", "X", &dhcp_universe, 90 },
- { "option-91", "X", &dhcp_universe, 91 },
- { "option-92", "X", &dhcp_universe, 92 },
- { "option-93", "X", &dhcp_universe, 93 },
- { "option-94", "X", &dhcp_universe, 94 },
- { "option-95", "X", &dhcp_universe, 95 },
- { "option-96", "X", &dhcp_universe, 96 },
- { "option-97", "X", &dhcp_universe, 97 },
- { "option-98", "X", &dhcp_universe, 98 },
- { "option-99", "X", &dhcp_universe, 99 },
- { "option-100", "X", &dhcp_universe, 100 },
- { "option-101", "X", &dhcp_universe, 101 },
- { "option-102", "X", &dhcp_universe, 102 },
- { "option-103", "X", &dhcp_universe, 103 },
- { "option-104", "X", &dhcp_universe, 104 },
- { "option-105", "X", &dhcp_universe, 105 },
- { "option-106", "X", &dhcp_universe, 106 },
- { "option-107", "X", &dhcp_universe, 107 },
- { "option-108", "X", &dhcp_universe, 108 },
- { "option-109", "X", &dhcp_universe, 109 },
- { "option-110", "X", &dhcp_universe, 110 },
- { "option-111", "X", &dhcp_universe, 111 },
- { "option-112", "X", &dhcp_universe, 112 },
- { "option-113", "X", &dhcp_universe, 113 },
- { "option-114", "X", &dhcp_universe, 114 },
- { "option-115", "X", &dhcp_universe, 115 },
- { "option-116", "X", &dhcp_universe, 116 },
- { "option-117", "X", &dhcp_universe, 117 },
- { "option-118", "X", &dhcp_universe, 118 },
- { "option-119", "X", &dhcp_universe, 119 },
- { "option-120", "X", &dhcp_universe, 120 },
- { "option-121", "X", &dhcp_universe, 121 },
- { "option-122", "X", &dhcp_universe, 122 },
- { "option-123", "X", &dhcp_universe, 123 },
- { "option-124", "X", &dhcp_universe, 124 },
- { "option-125", "X", &dhcp_universe, 125 },
- { "option-126", "X", &dhcp_universe, 126 },
- { "option-127", "X", &dhcp_universe, 127 },
- { "option-128", "X", &dhcp_universe, 128 },
- { "option-129", "X", &dhcp_universe, 129 },
- { "option-130", "X", &dhcp_universe, 130 },
- { "option-131", "X", &dhcp_universe, 131 },
- { "option-132", "X", &dhcp_universe, 132 },
- { "option-133", "X", &dhcp_universe, 133 },
- { "option-134", "X", &dhcp_universe, 134 },
- { "option-135", "X", &dhcp_universe, 135 },
- { "option-136", "X", &dhcp_universe, 136 },
- { "option-137", "X", &dhcp_universe, 137 },
- { "option-138", "X", &dhcp_universe, 138 },
- { "option-139", "X", &dhcp_universe, 139 },
- { "option-140", "X", &dhcp_universe, 140 },
- { "option-141", "X", &dhcp_universe, 141 },
- { "option-142", "X", &dhcp_universe, 142 },
- { "option-143", "X", &dhcp_universe, 143 },
- { "option-144", "X", &dhcp_universe, 144 },
- { "option-145", "X", &dhcp_universe, 145 },
- { "option-146", "X", &dhcp_universe, 146 },
- { "option-147", "X", &dhcp_universe, 147 },
- { "option-148", "X", &dhcp_universe, 148 },
- { "option-149", "X", &dhcp_universe, 149 },
- { "option-150", "X", &dhcp_universe, 150 },
- { "option-151", "X", &dhcp_universe, 151 },
- { "option-152", "X", &dhcp_universe, 152 },
- { "option-153", "X", &dhcp_universe, 153 },
- { "option-154", "X", &dhcp_universe, 154 },
- { "option-155", "X", &dhcp_universe, 155 },
- { "option-156", "X", &dhcp_universe, 156 },
- { "option-157", "X", &dhcp_universe, 157 },
- { "option-158", "X", &dhcp_universe, 158 },
- { "option-159", "X", &dhcp_universe, 159 },
- { "option-160", "X", &dhcp_universe, 160 },
- { "option-161", "X", &dhcp_universe, 161 },
- { "option-162", "X", &dhcp_universe, 162 },
- { "option-163", "X", &dhcp_universe, 163 },
- { "option-164", "X", &dhcp_universe, 164 },
- { "option-165", "X", &dhcp_universe, 165 },
- { "option-166", "X", &dhcp_universe, 166 },
- { "option-167", "X", &dhcp_universe, 167 },
- { "option-168", "X", &dhcp_universe, 168 },
- { "option-169", "X", &dhcp_universe, 169 },
- { "option-170", "X", &dhcp_universe, 170 },
- { "option-171", "X", &dhcp_universe, 171 },
- { "option-172", "X", &dhcp_universe, 172 },
- { "option-173", "X", &dhcp_universe, 173 },
- { "option-174", "X", &dhcp_universe, 174 },
- { "option-175", "X", &dhcp_universe, 175 },
- { "option-176", "X", &dhcp_universe, 176 },
- { "option-177", "X", &dhcp_universe, 177 },
- { "option-178", "X", &dhcp_universe, 178 },
- { "option-179", "X", &dhcp_universe, 179 },
- { "option-180", "X", &dhcp_universe, 180 },
- { "option-181", "X", &dhcp_universe, 181 },
- { "option-182", "X", &dhcp_universe, 182 },
- { "option-183", "X", &dhcp_universe, 183 },
- { "option-184", "X", &dhcp_universe, 184 },
- { "option-185", "X", &dhcp_universe, 185 },
- { "option-186", "X", &dhcp_universe, 186 },
- { "option-187", "X", &dhcp_universe, 187 },
- { "option-188", "X", &dhcp_universe, 188 },
- { "option-189", "X", &dhcp_universe, 189 },
- { "option-190", "X", &dhcp_universe, 190 },
- { "option-191", "X", &dhcp_universe, 191 },
- { "option-192", "X", &dhcp_universe, 192 },
- { "option-193", "X", &dhcp_universe, 193 },
- { "option-194", "X", &dhcp_universe, 194 },
- { "option-195", "X", &dhcp_universe, 195 },
- { "option-196", "X", &dhcp_universe, 196 },
- { "option-197", "X", &dhcp_universe, 197 },
- { "option-198", "X", &dhcp_universe, 198 },
- { "option-199", "X", &dhcp_universe, 199 },
- { "option-200", "X", &dhcp_universe, 200 },
- { "option-201", "X", &dhcp_universe, 201 },
- { "option-202", "X", &dhcp_universe, 202 },
- { "option-203", "X", &dhcp_universe, 203 },
- { "option-204", "X", &dhcp_universe, 204 },
- { "option-205", "X", &dhcp_universe, 205 },
- { "option-206", "X", &dhcp_universe, 206 },
- { "option-207", "X", &dhcp_universe, 207 },
- { "option-208", "X", &dhcp_universe, 208 },
- { "option-209", "X", &dhcp_universe, 209 },
- { "option-210", "X", &dhcp_universe, 210 },
- { "option-211", "X", &dhcp_universe, 211 },
- { "option-212", "X", &dhcp_universe, 212 },
- { "option-213", "X", &dhcp_universe, 213 },
- { "option-214", "X", &dhcp_universe, 214 },
- { "option-215", "X", &dhcp_universe, 215 },
- { "option-216", "X", &dhcp_universe, 216 },
- { "option-217", "X", &dhcp_universe, 217 },
- { "option-218", "X", &dhcp_universe, 218 },
- { "option-219", "X", &dhcp_universe, 219 },
- { "option-220", "X", &dhcp_universe, 220 },
- { "option-221", "X", &dhcp_universe, 221 },
- { "option-222", "X", &dhcp_universe, 222 },
- { "option-223", "X", &dhcp_universe, 223 },
- { "option-224", "X", &dhcp_universe, 224 },
- { "option-225", "X", &dhcp_universe, 225 },
- { "option-226", "X", &dhcp_universe, 226 },
- { "option-227", "X", &dhcp_universe, 227 },
- { "option-228", "X", &dhcp_universe, 228 },
- { "option-229", "X", &dhcp_universe, 229 },
- { "option-230", "X", &dhcp_universe, 230 },
- { "option-231", "X", &dhcp_universe, 231 },
- { "option-232", "X", &dhcp_universe, 232 },
- { "option-233", "X", &dhcp_universe, 233 },
- { "option-234", "X", &dhcp_universe, 234 },
- { "option-235", "X", &dhcp_universe, 235 },
- { "option-236", "X", &dhcp_universe, 236 },
- { "option-237", "X", &dhcp_universe, 237 },
- { "option-238", "X", &dhcp_universe, 238 },
- { "option-239", "X", &dhcp_universe, 239 },
- { "option-240", "X", &dhcp_universe, 240 },
- { "option-241", "X", &dhcp_universe, 241 },
- { "option-242", "X", &dhcp_universe, 242 },
- { "option-243", "X", &dhcp_universe, 243 },
- { "option-244", "X", &dhcp_universe, 244 },
- { "option-245", "X", &dhcp_universe, 245 },
- { "option-246", "X", &dhcp_universe, 246 },
- { "option-247", "X", &dhcp_universe, 247 },
- { "option-248", "X", &dhcp_universe, 248 },
- { "option-249", "X", &dhcp_universe, 249 },
- { "option-250", "X", &dhcp_universe, 250 },
- { "option-251", "X", &dhcp_universe, 251 },
- { "option-252", "X", &dhcp_universe, 252 },
- { "option-253", "X", &dhcp_universe, 253 },
- { "option-254", "X", &dhcp_universe, 254 },
- { "option-end", "e", &dhcp_universe, 255 },
-};
-
-/* Default dhcp option priority list (this is ad hoc and should not be
- mistaken for a carefully crafted and optimized list). */
-unsigned char dhcp_option_default_priority_list [] = {
- DHO_DHCP_REQUESTED_ADDRESS,
- DHO_DHCP_OPTION_OVERLOAD,
- DHO_DHCP_MAX_MESSAGE_SIZE,
- DHO_DHCP_RENEWAL_TIME,
- DHO_DHCP_REBINDING_TIME,
- DHO_DHCP_CLASS_IDENTIFIER,
- DHO_DHCP_CLIENT_IDENTIFIER,
- DHO_SUBNET_MASK,
- DHO_TIME_OFFSET,
- DHO_ROUTERS,
- DHO_TIME_SERVERS,
- DHO_NAME_SERVERS,
- DHO_DOMAIN_NAME_SERVERS,
- DHO_HOST_NAME,
- DHO_LOG_SERVERS,
- DHO_COOKIE_SERVERS,
- DHO_LPR_SERVERS,
- DHO_IMPRESS_SERVERS,
- DHO_RESOURCE_LOCATION_SERVERS,
- DHO_HOST_NAME,
- DHO_BOOT_SIZE,
- DHO_MERIT_DUMP,
- DHO_DOMAIN_NAME,
- DHO_SWAP_SERVER,
- DHO_ROOT_PATH,
- DHO_EXTENSIONS_PATH,
- DHO_IP_FORWARDING,
- DHO_NON_LOCAL_SOURCE_ROUTING,
- DHO_POLICY_FILTER,
- DHO_MAX_DGRAM_REASSEMBLY,
- DHO_DEFAULT_IP_TTL,
- DHO_PATH_MTU_AGING_TIMEOUT,
- DHO_PATH_MTU_PLATEAU_TABLE,
- DHO_INTERFACE_MTU,
- DHO_ALL_SUBNETS_LOCAL,
- DHO_BROADCAST_ADDRESS,
- DHO_PERFORM_MASK_DISCOVERY,
- DHO_MASK_SUPPLIER,
- DHO_ROUTER_DISCOVERY,
- DHO_ROUTER_SOLICITATION_ADDRESS,
- DHO_STATIC_ROUTES,
- DHO_TRAILER_ENCAPSULATION,
- DHO_ARP_CACHE_TIMEOUT,
- DHO_IEEE802_3_ENCAPSULATION,
- DHO_DEFAULT_TCP_TTL,
- DHO_TCP_KEEPALIVE_INTERVAL,
- DHO_TCP_KEEPALIVE_GARBAGE,
- DHO_NIS_DOMAIN,
- DHO_NIS_SERVERS,
- DHO_NTP_SERVERS,
- DHO_VENDOR_ENCAPSULATED_OPTIONS,
- DHO_NETBIOS_NAME_SERVERS,
- DHO_NETBIOS_DD_SERVER,
- DHO_NETBIOS_NODE_TYPE,
- DHO_NETBIOS_SCOPE,
- DHO_FONT_SERVERS,
- DHO_X_DISPLAY_MANAGER,
- DHO_DHCP_PARAMETER_REQUEST_LIST,
-
- /* Presently-undefined options... */
- 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
- 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
- 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
- 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
- 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
- 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
- 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
- 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166,
- 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178,
- 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190,
- 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202,
- 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214,
- 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226,
- 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238,
- 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250,
- 251, 252, 253, 254,
-};
-
-int sizeof_dhcp_option_default_priority_list =
- sizeof dhcp_option_default_priority_list;
-
-
-char *hardware_types [] = {
- "unknown-0",
- "ethernet",
- "unknown-2",
- "unknown-3",
- "unknown-4",
- "unknown-5",
- "token-ring",
- "unknown-7",
- "unknown-8",
- "unknown-9",
- "unknown-10",
- "unknown-11",
- "unknown-12",
- "unknown-13",
- "unknown-14",
- "unknown-15",
- "unknown-16",
- "unknown-17",
- "unknown-18",
- "unknown-19",
- "unknown-20",
- "unknown-21",
- "unknown-22",
- "unknown-23",
- "unknown-24",
- "unknown-25",
- "unknown-26",
- "unknown-27",
- "unknown-28",
- "unknown-29",
- "unknown-30",
- "unknown-31",
- "unknown-32",
- "unknown-33",
- "unknown-34",
- "unknown-35",
- "unknown-36",
- "unknown-37",
- "unknown-38",
- "unknown-39",
- "unknown-40",
- "unknown-41",
- "unknown-42",
- "unknown-43",
- "unknown-44",
- "unknown-45",
- "unknown-46",
- "unknown-47",
- "unknown-48",
- "unknown-49",
- "unknown-50",
- "unknown-51",
- "unknown-52",
- "unknown-53",
- "unknown-54",
- "unknown-55",
- "unknown-56",
- "unknown-57",
- "unknown-58",
- "unknown-59",
- "unknown-60",
- "unknown-61",
- "unknown-62",
- "unknown-63",
- "unknown-64",
- "unknown-65",
- "unknown-66",
- "unknown-67",
- "unknown-68",
- "unknown-69",
- "unknown-70",
- "unknown-71",
- "unknown-72",
- "unknown-73",
- "unknown-74",
- "unknown-75",
- "unknown-76",
- "unknown-77",
- "unknown-78",
- "unknown-79",
- "unknown-80",
- "unknown-81",
- "unknown-82",
- "unknown-83",
- "unknown-84",
- "unknown-85",
- "unknown-86",
- "unknown-87",
- "unknown-88",
- "unknown-89",
- "unknown-90",
- "unknown-91",
- "unknown-92",
- "unknown-93",
- "unknown-94",
- "unknown-95",
- "unknown-96",
- "unknown-97",
- "unknown-98",
- "unknown-99",
- "unknown-100",
- "unknown-101",
- "unknown-102",
- "unknown-103",
- "unknown-104",
- "unknown-105",
- "unknown-106",
- "unknown-107",
- "unknown-108",
- "unknown-109",
- "unknown-110",
- "unknown-111",
- "unknown-112",
- "unknown-113",
- "unknown-114",
- "unknown-115",
- "unknown-116",
- "unknown-117",
- "unknown-118",
- "unknown-119",
- "unknown-120",
- "unknown-121",
- "unknown-122",
- "unknown-123",
- "unknown-124",
- "unknown-125",
- "unknown-126",
- "unknown-127",
- "unknown-128",
- "unknown-129",
- "unknown-130",
- "unknown-131",
- "unknown-132",
- "unknown-133",
- "unknown-134",
- "unknown-135",
- "unknown-136",
- "unknown-137",
- "unknown-138",
- "unknown-139",
- "unknown-140",
- "unknown-141",
- "unknown-142",
- "unknown-143",
- "unknown-144",
- "unknown-145",
- "unknown-146",
- "unknown-147",
- "unknown-148",
- "unknown-149",
- "unknown-150",
- "unknown-151",
- "unknown-152",
- "unknown-153",
- "unknown-154",
- "unknown-155",
- "unknown-156",
- "unknown-157",
- "unknown-158",
- "unknown-159",
- "unknown-160",
- "unknown-161",
- "unknown-162",
- "unknown-163",
- "unknown-164",
- "unknown-165",
- "unknown-166",
- "unknown-167",
- "unknown-168",
- "unknown-169",
- "unknown-170",
- "unknown-171",
- "unknown-172",
- "unknown-173",
- "unknown-174",
- "unknown-175",
- "unknown-176",
- "unknown-177",
- "unknown-178",
- "unknown-179",
- "unknown-180",
- "unknown-181",
- "unknown-182",
- "unknown-183",
- "unknown-184",
- "unknown-185",
- "unknown-186",
- "unknown-187",
- "unknown-188",
- "unknown-189",
- "unknown-190",
- "unknown-191",
- "unknown-192",
- "unknown-193",
- "unknown-194",
- "unknown-195",
- "unknown-196",
- "unknown-197",
- "unknown-198",
- "unknown-199",
- "unknown-200",
- "unknown-201",
- "unknown-202",
- "unknown-203",
- "unknown-204",
- "unknown-205",
- "unknown-206",
- "unknown-207",
- "unknown-208",
- "unknown-209",
- "unknown-210",
- "unknown-211",
- "unknown-212",
- "unknown-213",
- "unknown-214",
- "unknown-215",
- "unknown-216",
- "unknown-217",
- "unknown-218",
- "unknown-219",
- "unknown-220",
- "unknown-221",
- "unknown-222",
- "unknown-223",
- "unknown-224",
- "unknown-225",
- "unknown-226",
- "unknown-227",
- "unknown-228",
- "unknown-229",
- "unknown-230",
- "unknown-231",
- "unknown-232",
- "unknown-233",
- "unknown-234",
- "unknown-235",
- "unknown-236",
- "unknown-237",
- "unknown-238",
- "unknown-239",
- "unknown-240",
- "unknown-241",
- "unknown-242",
- "unknown-243",
- "unknown-244",
- "unknown-245",
- "unknown-246",
- "unknown-247",
- "unknown-248",
- "unknown-249",
- "unknown-250",
- "unknown-251",
- "unknown-252",
- "unknown-253",
- "unknown-254",
- "unknown-255" };
-
-
-
-struct hash_table universe_hash;
-
-void initialize_universes()
-{
- int i;
-
- dhcp_universe.name = "dhcp";
- dhcp_universe.hash = new_hash ();
- if (!dhcp_universe.hash)
- error ("Can't allocate dhcp option hash table.");
- for (i = 0; i < 256; i++) {
- dhcp_universe.options [i] = &dhcp_options [i];
- add_hash (dhcp_universe.hash, dhcp_options [i].name, 0,
- (unsigned char *)&dhcp_options [i]);
- }
- universe_hash.hash_count = DEFAULT_HASH_SIZE;
- add_hash (&universe_hash, dhcp_universe.name, 0,
- (unsigned char *)&dhcp_universe);
-}
diff --git a/common/tree.c b/common/tree.c
deleted file mode 100644
index 8168522a..00000000
--- a/common/tree.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/* tree.c
-
- Routines for manipulating parse trees... */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: tree.c,v 1.9 1996/08/27 09:55:50 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-static TIME tree_evaluate_recurse PROTO ((int *, unsigned char **, int *,
- struct tree *));
-static TIME do_host_lookup PROTO ((int *, unsigned char **, int *,
- struct dns_host_entry *));
-static void do_data_copy PROTO ((int *, unsigned char **, int *,
- unsigned char *, int));
-
-pair cons (car, cdr)
- caddr_t car;
- pair cdr;
-{
- pair foo = (pair)dmalloc (sizeof *foo, "cons");
- if (!foo)
- error ("no memory for cons.");
- foo -> car = car;
- foo -> cdr = cdr;
- return foo;
-}
-
-struct tree_cache *tree_cache (tree)
- struct tree *tree;
-{
- struct tree_cache *tc;
-
- tc = new_tree_cache ("tree_cache");
- if (!tc)
- return 0;
- tc -> value = (unsigned char *)0;
- tc -> len = tc -> buf_size = 0;
- tc -> timeout = 0;
- tc -> tree = tree;
- return tc;
-}
-
-struct tree *tree_host_lookup (name)
- char *name;
-{
- struct tree *nt;
- nt = new_tree ("tree_host_lookup");
- if (!nt)
- error ("No memory for host lookup tree node.");
- nt -> op = TREE_HOST_LOOKUP;
- nt -> data.host_lookup.host = enter_dns_host (name);
- return nt;
-}
-
-struct dns_host_entry *enter_dns_host (name)
- char *name;
-{
- struct dns_host_entry *dh;
-
- if (!(dh = (struct dns_host_entry *)dmalloc
- (sizeof (struct dns_host_entry), "enter_dns_host"))
- || !(dh -> hostname = dmalloc (strlen (name) + 1,
- "enter_dns_host")))
- error ("Can't allocate space for new host.");
- strcpy (dh -> hostname, name);
- dh -> data = (unsigned char *)0;
- dh -> data_len = 0;
- dh -> buf_len = 0;
- dh -> timeout = 0;
- return dh;
-}
-
-struct tree *tree_const (data, len)
- unsigned char *data;
- int len;
-{
- struct tree *nt;
- if (!(nt = new_tree ("tree_const"))
- || !(nt -> data.const_val.data =
- (unsigned char *)dmalloc (len, "tree_const")))
- error ("No memory for constant data tree node.");
- nt -> op = TREE_CONST;
- memcpy (nt -> data.const_val.data, data, len);
- nt -> data.const_val.len = len;
- return nt;
-}
-
-struct tree *tree_concat (left, right)
- struct tree *left, *right;
-{
- struct tree *nt;
-
- /* If we're concatenating a null tree to a non-null tree, just
- return the non-null tree; if both trees are null, return
- a null tree. */
- if (!left)
- return right;
- if (!right)
- return left;
-
- /* If both trees are constant, combine them. */
- if (left -> op == TREE_CONST && right -> op == TREE_CONST) {
- unsigned char *buf = dmalloc (left -> data.const_val.len
- + right -> data.const_val.len,
- "tree_concat");
- if (!buf)
- error ("No memory to concatenate constants.");
- memcpy (buf, left -> data.const_val.data,
- left -> data.const_val.len);
- memcpy (buf + left -> data.const_val.len,
- right -> data.const_val.data,
- right -> data.const_val.len);
- dfree (left -> data.const_val.data, "tree_concat");
- dfree (right -> data.const_val.data, "tree_concat");
- left -> data.const_val.data = buf;
- left -> data.const_val.len += right -> data.const_val.len;
- free_tree (right, "tree_concat");
- return left;
- }
-
- /* Otherwise, allocate a new node to concatenate the two. */
- if (!(nt = new_tree ("tree_concat")))
- error ("No memory for data tree concatenation node.");
- nt -> op = TREE_CONCAT;
- nt -> data.concat.left = left;
- nt -> data.concat.right = right;
- return nt;
-}
-
-struct tree *tree_limit (tree, limit)
- struct tree *tree;
- int limit;
-{
- struct tree *rv;
-
- /* If the tree we're limiting is constant, limit it now. */
- if (tree -> op == TREE_CONST) {
- if (tree -> data.const_val.len > limit)
- tree -> data.const_val.len = limit;
- return tree;
- }
-
- /* Otherwise, put in a node which enforces the limit on evaluation. */
- rv = new_tree ("tree_limit");
- if (!rv)
- return (struct tree *)0;
- rv -> op = TREE_LIMIT;
- rv -> data.limit.tree = tree;
- rv -> data.limit.limit = limit;
- return rv;
-}
-
-int tree_evaluate (tree_cache)
- struct tree_cache *tree_cache;
-{
- unsigned char *bp = tree_cache -> value;
- int bc = tree_cache -> buf_size;
- int bufix = 0;
-
- /* If there's no tree associated with this cache, it evaluates
- to a constant and that was detected at startup. */
- if (!tree_cache -> tree)
- return 1;
-
- /* Try to evaluate the tree without allocating more memory... */
- tree_cache -> timeout = tree_evaluate_recurse (&bufix, &bp, &bc,
- tree_cache -> tree);
-
- /* No additional allocation needed? */
- if (bufix <= bc) {
- tree_cache -> len = bufix;
- return 1;
- }
-
- /* If we can't allocate more memory, return with what we
- have (maybe nothing). */
- if (!(bp = (unsigned char *)dmalloc (bufix, "tree_evaluate")))
- return 0;
-
- /* Record the change in conditions... */
- bc = bufix;
- bufix = 0;
-
- /* Note that the size of the result shouldn't change on the
- second call to tree_evaluate_recurse, since we haven't
- changed the ``current'' time. */
- tree_evaluate_recurse (&bufix, &bp, &bc, tree_cache -> tree);
-
- /* Free the old buffer if needed, then store the new buffer
- location and size and return. */
- if (tree_cache -> value)
- dfree (tree_cache -> value, "tree_evaluate");
- tree_cache -> value = bp;
- tree_cache -> len = bufix;
- tree_cache -> buf_size = bc;
- return 1;
-}
-
-static TIME tree_evaluate_recurse (bufix, bufp, bufcount, tree)
- int *bufix;
- unsigned char **bufp;
- int *bufcount;
- struct tree *tree;
-{
- int limit;
- TIME t1, t2;
-
- switch (tree -> op) {
- case TREE_CONCAT:
- t1 = tree_evaluate_recurse (bufix, bufp, bufcount,
- tree -> data.concat.left);
- t2 = tree_evaluate_recurse (bufix, bufp, bufcount,
- tree -> data.concat.right);
- if (t1 > t2)
- return t2;
- return t1;
-
- case TREE_HOST_LOOKUP:
- return do_host_lookup (bufix, bufp, bufcount,
- tree -> data.host_lookup.host);
-
- case TREE_CONST:
- do_data_copy (bufix, bufp, bufcount,
- tree -> data.const_val.data,
- tree -> data.const_val.len);
- t1 = MAX_TIME;
- return t1;
-
- case TREE_LIMIT:
- limit = *bufix + tree -> data.limit.limit;
- t1 = tree_evaluate_recurse (bufix, bufp, bufcount,
- tree -> data.limit.tree);
- *bufix = limit;
- return t1;
-
- default:
- warn ("Bad node id in tree: %d.");
- t1 = MAX_TIME;
- return t1;
- }
-}
-
-static TIME do_host_lookup (bufix, bufp, bufcount, dns)
- int *bufix;
- unsigned char **bufp;
- int *bufcount;
- struct dns_host_entry *dns;
-{
- struct hostent *h;
- int i;
- int new_len;
-
-#ifdef DEBUG_EVAL
- debug ("time: now = %d dns = %d %d diff = %d",
- cur_time, dns -> timeout, cur_time - dns -> timeout);
-#endif
-
- /* If the record hasn't timed out, just copy the data and return. */
- if (cur_time <= dns -> timeout) {
-#ifdef DEBUG_EVAL
- debug ("easy copy: %x %d %x",
- dns -> data, dns -> data_len,
- dns -> data ? *(int *)(dns -> data) : 0);
-#endif
- do_data_copy (bufix, bufp, bufcount,
- dns -> data, dns -> data_len);
- return dns -> timeout;
- }
-#ifdef DEBUG_EVAL
- debug ("Looking up %s", dns -> hostname);
-#endif
-
- /* Otherwise, look it up... */
- h = gethostbyname (dns -> hostname);
- if (!h) {
- switch (h_errno) {
- case HOST_NOT_FOUND:
- warn ("%s: host unknown.", dns -> hostname);
- break;
- case TRY_AGAIN:
- warn ("%s: temporary name server failure",
- dns -> hostname);
- break;
- case NO_RECOVERY:
- warn ("%s: name server failed", dns -> hostname);
- break;
- case NO_DATA:
- warn ("%s: no A record associated with address",
- dns -> hostname);
- }
-
- /* Okay to try again after a minute. */
- return cur_time + 60;
- }
-
-#ifdef DEBUG_EVAL
- debug ("Lookup succeeded; first address is %x",
- h -> h_addr_list [0]);
-#endif
-
- /* Count the number of addresses we got... */
- for (i = 0; h -> h_addr_list [i]; i++)
- ;
-
- /* Do we need to allocate more memory? */
- new_len = i * h -> h_length;
- if (dns -> buf_len < i) {
- unsigned char *buf =
- (unsigned char *)dmalloc (new_len, "do_host_lookup");
- /* If we didn't get more memory, use what we have. */
- if (!buf) {
- new_len = dns -> buf_len;
- if (!dns -> buf_len) {
- dns -> timeout = cur_time + 60;
- return dns -> timeout;
- }
- } else {
- if (dns -> data)
- dfree (dns -> data, "do_host_lookup");
- dns -> data = buf;
- dns -> buf_len = new_len;
- }
- }
-
- /* Addresses are conveniently stored one to the buffer, so we
- have to copy them out one at a time... :'( */
- for (i = 0; i < new_len / h -> h_length; i++) {
- memcpy (dns -> data + h -> h_length * i,
- h -> h_addr_list [i], h -> h_length);
- }
-#ifdef DEBUG_EVAL
- debug ("dns -> data: %x h -> h_addr_list [0]: %x",
- *(int *)(dns -> data), h -> h_addr_list [0]);
-#endif
- dns -> data_len = new_len;
-
- /* Set the timeout for an hour from now.
- XXX This should really use the time on the DNS reply. */
- dns -> timeout = cur_time + 3600;
-
-#ifdef DEBUG_EVAL
- debug ("hard copy: %x %d %x",
- dns -> data, dns -> data_len, *(int *)(dns -> data));
-#endif
- do_data_copy (bufix, bufp, bufcount, dns -> data, dns -> data_len);
- return dns -> timeout;
-}
-
-static void do_data_copy (bufix, bufp, bufcount, data, len)
- int *bufix;
- unsigned char **bufp;
- int *bufcount;
- unsigned char *data;
- int len;
-{
- int space = *bufcount - *bufix;
-
- /* If there's more space than we need, use only what we need. */
- if (space > len)
- space = len;
-
- /* Copy as much data as will fit, then increment the buffer index
- by the amount we actually had to copy, which could be more. */
- if (space > 0)
- memcpy (*bufp + *bufix, data, space);
- *bufix += len;
-}
diff --git a/includes/cdefs.h b/includes/cdefs.h
deleted file mode 100644
index 2bc67a52..00000000
--- a/includes/cdefs.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* cdefs.h
-
- Standard C definitions... */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium.
- * All Rights Reserved.
- * Copyright (c) 1995 RadioMail Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of RadioMail Corporation, the Internet Software
- * Consortium nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RADIOMAIL CORPORATION, THE INTERNET
- * SOFTWARE CONSORTIUM AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL RADIOMAIL CORPORATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software was written for RadioMail Corporation by Ted Lemon
- * under a contract with Vixie Enterprises. Further modifications have
- * been made for the Internet Software Consortium under a contract
- * with Vixie Laboratories.
- */
-
-#if (defined (__GNUC__) || defined (__STDC__)) && !defined (BROKEN_ANSI)
-#define PROTO(x) x
-#define KandR(x)
-#define ANSI_DECL(x) x
-#if defined (__GNUC__)
-#define INLINE inline
-#else
-#define INLINE
-#endif /* __GNUC__ */
-#else
-#define PROTO(x) ()
-#define KandR(x) x
-#define ANSI_DECL(x)
-#define INLINE
-#endif /* __GNUC__ || __STDC__ */
diff --git a/includes/cf/alphaosf.h b/includes/cf/alphaosf.h
deleted file mode 100644
index 6f154b42..00000000
--- a/includes/cf/alphaosf.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* alphaosf.h
-
- System dependencies for DEC Alpha/OSF1... */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software was written for the Internet Software Consortium by Ted Lemon
- * under a contract with Vixie Laboratories.
- */
-
-/* Define the basic integer types... */
-typedef char int8_t;
-typedef short int16_t;
-typedef int int32_t;
-
-typedef unsigned char u_int8_t;
-typedef unsigned short u_int16_t;
-typedef unsigned int u_int32_t;
-
-#include <syslog.h>
-#include <sys/types.h>
-#include <string.h>
-#include <paths.h>
-#include <errno.h>
-#include <malloc.h>
-#include <unistd.h>
-#include <setjmp.h>
-#include <limits.h>
-
-#include <sys/wait.h>
-#include <signal.h>
-
-extern int h_errno;
-
-#include <net/if.h>
-#include <net/if_dl.h>
-
-/* Varargs stuff... */
-#include <varargs.h>
-#define VA_DOTDOTDOT va_alist
-#define VA_start(list, last) va_start (list)
-
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
-#endif
-
-#define EOL '\n'
-#define VOIDPTR void *
-
-/* Time stuff... */
-#include <sys/time.h>
-#define TIME time_t
-#define GET_TIME(x) time ((x))
-
-/* The jmp_buf type is an array on OSF/1, so we can't dereference it
- and must declare it differently. */
-#define jbp_decl(x) jmp_buf x
-#define jref(x) (x)
-#define jdref(x) (x)
-#define jrefproto jmp_buf
-
-/* OSF/1 doesn't support limited sprintfs. */
-#define vsnprintf(buf, size, fmt, list) vsprintf (buf, fmt, list)
-#define NO_SNPRINTF
-
-#define NEED_OSF_PFILT_HACKS
-#define BPF_FORMAT "/dev/pf/pfilt%d"
-
-#if defined (USE_DEFAULT_NETWORK)
-# define USE_BPF
-#endif
diff --git a/includes/cf/bsdos.h b/includes/cf/bsdos.h
deleted file mode 100644
index 8af03e9b..00000000
--- a/includes/cf/bsdos.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* bsdos.h
-
- System dependencies for BSDI BSD/OS... */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software was written for the Internet Software Consortium by Ted Lemon
- * under a contract with Vixie Laboratories.
- */
-
-#include <syslog.h>
-#include <sys/types.h>
-#include <string.h>
-#include <paths.h>
-#include <errno.h>
-#include <unistd.h>
-#include <setjmp.h>
-#include <limits.h>
-
-#include <sys/wait.h>
-#include <signal.h>
-
-extern int h_errno;
-
-#include <net/if.h>
-#include <net/if_dl.h>
-#define INADDR_LOOPBACK ((u_int32_t)0x7f000001)
-
-/* Varargs stuff... */
-#include <stdarg.h>
-#define VA_DOTDOTDOT ...
-#define va_dcl
-#define VA_start(list, last) va_start (list, last)
-
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
-#endif
-#ifndef _PATH_DHCPD_DB
-#define _PATH_DHCPD_DB "/var/db/dhcpd.leases"
-#endif
-
-#define EOL '\n'
-#define VOIDPTR void *
-
-/* Time stuff... */
-#include <sys/time.h>
-#define TIME time_t
-#define GET_TIME(x) time ((x))
-
-#define HAVE_SA_LEN
-
-#if defined (USE_DEFAULT_NETWORK)
-# define USE_BPF
-#endif
diff --git a/includes/cf/freebsd.h b/includes/cf/freebsd.h
deleted file mode 100644
index 618f74a4..00000000
--- a/includes/cf/freebsd.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* freebsd.h
-
- System dependencies for FreeBSD... */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software was written for the Internet Software Consortium by Ted Lemon
- * under a contract with Vixie Laboratories.
- */
-
-#define _ANSI_SOURCE
-
-#include <syslog.h>
-#include <sys/types.h>
-#include <string.h>
-#include <paths.h>
-#include <errno.h>
-#include <unistd.h>
-#include <setjmp.h>
-#include <limits.h>
-
-#include <sys/wait.h>
-#include <signal.h>
-
-extern int h_errno;
-
-#include <net/if.h>
-#include <net/if_dl.h>
-#define INADDR_LOOPBACK ((u_int32_t)0x7f000001)
-
-/* Varargs stuff... */
-#include <stdarg.h>
-#define VA_DOTDOTDOT ...
-#define va_dcl
-#define VA_start(list, last) va_start (list, last)
-
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
-#endif
-#ifndef _PATH_DHCPD_DB
-#define _PATH_DHCPD_DB "/var/db/dhcpd.leases"
-#endif
-
-#define EOL '\n'
-#define VOIDPTR void *
-
-/* Time stuff... */
-#include <sys/time.h>
-#define TIME time_t
-#define GET_TIME(x) time ((x))
-
-#define HAVE_SA_LEN
-
-#if defined (USE_DEFAULT_NETWORK)
-# define USE_BPF
-# define BROKEN_FREEBSD_BPF /* Fixed in 2.2 */
-#endif
diff --git a/includes/cf/hpux.h b/includes/cf/hpux.h
deleted file mode 100644
index c5d2cdf8..00000000
--- a/includes/cf/hpux.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* hpux.h */
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define int8_t char
-#define int16_t short
-#define int32_t long
-
-#define u_int8_t unsigned char
-#define u_int16_t unsigned short
-#define u_int32_t unsigned long
-
-#include <sys/types.h>
-
-#include <syslog.h>
-
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <limits.h>
-
-extern int h_errno;
-
-#include <net/if.h>
-#include <net/if_arp.h>
-
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
-#endif
-
-#include <varargs.h>
-#define VA_DOTDOTDOT va_alist
-#define VA_start(list, last) va_start (list)
-
-#define vsnprintf(buf, size, fmt, list) vsprintf (buf, fmt, list)
-#define NO_SNPRINTF
-
-#define USE_SOCKETS 1
-#define EOL '\n'
-#define VOIDPTR void *
-
-#include <time.h>
-
-#define TIME time_t
-#define GET_TIME(x) time ((x))
-
-#define random rand
diff --git a/includes/cf/linux.h b/includes/cf/linux.h
deleted file mode 100644
index 8e439d0b..00000000
--- a/includes/cf/linux.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* linux.h
-
- System dependencies for Linux.
-
- Based on a configuration originally supplied by Jonathan Stone. */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <features.h>
-#ifndef __BIT_TYPES_DEFINED__
-#define __BIT_TYPES_DEFINED__
-#undef __USE_BSD
-typedef char int8_t;
-typedef short int16_t;
-typedef long int32_t;
-
-typedef unsigned char u_int8_t;
-typedef unsigned short u_int16_t;
-typedef unsigned long u_int32_t;
-#endif /* __BIT_TYPES_DEFINED__ */
-
-#include <syslog.h>
-#include <sys/types.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <limits.h>
-
-extern int h_errno;
-
-#include <net/if.h>
-
-#include <sys/time.h> /* gettimeofday()*/
-#include <linux/time.h> /* also necessary */
-
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
-#endif
-
-/* Varargs stuff... */
-#include <stdarg.h>
-#define VA_DOTDOTDOT ...
-#define VA_start(list, last) va_start (list, last)
-#define va_dcl
-
-#define vsnprintf(buf, size, fmt, list) vsprintf (buf, fmt, list)
-#define NO_SNPRINTF
-
-#define VOIDPTR void *
-
-#define EOL '\n'
-
-/* Time stuff... */
-
-#include <time.h>
-
-#define TIME time_t
-#define GET_TIME(x) time ((x))
-
-#if defined (USE_DEFAULT_NETWORK)
-# define USE_SOCKETS
-#endif
-
-#define ALIAS_NAMES_PERMUTED
diff --git a/includes/cf/netbsd.h b/includes/cf/netbsd.h
deleted file mode 100644
index 23f0b30d..00000000
--- a/includes/cf/netbsd.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* netbsd.h
-
- System dependencies for NetBSD... */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software was written for the Internet Software Consortium by Ted Lemon
- * under a contract with Vixie Laboratories.
- */
-
-#include <syslog.h>
-#include <sys/types.h>
-#include <string.h>
-#include <paths.h>
-#include <errno.h>
-#include <malloc.h>
-#include <unistd.h>
-#include <setjmp.h>
-#include <limits.h>
-
-#include <sys/wait.h>
-#include <signal.h>
-
-extern int h_errno;
-
-#include <net/if.h>
-#include <net/if_dl.h>
-
-/* Varargs stuff... */
-#include <stdarg.h>
-#define VA_DOTDOTDOT ...
-#define va_dcl
-#define VA_start(list, last) va_start (list, last)
-
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
-#endif
-#ifndef _PATH_DHCPD_DB
-#define _PATH_DHCPD_DB "/var/db/dhcpd.leases"
-#endif
-
-#define EOL '\n'
-#define VOIDPTR void *
-
-/* Time stuff... */
-#include <sys/time.h>
-#define TIME time_t
-#define GET_TIME(x) time ((x))
-
-#define HAVE_SA_LEN
-
-#if defined (USE_DEFAULT_NETWORK)
-# define USE_BPF
-#endif
diff --git a/includes/cf/qnx.h b/includes/cf/qnx.h
deleted file mode 100644
index a6127586..00000000
--- a/includes/cf/qnx.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* qnx.h
-
- System dependencies for QNX...
-*/
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of RadioMail Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY RADIOMAIL CORPORATION AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * RADIOMAIL CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software was written for the Internet Software Consortium by Ted Lemon
- * under a contract with Vixie Labs.
- */
-
-#include <sys/types.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <setjmp.h>
-#include <limits.h>
-#include <syslog.h>
-#include <sys/select.h>
-
-#include <sys/wait.h>
-#include <signal.h>
-
-#include <netdb.h>
-extern int h_errno;
-
-#include <net/if.h>
-#define INADDR_LOOPBACK ((u_long)0x7f000001)
-
-/* Varargs stuff... */
-#include <stdarg.h>
-#define VA_DOTDOTDOT ...
-#define va_dcl
-#define VA_start(list, last) va_start (list, last)
-
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
-#endif
-
-#define EOL '\n'
-#define VOIDPTR void *
-
-/* Time stuff... */
-#include <sys/time.h>
-#define TIME time_t
-#define GET_TIME(x) time ((x))
-#define TIME_DIFF(high, low) (*(high) - *(low))
-#define SET_TIME(x, y) (*(x) = (y))
-#define ADD_TIME(d, s1, s2) (*(d) = *(s1) + *(s2))
-#define SET_MAX_TIME(x) (*(x) = INT_MAX)
-
-typedef unsigned char u_int8_t;
-typedef unsigned short u_int16_t;
-typedef unsigned long u_int32_t;
-typedef signed short int16_t;
-typedef signed long int32_t;
-
-#define strcasecmp( s1, s2 ) stricmp( s1, s2 )
-#define strncasecmp( s1, s2, n ) strnicmp( s1, s2, n )
-#define vsnprintf( buf, size, fmt, list ) vsprintf( buf, fbuf, list )
-#define random() rand()
-
-#define HAVE_SA_LEN
-#define BROKEN_TM_GMT
-#define USE_SOCKETS
-#define NO_SNPRINTF
-#undef AF_LINK
-
-/*
- NOTE: to get the routing of the 255.255.255.255 broadcasts to work
- under QNX, you need to issue the following command before starting
- the daemon:
-
- route add -interface 255.255.255.0 <hostname>
-
- where <hostname> is replaced by the hostname or IP number of the
- machine that dhcpd is running on.
-*/
diff --git a/includes/cf/sample.h b/includes/cf/sample.h
deleted file mode 100644
index 8fe45f4b..00000000
--- a/includes/cf/sample.h
+++ /dev/null
@@ -1,292 +0,0 @@
-/* sample.h
-
- Sample config file for clients.
-
- This file is provided as a sample in case the system you want to run
- on is not currently supported. If that is the case, follow the Porting::
- comments here and in other files as guides for what to change. */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-/* Porting::
-
- Some systems do not define basic integer types as shown below.
- On some systems, you need to include <bitypes.h> or <sys/bitypes.h>.
- If you get parse errors in dhcpd.h while compiling dhcpd.conf, try
- including bitypes.h, and if that fails, use the hard-coded definitions
- shown below. */
-
-#if 0
-#include <sys/bitypes.h>
-#endif
-
-#if 0
-#define int8_t char
-#define int16_t short
-#define int32_t long
-
-#define u_int8_t unsigned char
-#define u_int16_t unsigned short
-#define u_int32_t unsigned long
-#endif
-
-#include <sys/types.h>
-
-/* Porting::
-
- The jmp_buf type as declared in <setjmp.h> is sometimes a structure
- and sometimes an array. By default, we assume it's a structure.
- If it's an array on your system, you may get compile warnings or errors
- as a result in confpars.c. If so, try including the following definitions,
- which treat jmp_buf as an array: */
-
-#if 0
-#define jbp_decl(x) jmp_buf x
-#define jref(x) (x)
-#define jdref(x) (x)
-#define jrefproto jmp_buf
-#endif
-
-/* Porting::
-
- Some older systems (e.g., Ultrix) still use the 4.2BSD-style syslog
- API. These differ from later versions of the syslog API in that the
- openlog system call takes two arguments instead of three, and the
- facility code (the third argument to modern versions of openlog())
- is ORed into the log priority in the syslog() call.
-
- If you are running with the 4.2BSD-style syslog interface, define
- SYSLOG_4_2. */
-
-/* #define SYSLOG_4_2 */
-
-#include <syslog.h>
-
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <limits.h>
-
-extern int h_errno;
-
-#include <net/if.h>
-#include <net/if_arp.h>
-
-/* Porting::
-
- Some older systems do not have defines for IP type-of-service,
- or don't define them the way we expect. If you get undefined
- symbol errors on the following symbols, they probably need to be
- defined here. */
-
-#if 0
-#define IPTOS_LOWDELAY 0x10
-#define IPTOS_THROUGHPUT 0x08
-#define IPTOS_RELIABILITY 0x04
-#endif
-
-/* Porting::
-
- Newer BSD derivatives store non-permanent daemon files in a
- directory called /var/run. If your system has a /var/run,
- use it; otherwise, use /etc. */
-
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
-#endif
-
-/* Porting::
-
- If your system supports standard ANSI C, it should provide the file
- /usr/include/stdarg.h. This contains the ANSI standard declarations
- for functions which take a variable number of arguments.
-
- Older systems with non-ANSI compilers cannot support this interface,
- and generally use the older varargs interface, defined in <varargs.h>.
- Some systems only support varargs, but define the interface in
- <stdarg.h> anyway.
-
- You must choose one of the two sets of definitions below. Try
- stdarg.h first, unless you know it won't work. If you have
- trouble compiling errwarn.c, try switching to the varargs.h definitions.
- If that fails, try using stdarg.h with the varargs definitions. */
-
-#if 0
-/* Stdarg definitions for ANSI-compliant C compilers. */
-#include <stdarg.h>
-#define VA_DOTDOTDOT ...
-#define VA_start(list, last) va_start (list, last)
-#define va_dcl
-#endif
-
-#if 0
-/* Varargs definitions, for non-ANSI-compliant C compilers. */
-#include <varargs.h>
-#define VA_DOTDOTDOT va_alist
-#define VA_start(list, last) va_start (list)
-#endif
-
-/* Porting::
-
- Some systems (notably 4.4BSD derivatives) support versions of the
- sprintf functions which will deposit a limited number of characters
- into the buffer; that limit is provided in an extra argument.
- If your system doesn't support this functionality, you must include
- the definitions below: */
-
-#if 0
-#define vsnprintf(buf, size, fmt, list) vsprintf (buf, fmt, list)
-#define NO_SNPRINTF
-#endif
-
-/* Porting::
-
- Some systems provide a function, strerror(), which takes the unix
- error number (see errno) and returns a pointer to a static buffer
- containing the corresponding error message.
-
- If your system doesn't provide strerror(), define NO_STRERROR
- as shown below: */
-
-#if 0
-#define NO_STRERROR
-char *strerror PROTO ((int));
-#endif
-
-/* Porting::
-
- Once dhcpd has initialized itself, it loops forever waiting for
- packets to come in. Since we need to support multiple input streams
- in order to support multiple interfaces, dhcpd needs to be able to
- do a syscall to determine which descriptors have input waiting on
- them.
-
- Normally, dhcpd uses the select() system call, which is a 4.2BSD
- syscall invented precisely for this purpose. Unfortunately, some
- System V-based systems do not support select() properly when it
- operates on streams. The System V interface which does (largely)
- the same thing as select is called poll(). In some cases, this may
- work better than select() - if you find that dhcpd is hanging and not
- responding to packets very consistently, you might try defining
- USE_POLL and including <poll.h>. */
-
-#if 0
-#define USE_POLL
-#include <poll.h>
-#endif
-
-/* Porting::
-
- You must define the default network API for your port. This
- will depend on whether one of the existing APIs will work for
- you, or whether you need to implement support for a new API.
- Currently, the following APIs are supported:
-
- The BSD socket API: define USE_SOCKETS.
- The Berkeley Packet Filter: define USE_BPF.
- The Streams Network Interface Tap (NIT): define USE_NIT.
- Raw sockets: define USE_RAW_SOCKETS
-
- If your system supports the BSD socket API and doesn't provide
- one of the supported interfaces to the physical packet layer,
- you can either provide support for the low-level API that your
- system does support (if any) or just use the BSD socket interface.
- The BSD socket interface doesn't support multiple network interfaces,
- and on many systems, it does not support the all-ones broadcast
- address, which can cause problems with some DHCP clients (e.g.
- Microsoft Windows 95). */
-
-#if defined (USE_DEFAULT_NETWORK)
-# define USE_SOCKETS
-#endif
-
-/* Porting::
-
- Recent versions of BSD added a new element to the sockaddr structure:
- sa_len. This indicates the length of the structure, and is used
- in a variety of places, not the least of which is the SIOCGIFCONF
- ioctl, which is used to figure out what interfaces are attached to
- the system.
-
- You should be able to determine if your system has an sa_len element
- by looking at the struct sockaddr definition in /usr/include/sys/socket.h.
- If it does, you must define HAVE_SA_LEN. Otherwise, you must not.
- The most obvious symptom that you've got this wrong is either a compile
- error complaining about the use of the sa_len structure element, or
- the failure of dhcpd to find any interfaces. */
-
-/* #define HAVE_SA_LEN */
-
-/* Every operating system has its own way of seperating lines in a
- sequential text file. Most modern systems use a single character,
- either an ASCII Newline (10) or an ASCII Carriage Return (13).
-
- The most notable exception is MS-DOS (and consequently, Windows),
- which uses an ASCII Carriage Return followed by a Newline to
- seperate each line. Fortunately, MS-DOS C compiler libraries
- typically hide this from the programmer, returning just a Newline.
-
- Define EOL to be whatever getc() returns for a newline. */
-
-#define EOL '\n'
-
-/* Some older C compilers don't support the void pointer type.
- ANSI C defines void * to be a pointer type that matches
- any other pointer type. This is handy for returning a pointer
- which will always need to be cast to a different value. For
- example, malloc() on an ANSI C-compliant system returns void *.
-
- If your compiler doesn't support void pointers, you may need to
- define VOIDPTR to be char *; otherwise, define it to be void *. */
-
-#define VOIDPTR void *
-
-/* Porting::
-
- The following definitions for time should work on any unix machine.
- They may not work (or at least, may not work well) on a variety of
- non-unix machines. If you are porting to a non-unix machine, you
- probably need to change the definitions below and perhaps include
- different headers.
-
- I should note that dhcpd is not yet entirely clean of unix-specific
- time references, so the list of defines shown below probably isn't
- good enough if you're porting to a system that really doesn't support
- unix time. It's probably a reasonable place to start, though. */
-
-#include <time.h>
-
-#define TIME time_t
-#define GET_TIME(x) time ((x))
diff --git a/includes/cf/sco.h b/includes/cf/sco.h
deleted file mode 100644
index d839f974..00000000
--- a/includes/cf/sco.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* sco.h
-
- System dependencies for SCO ODT 3.0...
-
- Based on changes contributed by Gerald Rosenberg. */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software was written for the Internet Software Consortium by Ted Lemon
- * under a contract with Vixie Laboratories.
- */
-
-#include <syslog.h>
-#include <sys/types.h>
-
-/* Basic Integer Types not defined in SCO headers... */
-
-typedef char int8_t;
-typedef short int16_t;
-typedef long int32_t;
-
-typedef unsigned char u_int8_t;
-typedef unsigned short u_int16_t;
-typedef unsigned long u_int32_t;
-
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <limits.h>
-
-extern int h_errno;
-
-#include <net/if.h>
-#include <net/if_arp.h>
-
-/* XXX dunno if this is required for SCO... */
-/*
- * Definitions for IP type of service (ip_tos)
- */
-#define IPTOS_LOWDELAY 0x10
-#define IPTOS_THROUGHPUT 0x08
-#define IPTOS_RELIABILITY 0x04
-/* IPTOS_LOWCOST 0x02 XXX */
-
-/* SCO doesn't have /var/run. */
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
-#endif
-
-#define INADDR_LOOPBACK ((u_int32_t)0x7f000001)
-
-/* Varargs stuff: use stdarg.h instead ... */
-#include <stdarg.h>
-#define VA_DOTDOTDOT ...
-#define VA_start(list, last) va_start (list, last)
-#define va_dcl
-
-/* SCO doesn't support limited sprintfs. */
-#define vsnprintf(buf, size, fmt, list) vsprintf (buf, fmt, list)
-#define NO_SNPRINTF
-
-/* By default, use BSD Socket API for receiving and sending packets.
- This actually works pretty well on Solaris, which doesn't censor
- the all-ones broadcast address. */
-#if defined (USE_DEFAULT_NETWORK)
-# define USE_SOCKETS
-#endif
-
-#define EOL '\n'
-#define VOIDPTR void *
-
-/*
- * Time stuff...
- *
- * Definitions for an ISC DHCPD system that uses time_t
- * to represent time internally as opposed to, for example, struct timeval.)
- */
-
-#include <time.h>
-
-#define TIME time_t
-#define GET_TIME(x) time ((x))
diff --git a/includes/cf/sunos4.h b/includes/cf/sunos4.h
deleted file mode 100644
index dc7743ea..00000000
--- a/includes/cf/sunos4.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* sunos4.h
-
- System dependencies for SunOS 4 (tested on 4.1.4)... */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software was written for the Internet Software Consortium by Ted Lemon
- * under a contract with Vixie Laboratories.
- */
-
-/* Basic Integer Types not defined in SunOS headers... */
-
-#define int8_t char
-#define int16_t short
-#define int32_t int
-
-#define u_int8_t unsigned char
-#define u_int16_t unsigned short
-#define u_int32_t unsigned int
-
-/* No endian.h either. */
-/*
- * Definitions for byte order, according to byte significance from low
- * address to high.
- */
-#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
-#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
-#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
-
-#define BYTE_ORDER BIG_ENDIAN
-
-/* The jmp_buf type is an array on SunOS, so we can't dereference it
- and must declare it differently. */
-#define jbp_decl(x) jmp_buf x
-#define jref(x) (x)
-#define jdref(x) (x)
-#define jrefproto jmp_buf
-
-#include <syslog.h>
-#include <sys/types.h>
-
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <limits.h>
-#include <poll.h>
-
-extern int h_errno;
-
-#include <net/if.h>
-#include <net/if_arp.h>
-
-/*
- * Definitions for IP type of service (ip_tos)
- */
-#define IPTOS_LOWDELAY 0x10
-#define IPTOS_THROUGHPUT 0x08
-#define IPTOS_RELIABILITY 0x04
-/* IPTOS_LOWCOST 0x02 XXX */
-
-/* SunOS systems don't have /var/run, but some sites have added it.
- If you want to put dhcpd.pid in /var/run, define _PATH_DHCPD_PID
- in site.h. */
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
-#endif
-
-#ifdef __GNUC__
-/* Varargs stuff: use stdarg.h instead ... */
-#include <stdarg.h>
-#define VA_DOTDOTDOT ...
-#define VA_start(list, last) va_start (list, last)
-#define va_dcl
-#else /* !__GNUC__*/
-/* Varargs stuff... */
-#include <varargs.h>
-#define VA_DOTDOTDOT va_alist
-#define VA_start(list, last) va_start (list)
-#endif /* !__GNUC__*/
-
-/* SunOS doesn't support limited sprintfs. */
-#define vsnprintf(buf, size, fmt, list) vsprintf (buf, fmt, list)
-#define NO_SNPRINTF
-
-/* SunOS doesn't supply strerror... */
-#define NO_STRERROR
-char *strerror PROTO ((int));
-
-/* SunOS select() doesn't work on streams, so we have to use poll -
- as usual, SysV can't do networking to save its life. */
-#define USE_POLL
-
-/* By default, use NIT API for receiving and sending packets... */
-#if defined (USE_DEFAULT_NETWORK)
-# define USE_NIT
-#endif
-
-#define EOL '\n'
-#define VOIDPTR void *
-
-#include <time.h>
-
-#define TIME time_t
-#define GET_TIME(x) time ((x))
diff --git a/includes/cf/sunos5-5.h b/includes/cf/sunos5-5.h
deleted file mode 100644
index e7cdea62..00000000
--- a/includes/cf/sunos5-5.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/* sunos5-5.h
-
- System dependencies for Solaris 2.x (tested on 2.5 with gcc)... */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software was written for the Internet Software Consortium by Ted Lemon
- * under a contract with Vixie Laboratories.
- */
-
-/* Basic Integer Types not defined in SunOS headers... */
-
-#define int8_t char
-#define int16_t short
-#define int32_t long
-
-#define u_int8_t unsigned char
-#define u_int16_t unsigned short
-#define u_int32_t unsigned long
-
-/* The jmp_buf type is an array on Solaris, so we can't dereference it
- and must declare it differently. */
-
-#define jbp_decl(x) jmp_buf x
-#define jref(x) (x)
-#define jdref(x) (x)
-#define jrefproto jmp_buf
-
-#include <syslog.h>
-#include <sys/types.h>
-#include <sys/sockio.h>
-
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <limits.h>
-
-extern int h_errno;
-
-#include <net/if.h>
-#include <net/if_arp.h>
-
-/*
- * Definitions for IP type of service (ip_tos)
- */
-#define IPTOS_LOWDELAY 0x10
-#define IPTOS_THROUGHPUT 0x08
-#define IPTOS_RELIABILITY 0x04
-/* IPTOS_LOWCOST 0x02 XXX */
-
-/* Solaris systems don't have /var/run, but some sites have added it.
- If you want to put dhcpd.pid in /var/run, define _PATH_DHCPD_PID
- in site.h. */
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
-#endif
-
-#if defined (__GNUC__) || defined (__SVR4)
-/* Varargs stuff: use stdarg.h instead ... */
-#include <stdarg.h>
-#define VA_DOTDOTDOT ...
-#define VA_start(list, last) va_start (list, last)
-#define va_dcl
-#else /* !__GNUC__*/
-/* Varargs stuff... */
-#include <varargs.h>
-#define VA_DOTDOTDOT va_alist
-#define VA_start(list, last) va_start (list)
-#endif /* !__GNUC__*/
-
-/* Solaris doesn't support limited sprintfs. */
-#define vsnprintf(buf, size, fmt, list) vsprintf (buf, fmt, list)
-#define NO_SNPRINTF
-
-/* By default, use BSD Socket API for receiving and sending packets.
- This actually works pretty well on Solaris, which doesn't censor
- the all-ones broadcast address. */
-#if defined (USE_DEFAULT_NETWORK)
-# define USE_SOCKETS
-#endif
-
-#define USE_POLL
-
-#define EOL '\n'
-#define VOIDPTR void *
-
-/* Time stuff... */
-
-#include <time.h>
-
-#define TIME time_t
-#define GET_TIME(x) time ((x))
-
-#define random() rand()
diff --git a/includes/cf/ultrix.h b/includes/cf/ultrix.h
deleted file mode 100644
index 2c881b96..00000000
--- a/includes/cf/ultrix.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* ultrix.h
-
- System dependencies for Ultrix 4.2 (tested on 4.2a+multicast)... */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software was written for the Internet Software Consortium by Ted Lemon
- * under a contract with Vixie Laboratories.
- */
-
-/* Ultrix uses the old 4.2BSD-style syslog(). */
-#include <sys/syslog.h>
-#define SYSLOG_4_2
-
-#include <sys/types.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <limits.h>
-
-extern int h_errno;
-
-#include <net/if.h>
-
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
-#endif
-
-#define int8_t char
-#define int16_t short
-#define int32_t long
-
-#define u_int8_t unsigned char /* Not quite POSIX... */
-#define u_int16_t unsigned short
-#define u_int32_t unsigned long
-
-/* The jmp_buf type is an array on ultrix, so we can't dereference it
- and must declare it differently. */
-#define jbp_decl(x) jmp_buf x
-#define jref(x) (x)
-#define jdref(x) (x)
-#define jrefproto jmp_buf
-
-#define IPTOS_LOWDELAY 0x10
-/* IPTOS_LOWCOST 0x02 XXX */
-
-/* Varargs stuff... */
-#include <varargs.h>
-#define VA_DOTDOTDOT va_alist
-#define VA_start(list, last) va_start (list)
-#define vsnprintf(buf, size, fmt, list) vsprintf (buf, fmt, list)
-#define NO_SNPRINTF
-
-#define INADDR_LOOPBACK ((u_int32_t)0x7f000001)
-#define EOL '\n'
-#define VOIDPTR void *
-
-/*
- * Time stuff...
- *
- * Definitions for an ISC DHCPD system that uses time_t
- * to represent time internally as opposed to, for example, struct timeval.)
- */
-
-#define TIME time_t
-#define GET_TIME(x) time ((x))
-
-#if defined (USE_DEFAULT_NETWORK)
-# define USE_SOCKETS
-#endif
diff --git a/includes/dhcp.h b/includes/dhcp.h
deleted file mode 100644
index 23a8bf73..00000000
--- a/includes/dhcp.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/* dhcp.h
-
- Protocol structures... */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \
- 20 + /* IP header */ \
- 8) /* UDP header */
-#define DHCP_SNAME_LEN 64
-#define DHCP_FILE_LEN 128
-#define DHCP_FIXED_NON_UDP 236
-#define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
- /* Everything but options. */
-#define DHCP_MTU_MAX 1500
-#define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN)
-
-#define BOOTP_MIN_LEN 300
-
-struct dhcp_packet {
- u_int8_t op; /* Message opcode/type */
- u_int8_t htype; /* Hardware addr type (see net/if_types.h) */
- u_int8_t hlen; /* Hardware addr length */
- u_int8_t hops; /* Number of relay agent hops from client */
- u_int32_t xid; /* Transaction ID */
- u_int16_t secs; /* Seconds since client started looking */
- u_int16_t flags; /* Flag bits */
- struct in_addr ciaddr; /* Client IP address (if already in use) */
- struct in_addr yiaddr; /* Client IP address */
- struct in_addr siaddr; /* IP address of next server to talk to */
- struct in_addr giaddr; /* DHCP relay agent IP address */
- unsigned char chaddr [16]; /* Client hardware address */
- char sname [DHCP_SNAME_LEN]; /* Server name */
- char file [DHCP_FILE_LEN]; /* Boot filename */
- unsigned char options [DHCP_OPTION_LEN];
- /* Optional parameters
- (actual length dependent on MTU). */
-};
-
-/* BOOTP (rfc951) message types */
-#define BOOTREQUEST 1
-#define BOOTREPLY 2
-
-/* Possible values for flags field... */
-#define BOOTP_BROADCAST 32768L
-
-/* Possible values for hardware type (htype) field... */
-#define HTYPE_ETHER 1 /* Ethernet 10Mbps */
-#define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring... */
-
-/* Magic cookie validating dhcp options field (and bootp vendor
- extensions field). */
-#define DHCP_OPTIONS_COOKIE "\143\202\123\143"
-
-/* DHCP Option codes: */
-
-#define DHO_PAD 0
-#define DHO_SUBNET_MASK 1
-#define DHO_TIME_OFFSET 2
-#define DHO_ROUTERS 3
-#define DHO_TIME_SERVERS 4
-#define DHO_NAME_SERVERS 5
-#define DHO_DOMAIN_NAME_SERVERS 6
-#define DHO_LOG_SERVERS 7
-#define DHO_COOKIE_SERVERS 8
-#define DHO_LPR_SERVERS 9
-#define DHO_IMPRESS_SERVERS 10
-#define DHO_RESOURCE_LOCATION_SERVERS 11
-#define DHO_HOST_NAME 12
-#define DHO_BOOT_SIZE 13
-#define DHO_MERIT_DUMP 14
-#define DHO_DOMAIN_NAME 15
-#define DHO_SWAP_SERVER 16
-#define DHO_ROOT_PATH 17
-#define DHO_EXTENSIONS_PATH 18
-#define DHO_IP_FORWARDING 19
-#define DHO_NON_LOCAL_SOURCE_ROUTING 20
-#define DHO_POLICY_FILTER 21
-#define DHO_MAX_DGRAM_REASSEMBLY 22
-#define DHO_DEFAULT_IP_TTL 23
-#define DHO_PATH_MTU_AGING_TIMEOUT 24
-#define DHO_PATH_MTU_PLATEAU_TABLE 25
-#define DHO_INTERFACE_MTU 26
-#define DHO_ALL_SUBNETS_LOCAL 27
-#define DHO_BROADCAST_ADDRESS 28
-#define DHO_PERFORM_MASK_DISCOVERY 29
-#define DHO_MASK_SUPPLIER 30
-#define DHO_ROUTER_DISCOVERY 31
-#define DHO_ROUTER_SOLICITATION_ADDRESS 32
-#define DHO_STATIC_ROUTES 33
-#define DHO_TRAILER_ENCAPSULATION 34
-#define DHO_ARP_CACHE_TIMEOUT 35
-#define DHO_IEEE802_3_ENCAPSULATION 36
-#define DHO_DEFAULT_TCP_TTL 37
-#define DHO_TCP_KEEPALIVE_INTERVAL 38
-#define DHO_TCP_KEEPALIVE_GARBAGE 39
-#define DHO_NIS_DOMAIN 40
-#define DHO_NIS_SERVERS 41
-#define DHO_NTP_SERVERS 42
-#define DHO_VENDOR_ENCAPSULATED_OPTIONS 43
-#define DHO_NETBIOS_NAME_SERVERS 44
-#define DHO_NETBIOS_DD_SERVER 45
-#define DHO_NETBIOS_NODE_TYPE 46
-#define DHO_NETBIOS_SCOPE 47
-#define DHO_FONT_SERVERS 48
-#define DHO_X_DISPLAY_MANAGER 49
-#define DHO_DHCP_REQUESTED_ADDRESS 50
-#define DHO_DHCP_LEASE_TIME 51
-#define DHO_DHCP_OPTION_OVERLOAD 52
-#define DHO_DHCP_MESSAGE_TYPE 53
-#define DHO_DHCP_SERVER_IDENTIFIER 54
-#define DHO_DHCP_PARAMETER_REQUEST_LIST 55
-#define DHO_DHCP_MESSAGE 56
-#define DHO_DHCP_MAX_MESSAGE_SIZE 57
-#define DHO_DHCP_RENEWAL_TIME 58
-#define DHO_DHCP_REBINDING_TIME 59
-#define DHO_DHCP_CLASS_IDENTIFIER 60
-#define DHO_DHCP_CLIENT_IDENTIFIER 61
-#define DHO_DHCP_USER_CLASS_ID 77
-#define DHO_END 255
-
-/* DHCP message types. */
-#define DHCPDISCOVER 1
-#define DHCPOFFER 2
-#define DHCPREQUEST 3
-#define DHCPDECLINE 4
-#define DHCPACK 5
-#define DHCPNAK 6
-#define DHCPRELEASE 7
-#define DHCPINFORM 8
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
deleted file mode 100644
index 34aed0b5..00000000
--- a/includes/dhcpd.h
+++ /dev/null
@@ -1,586 +0,0 @@
-/* dhcpd.h
-
- Definitions for dhcpd... */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <time.h>
-
-#include "cdefs.h"
-#include "osdep.h"
-#include "dhcp.h"
-#include "tree.h"
-#include "hash.h"
-#include "inet.h"
-
-/* A dhcp packet and the pointers to its option values. */
-struct packet {
- struct dhcp_packet *raw;
- int packet_length;
- int packet_type;
- int options_valid;
- int client_port;
- struct iaddr client_addr;
- struct interface_info *interface; /* Interface on which packet
- was received. */
- struct hardware *haddr; /* Physical link address
- of local sender (maybe gateway). */
- struct shared_network *shared_network;
- struct {
- int len;
- unsigned char *data;
- } options [256];
-};
-
-struct hardware {
- u_int8_t htype;
- u_int8_t hlen;
- u_int8_t haddr [16];
-};
-
-/* A dhcp lease declaration structure. */
-struct lease {
- struct lease *next;
- struct lease *prev;
- struct lease *n_uid, *n_hw;
- struct iaddr ip_addr;
- TIME starts, ends, timestamp;
- TIME offered_expiry;
- unsigned char *uid;
- int uid_len;
- char *hostname;
- struct host_decl *host;
- struct subnet *subnet;
- struct shared_network *shared_network;
- struct hardware hardware_addr;
- int state;
- int xid;
- int flags;
-# define STATIC_LEASE 1
-# define BOOTP_LEASE 2
-# define DYNAMIC_BOOTP_OK 4
-# define PERSISTENT_FLAGS (DYNAMIC_BOOTP_OK)
-# define EPHEMERAL_FLAGS (BOOTP_LEASE)
-};
-
-#define ROOT_GROUP 0
-#define HOST_DECL 1
-#define SHARED_NET_DECL 2
-#define SUBNET_DECL 3
-#define CLASS_DECL 4
-#define GROUP_DECL 5
-
-/* Group of declarations that share common parameters. */
-struct group {
- struct group *next;
-
- struct subnet *subnet;
- struct shared_network *shared_network;
-
- TIME default_lease_time;
- TIME max_lease_time;
- TIME bootp_lease_cutoff;
- TIME bootp_lease_length;
-
- char *filename;
- char *server_name;
- struct iaddr next_server;
-
- int boot_unknown_clients;
- int dynamic_bootp;
- int one_lease_per_client;
- int get_lease_hostnames;
- int use_host_decl_names;
-
- struct tree_cache *options [256];
-};
-
-/* A dhcp host declaration structure. */
-struct host_decl {
- struct host_decl *n_ipaddr;
- char *name;
- struct hardware interface;
- struct tree_cache *fixed_addr;
- struct group *group;
-};
-
-struct shared_network {
- struct shared_network *next;
- char *name;
- struct subnet *subnets;
- struct interface_info *interface;
- struct lease *leases;
- struct lease *insertion_point;
- struct lease *last_lease;
-
- struct group *group;
-};
-
-struct subnet {
- struct subnet *next_subnet;
- struct subnet *next_sibling;
- struct shared_network *shared_network;
- struct interface_info *interface;
- struct iaddr interface_address;
- struct iaddr net;
- struct iaddr netmask;
-
- struct group *group;
-};
-
-struct class {
- char *name;
-
- struct group *group;
-};
-
-/* Information about each network interface. */
-
-struct interface_info {
- struct interface_info *next; /* Next interface in list... */
- struct shared_network *shared_network;
- /* Networks connected to this interface. */
- struct hardware hw_address; /* Its physical address. */
- char name [IFNAMSIZ]; /* Its name... */
- int rfdesc; /* Its read file descriptor. */
- int wfdesc; /* Its write file descriptor, if
- different. */
- unsigned char *rbuf; /* Read buffer, if required. */
- size_t rbuf_max; /* Size of read buffer. */
- size_t rbuf_offset; /* Current offset into buffer. */
- size_t rbuf_len; /* Length of data in buffer. */
-
- struct ifreq *tif; /* Temp. pointer to ifreq struct. */
- u_int32_t flags; /* Control flags... */
-#define INTERFACE_REQUESTED 1
-};
-
-struct hardware_link {
- struct hardware_link *next;
- char name [IFNAMSIZ];
- struct hardware address;
-};
-
-/* Bitmask of dhcp option codes. */
-typedef unsigned char option_mask [16];
-
-/* DHCP Option mask manipulation macros... */
-#define OPTION_ZERO(mask) (memset (mask, 0, 16))
-#define OPTION_SET(mask, bit) (mask [bit >> 8] |= (1 << (bit & 7)))
-#define OPTION_CLR(mask, bit) (mask [bit >> 8] &= ~(1 << (bit & 7)))
-#define OPTION_ISSET(mask, bit) (mask [bit >> 8] & (1 << (bit & 7)))
-#define OPTION_ISCLR(mask, bit) (!OPTION_ISSET (mask, bit))
-
-/* An option occupies its length plus two header bytes (code and
- length) for every 255 bytes that must be stored. */
-#define OPTION_SPACE(x) ((x) + 2 * ((x) / 255 + 1))
-
-/* Default path to dhcpd config file. */
-#ifdef DEBUG
-#undef _PATH_DHCPD_CONF
-#define _PATH_DHCPD_CONF "dhcpd.conf"
-#undef _PATH_DHCPD_DB
-#define _PATH_DHCPD_DB "dhcpd.leases"
-#else
-#ifndef _PATH_DHCPD_CONF
-#define _PATH_DHCPD_CONF "/etc/dhcpd.conf"
-#endif
-
-#ifndef _PATH_DHCPD_DB
-#define _PATH_DHCPD_DB "/etc/dhcpd.leases"
-#endif
-
-#ifndef _PATH_DHCPD_PID
-#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
-#endif
-#endif
-
-#ifndef DHCPD_LOG_FACILITY
-#define DHCPD_LOG_FACILITY LOG_DAEMON
-#endif
-
-#define MAX_TIME 0x7fffffff
-#define MIN_TIME 0
-
-/* External definitions... */
-
-/* options.c */
-
-void parse_options PROTO ((struct packet *));
-void parse_option_buffer PROTO ((struct packet *, unsigned char *, int));
-void cons_options PROTO ((struct packet *, struct packet *,
- struct tree_cache **, int, int));
-int store_options PROTO ((unsigned char *, int, struct tree_cache **,
- unsigned char *, int, int, int, int));
-char *pretty_print_option PROTO ((unsigned char, unsigned char *, int));
-
-/* errwarn.c */
-extern int warnings_occurred;
-void error PROTO ((char *, ...));
-int warn PROTO ((char *, ...));
-int note PROTO ((char *, ...));
-int debug PROTO ((char *, ...));
-int parse_warn PROTO ((char *, ...));
-
-/* dhcpd.c */
-extern TIME cur_time;
-extern struct group root_group;
-
-extern struct iaddr server_identifier;
-extern int server_identifier_matched;
-
-extern u_int16_t server_port;
-extern int log_priority;
-extern int log_perror;
-
-#ifdef USE_FALLBACK
-extern struct interface_info fallback_interface;
-#endif
-
-extern char *path_dhcpd_conf;
-extern char *path_dhcpd_db;
-extern char *path_dhcpd_pid;
-
-int main PROTO ((int, char **, char **));
-void cleanup PROTO ((void));
-
-/* conflex.c */
-extern int lexline, lexchar;
-extern char *token_line, *tlname;
-extern char comments [4096];
-extern int comment_index;
-void new_parse PROTO ((char *));
-int next_token PROTO ((char **, FILE *));
-int peek_token PROTO ((char **, FILE *));
-
-/* confpars.c */
-int readconf PROTO ((void));
-void read_leases PROTO ((void));
-int parse_statement PROTO ((FILE *,
- struct group *, int, struct host_decl *, int));
-void skip_to_semi PROTO ((FILE *));
-int parse_boolean PROTO ((FILE *));
-int parse_semi PROTO ((FILE *));
-int parse_lbrace PROTO ((FILE *));
-void parse_host_declaration PROTO ((FILE *, struct group *));
-char *parse_host_name PROTO ((FILE *));
-void parse_class_declaration PROTO ((FILE *, struct group *, int));
-void parse_lease_time PROTO ((FILE *, TIME *));
-void parse_shared_net_declaration PROTO ((FILE *, struct group *));
-void parse_subnet_declaration PROTO ((FILE *, struct shared_network *));
-void parse_group_declaration PROTO ((FILE *, struct group *));
-void parse_hardware_param PROTO ((FILE *, struct hardware *));
-char *parse_string PROTO ((FILE *));
-struct tree *parse_ip_addr_or_hostname PROTO ((FILE *, int));
-struct tree_cache *parse_fixed_addr_param PROTO ((FILE *));
-void parse_option_param PROTO ((FILE *, struct group *));
-TIME parse_timestamp PROTO ((FILE *));
-struct lease *parse_lease_declaration PROTO ((FILE *));
-void parse_address_range PROTO ((FILE *, struct subnet *));
-TIME parse_date PROTO ((FILE *));
-unsigned char *parse_numeric_aggregate PROTO ((FILE *,
- unsigned char *, int *,
- int, int, int));
-void convert_num PROTO ((unsigned char *, char *, int, int));
-
-/* tree.c */
-pair cons PROTO ((caddr_t, pair));
-struct tree_cache *tree_cache PROTO ((struct tree *));
-struct tree *tree_host_lookup PROTO ((char *));
-struct dns_host_entry *enter_dns_host PROTO ((char *));
-struct tree *tree_const PROTO ((unsigned char *, int));
-struct tree *tree_concat PROTO ((struct tree *, struct tree *));
-struct tree *tree_limit PROTO ((struct tree *, int));
-int tree_evaluate PROTO ((struct tree_cache *));
-
-/* dhcp.c */
-void dhcp PROTO ((struct packet *));
-void dhcpdiscover PROTO ((struct packet *));
-void dhcprequest PROTO ((struct packet *));
-void dhcprelease PROTO ((struct packet *));
-void dhcpdecline PROTO ((struct packet *));
-void dhcpinform PROTO ((struct packet *));
-void nak_lease PROTO ((struct packet *, struct iaddr *cip));
-void ack_lease PROTO ((struct packet *, struct lease *, unsigned char, TIME));
-struct lease *find_lease PROTO ((struct packet *, struct shared_network *));
-struct lease *mockup_lease PROTO ((struct packet *,
- struct shared_network *,
- struct host_decl *));
-
-/* bootp.c */
-void bootp PROTO ((struct packet *));
-
-/* memory.c */
-void enter_host PROTO ((struct host_decl *));
-struct host_decl *find_hosts_by_haddr PROTO ((int, unsigned char *, int));
-struct host_decl *find_hosts_by_uid PROTO ((unsigned char *, int));
-struct subnet *find_host_for_network PROTO ((struct host_decl **,
- struct iaddr *,
- struct shared_network *));
-void new_address_range PROTO ((struct iaddr, struct iaddr,
- struct subnet *, int));
-extern struct subnet *find_grouped_subnet PROTO ((struct shared_network *,
- struct iaddr));
-extern struct subnet *find_subnet PROTO ((struct iaddr));
-void enter_shared_network PROTO ((struct shared_network *));
-void enter_subnet PROTO ((struct subnet *));
-void enter_lease PROTO ((struct lease *));
-int supersede_lease PROTO ((struct lease *, struct lease *, int));
-void release_lease PROTO ((struct lease *));
-void abandon_lease PROTO ((struct lease *));
-struct lease *find_lease_by_uid PROTO ((unsigned char *, int));
-struct lease *find_lease_by_hw_addr PROTO ((unsigned char *, int));
-struct lease *find_lease_by_ip_addr PROTO ((struct iaddr));
-void uid_hash_add PROTO ((struct lease *));
-void uid_hash_delete PROTO ((struct lease *));
-void hw_hash_add PROTO ((struct lease *));
-void hw_hash_delete PROTO ((struct lease *));
-struct class *add_class PROTO ((int, char *));
-struct class *find_class PROTO ((int, char *, int));
-struct group *clone_group PROTO ((struct group *, char *));
-void write_leases PROTO ((void));
-void dump_subnets PROTO ((void));
-
-/* alloc.c */
-VOIDPTR dmalloc PROTO ((int, char *));
-void dfree PROTO ((VOIDPTR, char *));
-struct packet *new_packet PROTO ((char *));
-struct dhcp_packet *new_dhcp_packet PROTO ((char *));
-struct tree *new_tree PROTO ((char *));
-struct tree_cache *new_tree_cache PROTO ((char *));
-struct hash_table *new_hash_table PROTO ((int, char *));
-struct hash_bucket *new_hash_bucket PROTO ((char *));
-struct lease *new_lease PROTO ((char *));
-struct lease *new_leases PROTO ((int, char *));
-struct subnet *new_subnet PROTO ((char *));
-struct class *new_class PROTO ((char *));
-struct shared_network *new_shared_network PROTO ((char *));
-struct group *new_group PROTO ((char *));
-void free_group PROTO ((struct group *, char *));
-void free_shared_network PROTO ((struct shared_network *, char *));
-void free_class PROTO ((struct class *, char *));
-void free_subnet PROTO ((struct subnet *, char *));
-void free_lease PROTO ((struct lease *, char *));
-void free_hash_bucket PROTO ((struct hash_bucket *, char *));
-void free_hash_table PROTO ((struct hash_table *, char *));
-void free_tree_cache PROTO ((struct tree_cache *, char *));
-void free_packet PROTO ((struct packet *, char *));
-void free_dhcp_packet PROTO ((struct dhcp_packet *, char *));
-void free_tree PROTO ((struct tree *, char *));
-
-/* print.c */
-char *print_hw_addr PROTO ((int, int, unsigned char *));
-void print_lease PROTO ((struct lease *));
-void dump_raw PROTO ((unsigned char *, int));
-void dump_packet PROTO ((struct packet *));
-void hash_dump PROTO ((struct hash_table *));
-
-/* socket.c */
-#if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_RECEIVE) \
- || defined (USE_SOCKET_FALLBACK)
-int if_register_socket PROTO ((struct interface_info *, struct ifreq *));
-#endif
-
-#ifdef USE_SOCKET_FALLBACK
-void if_register_fallback PROTO ((struct interface_info *, struct ifreq *));
-size_t send_fallback PROTO ((struct interface_info *,
- struct packet *, struct dhcp_packet *, size_t,
- struct in_addr,
- struct sockaddr_in *, struct hardware *));
-size_t fallback_discard PROTO ((struct interface_info *));
-#endif
-
-#ifdef USE_SOCKET_SEND
-void if_register_send PROTO ((struct interface_info *, struct ifreq *));
-size_t send_packet PROTO ((struct interface_info *,
- struct packet *, struct dhcp_packet *, size_t,
- struct in_addr,
- struct sockaddr_in *, struct hardware *));
-#endif
-#ifdef USE_SOCKET_RECEIVE
-void if_register_receive PROTO ((struct interface_info *, struct ifreq *));
-size_t receive_packet PROTO ((struct interface_info *,
- unsigned char *, size_t,
- struct sockaddr_in *, struct hardware *));
-#endif
-
-/* bpf.c */
-#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE)
-int if_register_bpf PROTO ( (struct interface_info *, struct ifreq *));
-#endif
-#ifdef USE_BPF_SEND
-void if_register_send PROTO ((struct interface_info *, struct ifreq *));
-size_t send_packet PROTO ((struct interface_info *,
- struct packet *, struct dhcp_packet *, size_t,
- struct in_addr,
- struct sockaddr_in *, struct hardware *));
-#endif
-#ifdef USE_BPF_RECEIVE
-void if_register_receive PROTO ((struct interface_info *, struct ifreq *));
-size_t receive_packet PROTO ((struct interface_info *,
- unsigned char *, size_t,
- struct sockaddr_in *, struct hardware *));
-#endif
-
-/* nit.c */
-#ifdef USE_NIT_SEND
-void if_register_send PROTO ((struct interface_info *, struct ifreq *));
-size_t send_packet PROTO ((struct interface_info *,
- struct packet *, struct dhcp_packet *, size_t,
- struct in_addr,
- struct sockaddr_in *, struct hardware *));
-#endif
-#ifdef USE_NIT_RECEIVE
-void if_register_receive PROTO ((struct interface_info *, struct ifreq *));
-size_t receive_packet PROTO ((struct interface_info *,
- unsigned char *, size_t,
- struct sockaddr_in *, struct hardware *));
-#endif
-
-/* raw.c */
-#ifdef USE_RAW_SEND
-void if_register_send PROTO ((struct interface_info *, struct ifreq *));
-size_t send_packet PROTO ((struct interface_info *,
- struct packet *, struct dhcp_packet *, size_t,
- struct in_addr,
- struct sockaddr_in *, struct hardware *));
-#endif
-
-/* dispatch.c */
-extern struct interface_info *interfaces;
-void discover_interfaces PROTO ((int));
-void dispatch PROTO ((void));
-void do_packet PROTO ((struct interface_info *,
- unsigned char *, int,
- unsigned short, struct iaddr, struct hardware *));
-int locate_network PROTO ((struct packet *));
-
-/* hash.c */
-struct hash_table *new_hash PROTO ((void));
-void add_hash PROTO ((struct hash_table *, char *, int, unsigned char *));
-void delete_hash_entry PROTO ((struct hash_table *, char *, int));
-unsigned char *hash_lookup PROTO ((struct hash_table *, char *, int));
-
-/* tables.c */
-extern struct option dhcp_options [256];
-extern unsigned char dhcp_option_default_priority_list [];
-extern int sizeof_dhcp_option_default_priority_list;
-extern char *hardware_types [256];
-extern struct hash_table universe_hash;
-extern struct universe dhcp_universe;
-void initialize_universes PROTO ((void));
-
-/* convert.c */
-u_int32_t getULong PROTO ((unsigned char *));
-int32_t getLong PROTO ((unsigned char *));
-u_int16_t getUShort PROTO ((unsigned char *));
-int16_t getShort PROTO ((unsigned char *));
-void putULong PROTO ((unsigned char *, u_int32_t));
-void putLong PROTO ((unsigned char *, int32_t));
-void putUShort PROTO ((unsigned char *, u_int16_t));
-void putShort PROTO ((unsigned char *, int16_t));
-
-/* inet.c */
-struct iaddr subnet_number PROTO ((struct iaddr, struct iaddr));
-struct iaddr ip_addr PROTO ((struct iaddr, struct iaddr, u_int32_t));
-u_int32_t host_addr PROTO ((struct iaddr, struct iaddr));
-int addr_eq PROTO ((struct iaddr, struct iaddr));
-char *piaddr PROTO ((struct iaddr));
-
-/* dhclient.c */
-void dhcpoffer PROTO ((struct packet *));
-void dhcpack PROTO ((struct packet *));
-void dhcpnak PROTO ((struct packet *));
-void send_discover PROTO ((struct interface_info *));
-void send_request PROTO ((struct packet *));
-
-/* db.c */
-int write_lease PROTO ((struct lease *));
-int commit_leases PROTO ((void));
-void db_startup PROTO ((void));
-void new_lease_file PROTO ((void));
-
-/* packet.c */
-void assemble_hw_header PROTO ((struct interface_info *, unsigned char *,
- int *, struct hardware *));
-void assemble_udp_ip_header PROTO ((struct interface_info *, unsigned char *,
- int *, u_int32_t, u_int32_t, u_int16_t,
- unsigned char *, int));
-size_t decode_hw_header PROTO ((struct interface_info *, unsigned char *,
- int, struct hardware *));
-size_t decode_udp_ip_header PROTO ((struct interface_info *, unsigned char *,
- int, struct sockaddr_in *,
- unsigned char *, int));
-
-/* dhxpxlt.c */
-void convert_statement PROTO ((FILE *));
-void convert_host_statement PROTO ((FILE *, jrefproto));
-void convert_host_name PROTO ((FILE *, jrefproto));
-void convert_class_statement PROTO ((FILE *, jrefproto, int));
-void convert_class_decl PROTO ((FILE *, jrefproto));
-void convert_lease_time PROTO ((FILE *, jrefproto, char *));
-void convert_shared_net_statement PROTO ((FILE *, jrefproto));
-void convert_subnet_statement PROTO ((FILE *, jrefproto));
-void convert_subnet_decl PROTO ((FILE *, jrefproto));
-void convert_host_decl PROTO ((FILE *, jrefproto));
-void convert_hardware_decl PROTO ((FILE *, jrefproto));
-void convert_hardware_addr PROTO ((FILE *, jrefproto));
-void convert_filename_decl PROTO ((FILE *, jrefproto));
-void convert_servername_decl PROTO ((FILE *, jrefproto));
-void convert_ip_addr_or_hostname PROTO ((FILE *, jrefproto, int));
-void convert_fixed_addr_decl PROTO ((FILE *, jrefproto));
-void convert_option_decl PROTO ((FILE *, jrefproto));
-void convert_timestamp PROTO ((FILE *, jrefproto));
-void convert_lease_statement PROTO ((FILE *, jrefproto));
-void convert_address_range PROTO ((FILE *, jrefproto));
-void convert_date PROTO ((FILE *, jrefproto, char *));
-void convert_numeric_aggregate PROTO ((FILE *, jrefproto, int, int, int, int));
-void indent PROTO ((int));
diff --git a/includes/dhctoken.h b/includes/dhctoken.h
deleted file mode 100644
index bbb02cad..00000000
--- a/includes/dhctoken.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* dhctoken.h
-
- Tokens for config file lexer and parser. */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#define SEMI ';'
-#define DOT '.'
-#define COLON ':'
-#define COMMA ','
-#define SLASH '/'
-#define LBRACE '{'
-#define RBRACE '}'
-
-#define FIRST_TOKEN HOST
-#define HOST 256
-#define HARDWARE 257
-#define FILENAME 258
-#define FIXED_ADDR 259
-#define OPTION 260
-#define ETHERNET 261
-#define STRING 262
-#define NUMBER 263
-#define NUMBER_OR_NAME 264
-#define NAME 265
-#define TIMESTAMP 266
-#define STARTS 267
-#define ENDS 268
-#define UID 269
-#define CLASS 270
-#define LEASE 271
-#define RANGE 272
-#define PACKET 273
-#define CIADDR 274
-#define YIADDR 275
-#define SIADDR 276
-#define GIADDR 277
-#define SUBNET 278
-#define NETMASK 279
-#define DEFAULT_LEASE_TIME 280
-#define MAX_LEASE_TIME 281
-#define VENDOR_CLASS 282
-#define USER_CLASS 283
-#define SHARED_NETWORK 284
-#define SERVER_NAME 285
-#define DYNAMIC_BOOTP 286
-#define SERVER_IDENTIFIER 287
-#define DYNAMIC_BOOTP_LEASE_CUTOFF 288
-#define DYNAMIC_BOOTP_LEASE_LENGTH 289
-#define BOOT_UNKNOWN_CLIENTS 290
-#define NEXT_SERVER 291
-#define TOKEN_RING 292
-#define GROUP 293
-#define ONE_LEASE_PER_CLIENT 294
-#define GET_LEASE_HOSTNAMES 295
-#define USE_HOST_DECL_NAMES 296
-
-#define is_identifier(x) ((x) >= FIRST_TOKEN && \
- (x) != STRING && \
- (x) != NUMBER && \
- (x) != EOF)
diff --git a/includes/hash.h b/includes/hash.h
deleted file mode 100644
index d30072b3..00000000
--- a/includes/hash.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* hash.h
-
- Definitions for hashing... */
-
-/*
- * Copyright (c) 1995 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#define DEFAULT_HASH_SIZE 97
-
-struct hash_bucket {
- struct hash_bucket *next;
- char *name;
- int len;
- unsigned char *value;
-};
-
-struct hash_table {
- int hash_count;
- struct hash_bucket *buckets [DEFAULT_HASH_SIZE];
-};
-
diff --git a/includes/inet.h b/includes/inet.h
deleted file mode 100644
index 758573e9..00000000
--- a/includes/inet.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* inet.h
-
- Portable definitions for internet addresses */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-/* An internet address of up to 128 bits. */
-
-struct iaddr {
- int len;
- unsigned char iabuf [16];
-};
diff --git a/includes/osdep.h b/includes/osdep.h
deleted file mode 100644
index 02af9dcd..00000000
--- a/includes/osdep.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/* osdep.h
-
- Operating system dependencies... */
-
-/*
- * Copyright (c) 1996 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software was written for the Internet Software Consortium by Ted Lemon
- * under a contract with Vixie Laboratories.
- */
-
-#include "site.h"
-
-/* Porting::
-
- If you add a new network API, you must add a check for it below: */
-
-#if !defined (USE_SOCKETS) && \
- !defined (USE_SOCKET_SEND) && \
- !defined (USE_SOCKET_RECEIVE) && \
- !defined (USE_RAW_SOCKETS) && \
- !defined (USE_RAW_SEND) && \
- !defined (USE_SOCKET_RECEIVE) && \
- !defined (USE_BPF) && \
- !defined (USE_BPF_SEND) && \
- !defined (USE_BPF_RECEIVE) && \
- !defined (USE_NIT) && \
- !defined (USE_NIT_SEND) && \
- !defined (USE_NIT_RECEIVE)
-# define USE_DEFAULT_NETWORK
-#endif
-
-
-/* Porting::
-
- If you add a new system configuration file, include it here: */
-
-#if defined (sun)
-# if defined (__svr4__) || defined (__SVR4)
-# include "cf/sunos5-5.h"
-# else
-# include "cf/sunos4.h"
-# endif
-#endif
-
-#ifdef bsdi
-# include "cf/bsdos.h"
-#endif
-
-#ifdef __NetBSD__
-# include "cf/netbsd.h"
-#endif
-
-#ifdef __FreeBSD__
-# include "cf/freebsd.h"
-#endif
-
-#if defined (__osf__) && defined (__alpha)
-# include "cf/alphaosf.h"
-#endif
-
-#ifdef ultrix
-# include "cf/ultrix.h"
-#endif
-
-#ifdef linux
-# include "cf/linux.h"
-#endif
-
-#ifdef SCO
-# include "cf/sco.h"
-#endif
-
-#ifdef hpux
-# include "cf/hpux.h"
-#endif
-
-#ifdef __QNX__
-# include "cf/qnx.h"
-#endif
-
-/* Porting::
-
- If you add a new network API, and have it set up so that it can be
- used for sending or receiving, but doesn't have to be used for both,
- then set up an ifdef like the ones below: */
-
-#ifdef USE_SOCKETS
-# define USE_SOCKET_SEND
-# define USE_SOCKET_RECEIVE
-#endif
-
-#ifdef USE_RAW_SOCKETS
-# define USE_RAW_SEND
-# define USE_SOCKET_RECEIVE
-#endif
-
-#ifdef USE_BPF
-# define USE_BPF_SEND
-# define USE_BPF_RECEIVE
-#endif
-
-#ifdef USE_NIT
-# define USE_NIT_SEND
-# define USE_NIT_RECEIVE
-#endif
-
-/* Porting::
-
- If you add support for sending packets directly out an interface,
- and your support does not do ARP or routing, you must use a fallback
- mechanism to deal with packets that need to be sent to routers.
- Currently, all low-level packet interfaces use BSD sockets as a
- fallback. */
-
-#if defined (USE_BPF_SEND) || defined (USE_NIT_SEND)
-# define USE_SOCKET_FALLBACK
-# define USE_FALLBACK
-#endif
-
-/* Porting::
-
- If you add support for sending packets directly out an interface
- and need to be able to assemble packets, add the USE_XXX_SEND
- definition for your interface to the list tested below. */
-
-#if defined (USE_RAW_SEND) || defined (USE_BPF_SEND) || defined (USE_NIT_SEND)
-# define PACKET_ASSEMBLY
-#endif
-
-/* Porting::
-
- If you add support for receiving packets directly from an interface
- and need to be able to decode raw packets, add the USE_XXX_RECEIVE
- definition for your interface to the list tested below. */
-
-#if defined (USE_RAW_RECEIVE) || defined (USE_BPF_RECEIVE) \
- || defined (USE_NIT_RECEIVE)
-# define PACKET_DECODING
-#endif
-
-/* jmp_buf is assumed to be a struct unless otherwise defined in the
- system header. */
-#ifndef jbp_decl
-# define jbp_decl(x) jmp_buf *x
-#endif
-#ifndef jref
-# define jref(x) (&(x))
-#endif
-#ifndef jdref
-# define jdref(x) (*(x))
-#endif
-#ifndef jrefproto
-# define jrefproto jmp_buf *
-#endif
-
-#ifndef BPF_FORMAT
-# define BPF_FORMAT "/dev/bpf%d"
-#endif
diff --git a/includes/site.h b/includes/site.h
deleted file mode 100644
index 30fdb703..00000000
--- a/includes/site.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* Site-specific definitions.
-
- For supported systems, you shouldn't need to make any changes here.
- However, you may want to, in order to deal with site-specific
- differences. */
-
-/* Add any site-specific definitions and inclusions here... */
-
-/* #include <site-foo-bar.h> */
-/* #define SITE_FOOBAR */
-
-/* Define this if you don't want dhcpd to run as a daemon and do want
- to see all its output printed to stdout instead of being logged via
- syslog(). This also makes dhcpd use the dhcpd.conf in its working
- directory and write the dhcpd.leases file there. */
-
-/* #define DEBUG */
-
-/* Define this to see what the parser is parsing. You probably don't
- want to see this. */
-
-/* #define DEBUG_TOKENS */
-
-/* Define this to see dumps of incoming and outgoing packets. This
- slows things down quite a bit... */
-
-/* #define DEBUG_PACKET */
-
-/* Define this if you want to see dumps of tree evaluations. The most
- common reason for doing this is to watch what happens with DNS name
- lookups. */
-
-/* #define DEBUG_EVAL */
-
-/* Define this if you want the dhcpd.pid file to go somewhere other than
- the default (which varies from system to system, but is usually either
- /etc or /var/run. */
-
-/* #define _PATH_DHCPD_PID "/var/run/dhcpd.pid" */
-
-/* Define this if you want the dhcpd.leases file (the dynamic lease database)
- to go somewhere other than the default location, which is normally
- /etc/dhcpd.leases. */
-
-/* #define _PATH_DHCPD_DB "/etc/dhcpd.leases" */
-
-/* Define this if you want the dhcpd.conf file to go somewhere other than
- the default location. By default, it goes in /etc/dhcpd.conf. */
-
-/* #define _PATH_DHCPD_CONF "/etc/dhcpd.conf" */
-
-/* Network API definitions. You do not need to choose one of these - if
- you don't choose, one will be chosen for you in your system's config
- header. DON'T MESS WITH THIS UNLESS YOU KNOW WHAT YOU'RE DOING!!! */
-
-/* Define this to use the standard BSD socket API.
-
- On many systems, the BSD socket API does not provide the ability to
- send packets to the 255.255.255.255 broadcast address, which can
- prevent some clients (e.g., Win95) from seeing replies. This is
- not a problem on Solaris.
-
- In addition, the BSD socket API will not work when more than one
- network interface is configured on the server.
-
- However, the BSD socket API is about as efficient as you can get, so if
- the aforementioned problems do not matter to you, or if no other
- API is supported for your system, you may want to go with it. */
-
-/* #define USE_SOCKETS */
-
-/* Define this to use the Sun Streams NIT API.
-
- The Sun Streams NIT API is only supported on SunOS 4.x releases. */
-
-/* #define USE_NIT */
-
-/* Define this to use the Berkeley Packet Filter API.
-
- The BPF API is available on all 4.4-BSD derivatives, including
- NetBSD, FreeBSD and BSDI's BSD/OS. It's also available on
- DEC Alpha OSF/1 in a compatibility mode supported by the Alpha OSF/1
- packetfilter interface. */
-
-/* #define USE_BPF */
-
-/* Define this to use the raw socket API.
-
- The raw socket API is provided on many BSD derivatives, and provides
- a way to send out raw IP packets. It is only supported for sending
- packets - packets must be received with the regular socket API.
- This code is experimental - I've never gotten it to actually transmit
- a packet to the 255.255.255.255 broadcast address - so use it at your
- own risk. */
-
-/* #define USE_RAW_SOCKETS */
-
-/* Define this to change the logging facility used by dhcpd. */
-
-/* #define DHCPD_LOG_FACILITY LOG_DAEMON */
diff --git a/includes/tree.h b/includes/tree.h
deleted file mode 100644
index c6b7a3ba..00000000
--- a/includes/tree.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* tree.h
-
- Definitions for address trees... */
-
-/*
- * Copyright (c) 1995 The Internet Software Consortium. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-/* A pair of pointers, suitable for making a linked list. */
-typedef struct _pair {
- caddr_t car;
- struct _pair *cdr;
-} *pair;
-
-/* Tree node types... */
-#define TREE_CONCAT 1
-#define TREE_HOST_LOOKUP 2
-#define TREE_CONST 3
-#define TREE_LIMIT 4
-
-/* Tree structure for deferred evaluation of changing values. */
-struct tree {
- int op;
- union {
- struct concat {
- struct tree *left;
- struct tree *right;
- } concat;
- struct host_lookup {
- struct dns_host_entry *host;
- } host_lookup;
- struct const_val {
- unsigned char *data;
- int len;
- } const_val;
- struct limit {
- struct tree *tree;
- int limit;
- } limit;
- } data;
-};
-
-/* DNS host entry structure... */
-struct dns_host_entry {
- char *hostname;
- unsigned char *data;
- int data_len;
- int buf_len;
- TIME timeout;
-};
-
-struct tree_cache {
- unsigned char *value;
- int len;
- int buf_size;
- TIME timeout;
- struct tree *tree;
-};
-
-struct universe {
- char *name;
- struct hash_table *hash;
- struct option *options [256];
-};
-
-struct option {
- char *name;
- char *format;
- struct universe *universe;
- unsigned char code;
-};
diff --git a/server/bootp.c b/server/bootp.c
deleted file mode 100644
index fc983f11..00000000
--- a/server/bootp.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/* bootp.c
-
- BOOTP Protocol support. */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: bootp.c,v 1.20 1996/11/08 20:08:34 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-void bootp (packet)
- struct packet *packet;
-{
- int result;
- struct host_decl *hp;
- struct host_decl *host = (struct host_decl *)0;
- struct packet outgoing;
- struct dhcp_packet raw;
- struct sockaddr_in to;
- struct in_addr from;
- struct hardware hto;
- struct tree_cache *options [256];
- struct subnet *subnet;
- struct lease *lease;
- struct iaddr ip_address;
- int i;
-
- note ("BOOTREQUEST from %s via %s",
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr),
- packet -> raw -> giaddr.s_addr
- ? inet_ntoa (packet -> raw -> giaddr)
- : packet -> interface -> name);
-
-
-
- if (!locate_network (packet))
- return;
-
- hp = find_hosts_by_haddr (packet -> raw -> htype,
- packet -> raw -> chaddr,
- packet -> raw -> hlen);
-
- lease = find_lease (packet, packet -> shared_network);
-
- /* Find an IP address in the host_decl that matches the
- specified network. */
- if (hp)
- subnet = find_host_for_network (&hp, &ip_address,
- packet -> shared_network);
- else
- subnet = (struct subnet *)0;
-
- if (!subnet) {
- /* We didn't find an applicable host declaration.
- Just in case we may be able to dynamically assign
- an address, see if there's a host declaration
- that doesn't have an ip address associated with it. */
- if (hp) {
- for (; hp; hp = hp -> n_ipaddr) {
- if (!hp -> fixed_addr) {
- host = hp;
- }
- }
- }
-
- /* If we've been told not to boot unknown clients,
- and we didn't find any host record for this client,
- ignore it. */
- if (!hp && !(packet -> shared_network ->
- group -> boot_unknown_clients)) {
- note ("Ignoring unknown BOOTP client %s via %s",
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr),
- packet -> raw -> giaddr.s_addr
- ? inet_ntoa (packet -> raw -> giaddr)
- : packet -> interface -> name);
- return;
- }
-
- /* If the packet is from a host we don't know and there
- are no dynamic bootp addresses on the network it came
- in on, drop it on the floor. */
- if (!(packet -> shared_network -> group -> dynamic_bootp)) {
- lose:
- note ("No applicable record for BOOTP host %s via %s",
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr),
- packet -> raw -> giaddr.s_addr
- ? inet_ntoa (packet -> raw -> giaddr)
- : packet -> interface -> name);
- return;
- }
-
- /* If a lease has already been assigned to this client
- and it's still okay to use dynamic bootp on
- that lease, reassign it. */
- if (lease) {
- /* If this lease can be used for dynamic bootp,
- do so. */
- if ((lease -> flags & DYNAMIC_BOOTP_OK)) {
-
- /* If it's not a DYNAMIC_BOOTP lease,
- release it before reassigning it
- so that we don't get a lease
- conflict. */
- if (!(lease -> flags & BOOTP_LEASE))
- release_lease (lease);
-
- lease -> host = host;
- ack_lease (packet, lease, 0, 0);
- return;
- }
-
- /* If dynamic BOOTP is no longer allowed for
- this lease, set it free. */
- release_lease (lease);
- }
-
- /* If there are dynamic bootp addresses that might be
- available, try to snag one. */
- for (lease = packet -> shared_network -> last_lease;
- lease && lease -> ends <= cur_time;
- lease = lease -> prev) {
- if ((lease -> flags & DYNAMIC_BOOTP_OK)) {
- lease -> host = host;
- ack_lease (packet, lease, 0, 0);
- return;
- }
- }
- goto lose;
- }
-
- /* Set up the outgoing packet... */
- memset (&outgoing, 0, sizeof outgoing);
- memset (&raw, 0, sizeof raw);
- outgoing.raw = &raw;
-
- /* Come up with a list of options that we want to send to this
- client. Start with the per-subnet options, and then override
- those with client-specific options. */
-
- memcpy (options, subnet -> group -> options, sizeof options);
-
- for (i = 0; i < 256; i++) {
- if (hp -> group -> options [i])
- options [i] = hp -> group -> options [i];
- }
-
- /* Pack the options into the buffer. Unlike DHCP, we can't
- pack options into the filename and server name buffers. */
-
- cons_options (packet, &outgoing, options, 0, 0);
- if (outgoing.packet_length < BOOTP_MIN_LEN)
- outgoing.packet_length = BOOTP_MIN_LEN;
-
- /* Take the fields that we care about... */
- raw.op = BOOTREPLY;
- raw.htype = packet -> raw -> htype;
- raw.hlen = packet -> raw -> hlen;
- memcpy (raw.chaddr, packet -> raw -> chaddr, raw.hlen);
- memset (&raw.chaddr [raw.hlen], 0,
- (sizeof raw.chaddr) - raw.hlen);
- raw.hops = packet -> raw -> hops;
- raw.xid = packet -> raw -> xid;
- raw.secs = packet -> raw -> secs;
- raw.flags = 0;
- raw.ciaddr = packet -> raw -> ciaddr;
- memcpy (&raw.yiaddr, ip_address.iabuf, sizeof raw.yiaddr);
-
- /* Figure out the address of the next server. */
- if (hp && hp -> group -> next_server.len)
- memcpy (&raw.siaddr, hp -> group -> next_server.iabuf, 4);
- else if (subnet -> group -> next_server.len)
- memcpy (&raw.siaddr, subnet -> group -> next_server.iabuf, 4);
- else if (subnet -> interface_address.len)
- memcpy (&raw.siaddr, subnet -> interface_address.iabuf, 4);
- else
- memcpy (&raw.siaddr, server_identifier.iabuf, 4);
-
- raw.giaddr = packet -> raw -> giaddr;
- if (hp -> group -> server_name) {
- strncpy (raw.sname, hp -> group -> server_name,
- (sizeof raw.sname) - 1);
- raw.sname [(sizeof raw.sname) - 1] = 0;
- }
- if (hp -> group -> filename) {
- strncpy (raw.file, hp -> group -> filename,
- (sizeof raw.file) - 1);
- raw.file [(sizeof raw.file) - 1] = 0;
- }
-
- /* Set up the hardware destination address... */
- hto.htype = packet -> raw -> htype;
- hto.hlen = packet -> raw -> hlen;
- memcpy (hto.haddr, packet -> raw -> chaddr, hto.hlen);
-
- if (server_identifier.len)
- memcpy (&from, server_identifier.iabuf, 4);
- else
- memset (&from, 0, 4);
-
- /* Report what we're doing... */
- note ("BOOTREPLY for %s to %s (%s) via %s",
- piaddr (ip_address), hp -> name,
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr),
- packet -> raw -> giaddr.s_addr
- ? inet_ntoa (packet -> raw -> giaddr)
- : packet -> interface -> name);
-
- /* Set up the parts of the address that are in common. */
- to.sin_family = AF_INET;
-#ifdef HAVE_SA_LEN
- to.sin_len = sizeof to;
-#endif
- memset (to.sin_zero, 0, sizeof to.sin_zero);
-
- /* If this was gatewayed, send it back to the gateway... */
- if (raw.giaddr.s_addr) {
- to.sin_addr = raw.giaddr;
- to.sin_port = server_port;
-
-#ifdef USE_FALLBACK
- result = send_fallback (&fallback_interface,
- (struct packet *)0,
- &raw, outgoing.packet_length,
- from, &to, &hto);
- if (result < 0)
- warn ("send_fallback: %m");
- return;
-#endif
- /* Otherwise, broadcast it on the local network. */
- } else {
- to.sin_addr.s_addr = INADDR_BROADCAST;
- to.sin_port = htons (ntohs (server_port) + 1); /* XXX */
- }
-
- errno = 0;
- result = send_packet (packet -> interface,
- packet, &raw, outgoing.packet_length,
- from, &to, &hto);
- if (result < 0)
- warn ("send_packet: %m");
-}
diff --git a/server/confpars.c b/server/confpars.c
deleted file mode 100644
index 76e8606a..00000000
--- a/server/confpars.c
+++ /dev/null
@@ -1,1808 +0,0 @@
-/* confpars.c
-
- Parser for dhcpd config file... */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: confpars.c,v 1.36 1996/11/08 20:06:28 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-#include "dhctoken.h"
-
-static TIME parsed_time;
-
-/* conf-file :== parameters declarations EOF
- parameters :== <nil> | parameter | parameters parameter
- declarations :== <nil> | declaration | declarations declaration */
-
-int readconf ()
-{
- FILE *cfile;
- char *val;
- int token;
- int declaration = 0;
-
- new_parse (path_dhcpd_conf);
-
- /* Set up the initial dhcp option universe. */
- initialize_universes ();
-
- /* Set up the global defaults... */
- root_group.default_lease_time = 43200; /* 12 hours. */
- root_group.max_lease_time = 86400; /* 24 hours. */
- root_group.bootp_lease_cutoff = MAX_TIME;
- root_group.boot_unknown_clients = 1;
-
- if ((cfile = fopen (path_dhcpd_conf, "r")) == NULL)
- error ("Can't open %s: %m", path_dhcpd_conf);
- do {
- token = peek_token (&val, cfile);
- if (token == EOF)
- break;
- declaration = parse_statement (cfile, &root_group,
- ROOT_GROUP,
- (struct host_decl *)0,
- declaration);
- } while (1);
- token = next_token (&val, cfile); /* Clear the peek buffer */
-
- return !warnings_occurred;
-}
-
-/* lease-file :== lease-declarations EOF
- lease-statments :== <nil>
- | lease-declaration
- | lease-declarations lease-declaration */
-
-void read_leases ()
-{
- FILE *cfile;
- char *val;
- int token;
-
- new_parse (path_dhcpd_db);
-
- /* Open the lease file. If we can't open it, fail. The reason
- for this is that although on initial startup, the absence of
- a lease file is perfectly benign, if dhcpd has been running
- and this file is absent, it means that dhcpd tried and failed
- to rewrite the lease database. If we proceed and the
- problem which caused the rewrite to fail has been fixed, but no
- human has corrected the database problem, then we are left
- thinking that no leases have been assigned to anybody, which
- could create severe network chaos. */
- if ((cfile = fopen (path_dhcpd_db, "r")) == NULL)
- error ("Can't open lease database %s: %m -- %s",
- path_dhcpd_db,
- "check for failed database rewrite attempt!");
- do {
- token = next_token (&val, cfile);
- if (token == EOF)
- break;
- if (token != LEASE) {
- warn ("Corrupt lease file - possible data loss!");
- skip_to_semi (cfile);
- } else {
- struct lease *lease;
- lease = parse_lease_declaration (cfile);
- if (lease)
- enter_lease (lease);
- else
- parse_warn ("possibly corrupt lease file");
- }
-
- } while (1);
-}
-
-/* statement :== parameter | declaration
-
- parameter :== timestamp
- | DEFAULT_LEASE_TIME lease_time
- | MAX_LEASE_TIME lease_time
- | DYNAMIC_BOOTP_LEASE_CUTOFF date
- | DYNAMIC_BOOTP_LEASE_LENGTH lease_time
- | BOOT_UNKNOWN_CLIENTS boolean
- | ONE_LEASE_PER_CLIENT boolean
- | GET_LEASE_HOSTNAMES boolean
- | USE_HOST_DECL_NAME boolean
- | NEXT_SERVER ip-addr-or-hostname SEMI
- | option_parameter
- | SERVER-IDENTIFIER ip-addr-or-hostname SEMI
- | FILENAME string-parameter
- | SERVER_NAME string-parameter
- | hardware-parameter
- | fixed-address-parameter
-
- declaration :== host-declaration
- | group-declaration
- | shared-network-declaration
- | subnet-declaration
- | VENDOR_CLASS class-declaration
- | USER_CLASS class-declaration
- | RANGE address-range-declaration */
-
-int parse_statement (cfile, group, type, host_decl, declaration)
- FILE *cfile;
- struct group *group;
- int type;
- struct host_decl *host_decl;
- int declaration;
-{
- int token;
- char *val;
- struct shared_network *share;
- char *t, *n;
- struct tree *tree;
- struct tree_cache *cache;
- struct hardware hardware;
-
- switch (next_token (&val, cfile)) {
- case HOST:
- if (type != HOST_DECL)
- parse_host_declaration (cfile, group);
- else {
- parse_warn ("host declarations not allowed here.");
- skip_to_semi (cfile);
- }
- return 1;
-
- case GROUP:
- if (type != HOST_DECL)
- parse_group_declaration (cfile, group);
- else {
- parse_warn ("host declarations not allowed here.");
- skip_to_semi (cfile);
- }
- return 1;
-
- case TIMESTAMP:
- parsed_time = parse_timestamp (cfile);
- break;
-
- case SHARED_NETWORK:
- if (type == SHARED_NET_DECL ||
- type == HOST_DECL ||
- type == SUBNET_DECL) {
- parse_warn ("shared-network parameters not %s.",
- "allowed here");
- skip_to_semi (cfile);
- break;
- }
-
- parse_shared_net_declaration (cfile, group);
- return 1;
-
- case SUBNET:
- if (type == HOST_DECL || type == SUBNET_DECL) {
- parse_warn ("subnet declarations not allowed here.");
- skip_to_semi (cfile);
- return 1;
- }
-
- /* If we're in a subnet declaration, just do the parse. */
- if (group -> shared_network) {
- parse_subnet_declaration (cfile,
- group -> shared_network);
- break;
- }
-
- /* Otherwise, cons up a fake shared network structure
- and populate it with the lone subnet... */
-
- share = new_shared_network ("parse_statement");
- if (!share)
- error ("No memory for shared subnet");
- share -> group = clone_group (group, "parse_statement:subnet");
- share -> group -> shared_network = share;
-
- parse_subnet_declaration (cfile, share);
- if (share -> subnets) {
- share -> interface =
- share -> subnets -> interface;
-
- n = piaddr (share -> subnets -> net);
- t = malloc (strlen (n) + 1);
- if (!t)
- error ("no memory for subnet name");
- strcpy (t, n);
- share -> name = t;
- enter_shared_network (share);
- }
- return 1;
-
- case VENDOR_CLASS:
- parse_class_declaration (cfile, group, 0);
- return 1;
-
- case USER_CLASS:
- parse_class_declaration (cfile, group, 1);
- return 1;
-
- case DEFAULT_LEASE_TIME:
- parse_lease_time (cfile, &group -> default_lease_time);
- break;
-
- case MAX_LEASE_TIME:
- parse_lease_time (cfile, &group -> max_lease_time);
- break;
-
- case DYNAMIC_BOOTP_LEASE_CUTOFF:
- group -> bootp_lease_cutoff = parse_date (cfile);
- break;
-
- case DYNAMIC_BOOTP_LEASE_LENGTH:
- parse_lease_time (cfile, &group -> bootp_lease_length);
- break;
-
- case BOOT_UNKNOWN_CLIENTS:
- if (type == HOST_DECL)
- parse_warn ("boot-unknown-clients not allowed here.");
- group -> boot_unknown_clients = parse_boolean (cfile);
- break;
-
- case ONE_LEASE_PER_CLIENT:
- if (type == HOST_DECL)
- parse_warn ("one-lease-per-client not allowed here.");
- group -> one_lease_per_client = parse_boolean (cfile);
- break;
-
- case GET_LEASE_HOSTNAMES:
- if (type == HOST_DECL)
- parse_warn ("get-lease-hostnames not allowed here.");
- group -> get_lease_hostnames = parse_boolean (cfile);
- break;
-
- case USE_HOST_DECL_NAMES:
- if (type == HOST_DECL)
- parse_warn ("use-host-decl-names not allowed here.");
- group -> use_host_decl_names = parse_boolean (cfile);
- break;
-
- case NEXT_SERVER:
- tree = parse_ip_addr_or_hostname (cfile, 0);
- if (!tree)
- break;
- cache = tree_cache (tree);
- if (!tree_evaluate (cache))
- error ("next-server is not known");
- group -> next_server.len = 4;
- memcpy (group -> next_server.iabuf,
- cache -> value, group -> next_server.len);
- parse_semi (cfile);
- break;
-
- case OPTION:
- parse_option_param (cfile, group);
- break;
-
- case SERVER_IDENTIFIER:
- if (type != ROOT_GROUP)
- parse_warn ("server-identifier only allowed at top %s",
- "level.");
- tree = parse_ip_addr_or_hostname (cfile, 0);
- if (!tree)
- return declaration;
- cache = tree_cache (tree);
- if (type == ROOT_GROUP) {
- if (!tree_evaluate (cache))
- error ("server-identifier is not known");
- }
- token = next_token (&val, cfile);
- break;
-
- case FILENAME:
- group -> filename = parse_string (cfile);
- break;
-
- case SERVER_NAME:
- group -> server_name = parse_string (cfile);
- break;
-
- case HARDWARE:
- parse_hardware_param (cfile, &hardware);
- if (host_decl)
- host_decl -> interface = hardware;
- else
- parse_warn ("hardware address parameter %s",
- "not allowed here.");
- break;
-
- case FIXED_ADDR:
- cache = parse_fixed_addr_param (cfile);
- if (host_decl)
- host_decl -> fixed_addr = cache;
- else
- parse_warn ("fixed-address parameter not %s",
- "allowed here.");
- break;
-
- case RANGE:
- if (type != SUBNET_DECL || !group -> subnet) {
- parse_warn ("range declaration not allowed here.");
- skip_to_semi (cfile);
- return declaration;
- }
- parse_address_range (cfile, group -> subnet);
- return declaration;
-
- default:
- if (declaration)
- parse_warn ("expecting a declaration.");
- else
- parse_warn ("expecting a parameter or declaration.");
- skip_to_semi (cfile);
- return declaration;
- }
-
- if (declaration) {
- parse_warn ("parameters not allowed after first declaration.");
- return 1;
- }
-
- return 0;
-}
-
-/* Skip to the semicolon ending the current statement. If we encounter
- braces, the matching closing brace terminates the statement. If we
- encounter a right brace but haven't encountered a left brace, return
- leaving the brace in the token buffer for the caller. If we see a
- semicolon and haven't seen a left brace, return. This lets us skip
- over:
-
- statement;
- statement foo bar { }
- statement foo bar { statement { } }
- statement}
-
- ...et cetera. */
-
-void skip_to_semi (cfile)
- FILE *cfile;
-{
- int token;
- char *val;
- int brace_count = 0;
-
- do {
- token = peek_token (&val, cfile);
- if (token == RBRACE) {
- if (brace_count) {
- token = next_token (&val, cfile);
- if (!--brace_count)
- return;
- } else
- return;
- } else if (token == LBRACE) {
- brace_count++;
- } else if (token == SEMI && !brace_count) {
- token = next_token (&val, cfile);
- return;
- }
- token = next_token (&val, cfile);
- } while (token != EOF);
-}
-
-/* boolean :== ON SEMI | OFF SEMI | TRUE SEMI | FALSE SEMI */
-
-int parse_boolean (cfile)
- FILE *cfile;
-{
- int token;
- char *val;
- int rv;
-
- token = next_token (&val, cfile);
- if (!strcasecmp (val, "true")
- || !strcasecmp (val, "on"))
- rv = 1;
- else if (!strcasecmp (val, "false")
- || !strcasecmp (val, "off"))
- rv = 0;
- else {
- parse_warn ("boolean value (true/false/on/off) expected");
- skip_to_semi (cfile);
- return 0;
- }
- parse_semi (cfile);
- return rv;
-}
-
-int parse_semi (cfile)
- FILE *cfile;
-{
- int token;
- char *val;
-
- token = next_token (&val, cfile);
- if (token != SEMI) {
- parse_warn ("semicolon expected.");
- skip_to_semi (cfile);
- return 0;
- }
- return 1;
-}
-
-/* Expect a left brace; if there isn't one, skip over the rest of the
- statement and return zero; otherwise, return 1. */
-
-int parse_lbrace (cfile)
- FILE *cfile;
-{
- int token;
- char *val;
-
- token = next_token (&val, cfile);
- if (token != LBRACE) {
- parse_warn ("expecting left brace.");
- skip_to_semi (cfile);
- return 0;
- }
- return 1;
-}
-
-
-/* host-declaration :== hostname RBRACE parameters declarations LBRACE */
-
-void parse_host_declaration (cfile, group)
- FILE *cfile;
- struct group *group;
-{
- char *val;
- int token;
- struct host_decl *host;
- char *name = parse_host_name (cfile);
- int declaration = 0;
-
- if (!name)
- return;
-
- host = (struct host_decl *)dmalloc (sizeof (struct host_decl),
- "parse_host_declaration");
- if (!host)
- error ("can't allocate host decl struct %s.", name);
-
- host -> name = name;
- host -> group = clone_group (group, "parse_host_declaration");
-
- if (!parse_lbrace (cfile))
- return;
-
- do {
- token = peek_token (&val, cfile);
- if (token == RBRACE) {
- token = next_token (&val, cfile);
- break;
- }
- if (token == EOF) {
- token = next_token (&val, cfile);
- parse_warn ("unexpected end of file");
- break;
- }
- declaration = parse_statement (cfile, host -> group,
- HOST_DECL, host,
- declaration);
- } while (1);
-
- if (!host -> group -> options [DHO_HOST_NAME] &&
- host -> group -> use_host_decl_names) {
- host -> group -> options [DHO_HOST_NAME] =
- new_tree_cache ("parse_host_declaration");
- if (!host -> group -> options [DHO_HOST_NAME])
- error ("can't allocate a tree cache for hostname.");
- host -> group -> options [DHO_HOST_NAME] -> len =
- strlen (name);
- host -> group -> options [DHO_HOST_NAME] -> value =
- (unsigned char *)name;
- host -> group -> options [DHO_HOST_NAME] -> buf_size =
- host -> group -> options [DHO_HOST_NAME] -> len;
- host -> group -> options [DHO_HOST_NAME] -> timeout =
- 0xFFFFFFFF;
- host -> group -> options [DHO_HOST_NAME] -> tree =
- (struct tree *)0;
- }
-
- enter_host (host);
-}
-
-/* hostname :== identifier | hostname DOT identifier */
-
-char *parse_host_name (cfile)
- FILE *cfile;
-{
- char *val;
- int token;
- int len = 0;
- char *s;
- char *t;
- pair c = (pair)0;
-
- /* Read a dotted hostname... */
- do {
- /* Read a token, which should be an identifier. */
- token = next_token (&val, cfile);
- if (!is_identifier (token) && token != NUMBER) {
- parse_warn ("expecting an identifier in hostname");
- skip_to_semi (cfile);
- return (char *)0;
- }
- /* Store this identifier... */
- if (!(s = (char *)malloc (strlen (val) + 1)))
- error ("can't allocate temp space for hostname.");
- strcpy (s, val);
- c = cons ((caddr_t)s, c);
- len += strlen (s) + 1;
- /* Look for a dot; if it's there, keep going, otherwise
- we're done. */
- token = peek_token (&val, cfile);
- if (token == DOT)
- token = next_token (&val, cfile);
- } while (token == DOT);
-
- /* Assemble the hostname together into a string. */
- if (!(s = (char *)malloc (len)))
- error ("can't allocate space for hostname.");
- t = s + len;
- *--t = 0;
- while (c) {
- pair cdr = c -> cdr;
- int l = strlen ((char *)(c -> car));
- t -= l;
- memcpy (t, (char *)(c -> car), l);
- /* Free up temp space. */
- free (c -> car);
- free (c);
- c = cdr;
- if (t != s)
- *--t = '.';
- }
- return s;
-}
-
-/* class-declaration :== STRING LBRACE parameters declarations RBRACE
-*/
-
-void parse_class_declaration (cfile, group, type)
- FILE *cfile;
- struct group *group;
- int type;
-{
- char *val;
- int token;
- struct class *class;
- int declaration;
-
- token = next_token (&val, cfile);
- if (token != STRING) {
- parse_warn ("Expecting class name");
- skip_to_semi (cfile);
- return;
- }
-
- class = add_class (type, val);
- if (!class)
- error ("No memory for class %s.", val);
- class -> group = clone_group (group, "parse_class_declaration");
-
- if (!parse_lbrace (cfile))
- return;
-
- do {
- token = peek_token (&val, cfile);
- if (token == RBRACE) {
- token = next_token (&val, cfile);
- break;
- } else if (token == EOF) {
- token = next_token (&val, cfile);
- parse_warn ("unexpected end of file");
- break;
- } else {
- declaration = parse_statement (cfile, class -> group,
- CLASS_DECL,
- (struct host_decl *)0,
- declaration);
- }
- } while (1);
-}
-
-/* lease-time :== NUMBER SEMI */
-
-void parse_lease_time (cfile, timep)
- FILE *cfile;
- TIME *timep;
-{
- char *val;
- int token;
-
- token = next_token (&val, cfile);
- if (token != NUMBER) {
- parse_warn ("Expecting numeric lease time");
- skip_to_semi (cfile);
- return;
- }
- convert_num ((unsigned char *)timep, val, 10, 32);
- /* Unswap the number - convert_num returns stuff in NBO. */
- *timep = ntohl (*timep); /* XXX */
-
- parse_semi (cfile);
-}
-
-/* shared-network-declaration :==
- hostname LBRACE declarations parameters RBRACE */
-
-void parse_shared_net_declaration (cfile, group)
- FILE *cfile;
- struct group *group;
-{
- char *val;
- int token;
- struct shared_network *share;
- char *name;
- int declaration = 0;
-
- share = new_shared_network ("parse_shared_net_declaration");
- if (!share)
- error ("No memory for shared subnet");
- share -> leases = (struct lease *)0;
- share -> last_lease = (struct lease *)0;
- share -> insertion_point = (struct lease *)0;
- share -> next = (struct shared_network *)0;
- share -> interface = (struct interface_info *)0;
- share -> group = clone_group (group, "parse_shared_net_declaration");
- share -> group -> shared_network = share;
-
- /* Get the name of the shared network... */
- token = peek_token (&val, cfile);
- if (token == STRING) {
- token = next_token (&val, cfile);
-
- if (val [0] == 0) {
- parse_warn ("zero-length shared network name");
- val = "<no-name-given>";
- }
- name = malloc (strlen (val) + 1);
- if (!name)
- error ("no memory for shared network name");
- strcpy (name, val);
- } else {
- name = parse_host_name (cfile);
- if (!name)
- return;
- }
- share -> name = name;
-
- if (!parse_lbrace (cfile))
- return;
-
- do {
- token = peek_token (&val, cfile);
- if (token == RBRACE) {
- token = next_token (&val, cfile);
- if (!share -> subnets) {
- parse_warn ("empty shared-network decl");
- return;
- }
- enter_shared_network (share);
- return;
- } else if (token == EOF) {
- token = next_token (&val, cfile);
- parse_warn ("unexpected end of file");
- break;
- }
-
- declaration = parse_statement (cfile, share -> group,
- SHARED_NET_DECL,
- (struct host_decl *)0,
- declaration);
- } while (1);
-}
-
-/* subnet-declaration :==
- net NETMASK netmask RBRACE parameters declarations LBRACE */
-
-void parse_subnet_declaration (cfile, share)
- FILE *cfile;
- struct shared_network *share;
-{
- char *val;
- int token;
- struct subnet *subnet, *t;
- struct iaddr iaddr;
- unsigned char addr [4];
- int len = sizeof addr;
- int declaration = 0;
-
- subnet = new_subnet ("parse_subnet_declaration");
- if (!subnet)
- error ("No memory for new subnet");
- subnet -> shared_network = share;
- subnet -> group = clone_group (share -> group,
- "parse_subnet_declaration");
- subnet -> group -> subnet = subnet;
-
- /* Get the network number... */
- if (!parse_numeric_aggregate (cfile, addr, &len, DOT, 10, 8))
- return;
- memcpy (iaddr.iabuf, addr, len);
- iaddr.len = len;
- subnet -> net = iaddr;
-
- token = next_token (&val, cfile);
- if (token != NETMASK) {
- parse_warn ("Expecting netmask");
- skip_to_semi (cfile);
- return;
- }
-
- /* Get the netmask... */
- if (!parse_numeric_aggregate (cfile, addr, &len, DOT, 10, 8))
- return;
- memcpy (iaddr.iabuf, addr, len);
- iaddr.len = len;
- subnet -> netmask = iaddr;
-
- enter_subnet (subnet);
-
- if (!parse_lbrace (cfile))
- return;
-
- do {
- token = peek_token (&val, cfile);
- if (token == RBRACE) {
- token = next_token (&val, cfile);
- break;
- } else if (token == EOF) {
- token = next_token (&val, cfile);
- parse_warn ("unexpected end of file");
- break;
- }
- declaration = parse_statement (cfile, subnet -> group,
- SUBNET_DECL,
- (struct host_decl *)0,
- declaration);
- } while (1);
-
- /* If this subnet supports dynamic bootp, flag it so in the
- shared_network containing it. */
- if (subnet -> group -> dynamic_bootp)
- share -> group -> dynamic_bootp = 1;
- if (subnet -> group -> one_lease_per_client)
- share -> group -> one_lease_per_client = 1;
-
- /* Add the subnet to the list of subnets in this shared net. */
- if (!share -> subnets)
- share -> subnets = subnet;
- else {
- for (t = share -> subnets;
- t -> next_sibling; t = t -> next_sibling)
- ;
- t -> next_sibling = subnet;
- }
-}
-
-/* group-declaration :== RBRACE parameters declarations LBRACE */
-
-void parse_group_declaration (cfile, group)
- FILE *cfile;
- struct group *group;
-{
- char *val;
- int token;
- struct group *g;
- int declaration = 0;
-
- g = clone_group (group, "parse_group_declaration");
-
- if (!parse_lbrace (cfile))
- return;
-
- do {
- token = peek_token (&val, cfile);
- if (token == RBRACE) {
- token = next_token (&val, cfile);
- break;
- } else if (token == EOF) {
- token = next_token (&val, cfile);
- parse_warn ("unexpected end of file");
- break;
- }
- declaration = parse_statement (cfile, g, GROUP_DECL,
- (struct host_decl *)0,
- declaration);
- } while (1);
-}
-
-/* hardware-parameter :== HARDWARE ETHERNET csns SEMI
- csns :== NUMBER | csns COLON NUMBER */
-
-void parse_hardware_param (cfile, hardware)
- FILE *cfile;
- struct hardware *hardware;
-{
- char *val;
- int token;
- int hlen;
- unsigned char *t;
-
- token = next_token (&val, cfile);
- switch (token) {
- case ETHERNET:
- hardware -> htype = HTYPE_ETHER;
- break;
- case TOKEN_RING:
- hardware -> htype = HTYPE_IEEE802;
- break;
- default:
- parse_warn ("expecting a network hardware type");
- skip_to_semi (cfile);
- return;
- }
-
- /* Parse the hardware address information. Technically,
- it would make a lot of sense to restrict the length of the
- data we'll accept here to the length of a particular hardware
- address type. Unfortunately, there are some broken clients
- out there that put bogus data in the chaddr buffer, and we accept
- that data in the lease file rather than simply failing on such
- clients. Yuck. */
- hlen = 0;
- t = parse_numeric_aggregate (cfile, (unsigned char *)0, &hlen,
- COLON, 16, 8);
- if (!t)
- return;
- if (hlen > sizeof hardware -> haddr) {
- free (t);
- parse_warn ("hardware address too long");
- } else {
- hardware -> hlen = hlen;
- memcpy ((unsigned char *)&hardware -> haddr [0],
- t, hardware -> hlen);
- free (t);
- }
-
- token = next_token (&val, cfile);
- if (token != SEMI) {
- parse_warn ("expecting semicolon.");
- skip_to_semi (cfile);
- }
-}
-
-/* string-parameter :== STRING SEMI */
-
-char *parse_string (cfile)
- FILE *cfile;
-{
- char *val;
- int token;
- char *s;
-
- token = next_token (&val, cfile);
- if (token != STRING) {
- parse_warn ("filename must be a string");
- skip_to_semi (cfile);
- return (char *)0;
- }
- s = (char *)malloc (strlen (val) + 1);
- if (!s)
- error ("no memory for string %s.", val);
- strcpy (s, val);
-
- if (!parse_semi (cfile))
- return (char *)0;
- return s;
-}
-
-/* ip-addr-or-hostname :== ip-address | hostname
- ip-address :== NUMBER DOT NUMBER DOT NUMBER DOT NUMBER
-
- Parse an ip address or a hostname. If uniform is zero, put in
- a TREE_LIMIT node to catch hostnames that evaluate to more than
- one IP address. */
-
-struct tree *parse_ip_addr_or_hostname (cfile, uniform)
- FILE *cfile;
- int uniform;
-{
- char *val;
- int token;
- unsigned char addr [4];
- int len = sizeof addr;
- char *name;
- struct tree *rv;
-
- token = peek_token (&val, cfile);
- if (is_identifier (token)) {
- name = parse_host_name (cfile);
- if (!name)
- return (struct tree *)0;
- rv = tree_host_lookup (name);
- if (!uniform)
- rv = tree_limit (rv, 4);
- } else if (token == NUMBER) {
- if (!parse_numeric_aggregate (cfile, addr, &len, DOT, 10, 8))
- return (struct tree *)0;
- rv = tree_const (addr, len);
- } else {
- if (token != RBRACE && token != LBRACE)
- token = next_token (&val, cfile);
- parse_warn ("%s (%d): expecting IP address or hostname",
- val, token);
- if (token != SEMI)
- skip_to_semi (cfile);
- return (struct tree *)0;
- }
-
- return rv;
-}
-
-
-/* fixed-addr-parameter :== ip-addrs-or-hostnames SEMI
- ip-addrs-or-hostnames :== ip-addr-or-hostname
- | ip-addrs-or-hostnames ip-addr-or-hostname */
-
-struct tree_cache *parse_fixed_addr_param (cfile)
- FILE *cfile;
-{
- char *val;
- int token;
- struct tree *tree = (struct tree *)0;
- struct tree *tmp;
-
- do {
- tmp = parse_ip_addr_or_hostname (cfile, 0);
- if (tree)
- tree = tree_concat (tree, tmp);
- else
- tree = tmp;
- token = peek_token (&val, cfile);
- if (token == COMMA)
- token = next_token (&val, cfile);
- } while (token == COMMA);
-
- if (!parse_semi (cfile))
- return (struct tree_cache *)0;
- return tree_cache (tree);
-}
-
-/* option_parameter :== identifier DOT identifier <syntax> SEMI
- | identifier <syntax> SEMI
-
- Option syntax is handled specially through format strings, so it
- would be painful to come up with BNF for it. However, it always
- starts as above and ends in a SEMI. */
-
-void parse_option_param (cfile, group)
- FILE *cfile;
- struct group *group;
-{
- char *val;
- int token;
- unsigned char buf [4];
- char *vendor;
- char *fmt;
- struct universe *universe;
- struct option *option;
- struct tree *tree = (struct tree *)0;
- struct tree *t;
-
- token = next_token (&val, cfile);
- if (!is_identifier (token)) {
- parse_warn ("expecting identifier after option keyword.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return;
- }
- vendor = malloc (strlen (val) + 1);
- strcpy (vendor, val);
- token = peek_token (&val, cfile);
- if (token == DOT) {
- /* Go ahead and take the DOT token... */
- token = next_token (&val, cfile);
-
- /* The next token should be an identifier... */
- token = next_token (&val, cfile);
- if (!is_identifier (token)) {
- parse_warn ("expecting identifier after '.'");
- if (token != SEMI)
- skip_to_semi (cfile);
- return;
- }
-
- /* Look up the option name hash table for the specified
- vendor. */
- universe = (struct universe *)hash_lookup (&universe_hash,
- vendor, 0);
- /* If it's not there, we can't parse the rest of the
- declaration. */
- if (!universe) {
- parse_warn ("no vendor named %s.", vendor);
- skip_to_semi (cfile);
- return;
- }
- } else {
- /* Use the default hash table, which contains all the
- standard dhcp option names. */
- val = vendor;
- universe = &dhcp_universe;
- }
-
- /* Look up the actual option info... */
- option = (struct option *)hash_lookup (universe -> hash, val, 0);
-
- /* If we didn't get an option structure, it's an undefined option. */
- if (!option) {
- if (val == vendor)
- parse_warn ("no option named %s", val);
- else
- parse_warn ("no option named %s for vendor %s",
- val, vendor);
- skip_to_semi (cfile);
- return;
- }
-
- /* Free the initial identifier token. */
- free (vendor);
-
- /* Parse the option data... */
- do {
- /* Set a flag if this is an array of a simple type (i.e.,
- not an array of pairs of IP addresses, or something
- like that. */
- int uniform = option -> format [1] == 'A';
-
- for (fmt = option -> format; *fmt; fmt++) {
- if (*fmt == 'A')
- break;
- switch (*fmt) {
- case 'X':
- token = peek_token (&val, cfile);
- if (token == NUMBER_OR_NAME ||
- token == NUMBER) {
- do {
- token = next_token
- (&val, cfile);
- if (token != NUMBER
- && token != NUMBER_OR_NAME)
- goto need_number;
- convert_num (buf, val, 16, 8);
- tree = tree_concat
- (tree,
- tree_const (buf, 1));
- token = peek_token
- (&val, cfile);
- if (token == COLON)
- token = next_token
- (&val, cfile);
- } while (token == COLON);
- } else if (token == STRING) {
- token = next_token (&val, cfile);
- tree = tree_concat
- (tree,
- tree_const (val,
- strlen (val)));
- } else {
- parse_warn ("expecting string %s.",
- "or hexadecimal data");
- skip_to_semi (cfile);
- return;
- }
- break;
-
- case 't': /* Text string... */
- token = next_token (&val, cfile);
- if (token != STRING
- && !is_identifier (token)) {
- parse_warn ("expecting string.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return;
- }
- tree = tree_concat (tree,
- tree_const (val,
- strlen (val)));
- break;
-
- case 'I': /* IP address or hostname. */
- t = parse_ip_addr_or_hostname (cfile, uniform);
- if (!t)
- return;
- tree = tree_concat (tree, t);
- break;
-
- case 'L': /* Unsigned 32-bit integer... */
- case 'l': /* Signed 32-bit integer... */
- token = next_token (&val, cfile);
- if (token != NUMBER) {
- need_number:
- parse_warn ("expecting number.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return;
- }
- convert_num (buf, val, 0, 32);
- tree = tree_concat (tree, tree_const (buf, 4));
- break;
- case 's': /* Signed 16-bit integer. */
- case 'S': /* Unsigned 16-bit integer. */
- token = next_token (&val, cfile);
- if (token != NUMBER)
- goto need_number;
- convert_num (buf, val, 0, 16);
- tree = tree_concat (tree, tree_const (buf, 2));
- break;
- case 'b': /* Signed 8-bit integer. */
- case 'B': /* Unsigned 8-bit integer. */
- token = next_token (&val, cfile);
- if (token != NUMBER)
- goto need_number;
- convert_num (buf, val, 0, 8);
- tree = tree_concat (tree, tree_const (buf, 1));
- break;
- case 'f': /* Boolean flag. */
- token = next_token (&val, cfile);
- if (!is_identifier (token)) {
- parse_warn ("expecting identifier.");
- bad_flag:
- if (token != SEMI)
- skip_to_semi (cfile);
- return;
- }
- if (!strcasecmp (val, "true")
- || !strcasecmp (val, "on"))
- buf [0] = 1;
- else if (!strcasecmp (val, "false")
- || !strcasecmp (val, "off"))
- buf [0] = 0;
- else {
- parse_warn ("expecting boolean.");
- goto bad_flag;
- }
- tree = tree_concat (tree, tree_const (buf, 1));
- break;
- default:
- warn ("Bad format %c in parse_option_param.",
- *fmt);
- skip_to_semi (cfile);
- return;
- }
- }
- if (*fmt == 'A') {
- token = peek_token (&val, cfile);
- if (token == COMMA) {
- token = next_token (&val, cfile);
- continue;
- }
- break;
- }
- } while (*fmt == 'A');
-
- token = next_token (&val, cfile);
- if (token != SEMI) {
- parse_warn ("semicolon expected.");
- skip_to_semi (cfile);
- return;
- }
- group -> options [option -> code] = tree_cache (tree);
-}
-
-/* timestamp :== date
-
- Timestamps are actually not used in dhcpd.conf, which is a static file,
- but rather in the database file and the journal file. (Okay, actually
- they're not even used there yet). */
-
-TIME parse_timestamp (cfile)
- FILE *cfile;
-{
- TIME rv;
-
- rv = parse_date (cfile);
- return rv;
-}
-
-/* lease_declaration :== LEASE ip_address LBRACE lease_parameters RBRACE
-
- lease_parameters :== <nil>
- | lease_parameter
- | lease_parameters lease_parameter
-
- lease_parameter :== STARTS date
- | ENDS date
- | TIMESTAMP date
- | HARDWARE hardware-parameter
- | UID hex_numbers SEMI
- | HOST hostname SEMI
- | CLASS identifier SEMI
- | DYNAMIC_BOOTP SEMI */
-
-struct lease *parse_lease_declaration (cfile)
- FILE *cfile;
-{
- char *val;
- int token;
- unsigned char addr [4];
- int len = sizeof addr;
- int seenmask = 0;
- int seenbit;
- char tbuf [32];
- static struct lease lease;
-
- /* Zap the lease structure... */
- memset (&lease, 0, sizeof lease);
-
- /* Get the address for which the lease has been issued. */
- if (!parse_numeric_aggregate (cfile, addr, &len, DOT, 10, 8))
- return (struct lease *)0;
- memcpy (lease.ip_addr.iabuf, addr, len);
- lease.ip_addr.len = len;
-
- if (!parse_lbrace (cfile))
- return (struct lease *)0;
-
- do {
- token = next_token (&val, cfile);
- if (token == RBRACE)
- break;
- else if (token == EOF) {
- parse_warn ("unexpected end of file");
- break;
- }
- strncpy (val, tbuf, sizeof tbuf);
- tbuf [(sizeof tbuf) - 1] = 0;
-
- /* Parse any of the times associated with the lease. */
- if (token == STARTS || token == ENDS || token == TIMESTAMP) {
- TIME t;
- t = parse_date (cfile);
- switch (token) {
- case STARTS:
- seenbit = 1;
- lease.starts = t;
- break;
-
- case ENDS:
- seenbit = 2;
- lease.ends = t;
- break;
-
- case TIMESTAMP:
- seenbit = 4;
- lease.timestamp = t;
- break;
-
- default:
- /*NOTREACHED*/
- seenbit = 0;
- break;
- }
- } else {
- switch (token) {
- /* Colon-seperated hexadecimal octets... */
- case UID:
- seenbit = 8;
- token = peek_token (&val, cfile);
- if (token == STRING) {
- token = next_token (&val, cfile);
- lease.uid_len = strlen (val) + 1;
- lease.uid = (unsigned char *)
- malloc (lease.uid_len);
- if (!lease.uid) {
- warn ("no space for uid");
- return (struct lease *)0;
- }
- memcpy (lease.uid, val, lease.uid_len);
- } else {
- lease.uid_len = 0;
- lease.uid = parse_numeric_aggregate
- (cfile, (unsigned char *)0,
- &lease.uid_len, ':', 16, 8);
- if (!lease.uid) {
- warn ("no space for uid");
- return (struct lease *)0;
- }
- if (lease.uid_len == 0) {
- lease.uid = (unsigned char *)0;
- parse_warn ("zero-length uid");
- seenbit = 0;
- break;
- }
- }
- if (!lease.uid) {
- error ("No memory for lease uid");
- }
- break;
-
- case CLASS:
- seenbit = 32;
- token = next_token (&val, cfile);
- if (!is_identifier (token)) {
- if (token != SEMI)
- skip_to_semi (cfile);
- return (struct lease *)0;
- }
- /* for now, we aren't using this. */
- break;
-
- case HARDWARE:
- seenbit = 64;
- parse_hardware_param (cfile,
- &lease.hardware_addr);
- break;
-
- case DYNAMIC_BOOTP:
- seenbit = 128;
- lease.flags |= BOOTP_LEASE;
- break;
-
- default:
- skip_to_semi (cfile);
- seenbit = 0;
- return (struct lease *)0;
- }
-
- if (token != HARDWARE) {
- token = next_token (&val, cfile);
- if (token != SEMI) {
- parse_warn ("semicolon expected.");
- skip_to_semi (cfile);
- return (struct lease *)0;
- }
- }
- }
- if (seenmask & seenbit) {
- parse_warn ("Too many %s parameters in lease %s\n",
- tbuf, piaddr (lease.ip_addr));
- } else
- seenmask |= seenbit;
-
- } while (1);
- return &lease;
-}
-
-/* address-range-declaration :== ip-address ip-address SEMI
- | DYNAMIC_BOOTP ip-address ip-address SEMI */
-
-void parse_address_range (cfile, subnet)
- FILE *cfile;
- struct subnet *subnet;
-{
- struct iaddr low, high;
- unsigned char addr [4];
- int len = sizeof addr;
- int token;
- char *val;
- int dynamic = 0;
-
- if ((token = peek_token (&val, cfile)) == DYNAMIC_BOOTP) {
- token = next_token (&val, cfile);
- subnet -> group -> dynamic_bootp = dynamic = 1;
- }
-
- /* Get the bottom address in the range... */
- if (!parse_numeric_aggregate (cfile, addr, &len, DOT, 10, 8))
- return;
- memcpy (low.iabuf, addr, len);
- low.len = len;
-
- /* Only one address? */
- token = peek_token (&val, cfile);
- if (token == SEMI)
- high = low;
- else {
- /* Get the top address in the range... */
- if (!parse_numeric_aggregate (cfile, addr, &len, DOT, 10, 8))
- return;
- memcpy (high.iabuf, addr, len);
- high.len = len;
- }
-
- token = next_token (&val, cfile);
- if (token != SEMI) {
- parse_warn ("semicolon expected.");
- skip_to_semi (cfile);
- return;
- }
-
- /* Create the new address range... */
- new_address_range (low, high, subnet, dynamic);
-}
-
-/* date :== NUMBER NUMBER SLASH NUMBER SLASH NUMBER
- NUMBER COLON NUMBER COLON NUMBER SEMI
-
- Dates are always in GMT; first number is day of week; next is
- year/month/day; next is hours:minutes:seconds on a 24-hour
- clock. */
-
-TIME parse_date (cfile)
- FILE *cfile;
-{
- struct tm tm;
- int guess;
- char *val;
- int token;
- static int months [11] = { 31, 59, 90, 120, 151, 181,
- 212, 243, 273, 304, 334 };
-
- /* Day of week... */
- token = next_token (&val, cfile);
- if (token != NUMBER) {
- parse_warn ("numeric day of week expected.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return (TIME)0;
- }
- tm.tm_wday = atoi (val);
-
- /* Year... */
- token = next_token (&val, cfile);
- if (token != NUMBER) {
- parse_warn ("numeric year expected.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return (TIME)0;
- }
- tm.tm_year = atoi (val);
- if (tm.tm_year > 1900)
- tm.tm_year -= 1900;
-
- /* Slash seperating year from month... */
- token = next_token (&val, cfile);
- if (token != SLASH) {
- parse_warn ("expected slash seperating year from month.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return (TIME)0;
- }
-
- /* Month... */
- token = next_token (&val, cfile);
- if (token != NUMBER) {
- parse_warn ("numeric month expected.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return (TIME)0;
- }
- tm.tm_mon = atoi (val) - 1;
-
- /* Slash seperating month from day... */
- token = next_token (&val, cfile);
- if (token != SLASH) {
- parse_warn ("expected slash seperating month from day.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return (TIME)0;
- }
-
- /* Month... */
- token = next_token (&val, cfile);
- if (token != NUMBER) {
- parse_warn ("numeric day of month expected.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return (TIME)0;
- }
- tm.tm_mday = atoi (val);
-
- /* Hour... */
- token = next_token (&val, cfile);
- if (token != NUMBER) {
- parse_warn ("numeric hour expected.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return (TIME)0;
- }
- tm.tm_hour = atoi (val);
-
- /* Colon seperating hour from minute... */
- token = next_token (&val, cfile);
- if (token != COLON) {
- parse_warn ("expected colon seperating hour from minute.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return (TIME)0;
- }
-
- /* Minute... */
- token = next_token (&val, cfile);
- if (token != NUMBER) {
- parse_warn ("numeric minute expected.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return (TIME)0;
- }
- tm.tm_min = atoi (val);
-
- /* Colon seperating minute from second... */
- token = next_token (&val, cfile);
- if (token != COLON) {
- parse_warn ("expected colon seperating hour from minute.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return (TIME)0;
- }
-
- /* Minute... */
- token = next_token (&val, cfile);
- if (token != NUMBER) {
- parse_warn ("numeric minute expected.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return (TIME)0;
- }
- tm.tm_sec = atoi (val);
- tm.tm_isdst = 0;
-
- /* XXX */ /* We assume that mktime does not use tm_yday. */
- tm.tm_yday = 0;
-
- /* Make sure the date ends in a semicolon... */
- token = next_token (&val, cfile);
- if (token != SEMI) {
- parse_warn ("semicolon expected.");
- skip_to_semi (cfile);
- return 0;
- }
-
- /* Guess the time value... */
- guess = ((((((365 * (tm.tm_year - 70) + /* Days in years since '70 */
- (tm.tm_year - 72) / 4 + /* Leap days since '70 */
- (tm.tm_mon /* Days in months this year */
- ? months [tm.tm_mon - 1]
- : 0) +
- (tm.tm_mon > 1 && /* Leap day this year */
- ((tm.tm_year - 72) & 3)) +
- tm.tm_mday) * 24) + /* Day of month */
- tm.tm_hour) * 60) +
- tm.tm_min) * 60) + tm.tm_sec;
-
- /* This guess could be wrong because of leap seconds or other
- weirdness we don't know about that the system does. For
- now, we're just going to accept the guess, but at some point
- it might be nice to do a successive approximation here to
- get an exact value. Even if the error is small, if the
- server is restarted frequently (and thus the lease database
- is reread), the error could accumulate into something
- significant. */
-
- return guess;
-}
-
-/* No BNF for numeric aggregates - that's defined by the caller. What
- this function does is to parse a sequence of numbers seperated by
- the token specified in seperator. If max is zero, any number of
- numbers will be parsed; otherwise, exactly max numbers are
- expected. Base and size tell us how to internalize the numbers
- once they've been tokenized. */
-
-unsigned char *parse_numeric_aggregate (cfile, buf,
- max, seperator, base, size)
- FILE *cfile;
- unsigned char *buf;
- int *max;
- int seperator;
- int base;
- int size;
-{
- char *val;
- int token;
- unsigned char *bufp = buf, *s, *t;
- int count = 0;
- pair c = (pair)0;
-
- if (!bufp && *max) {
- bufp = (unsigned char *)malloc (*max * size / 8);
- if (!bufp)
- error ("can't allocate space for numeric aggregate");
- } else
- s = bufp;
-
- do {
- if (count) {
- token = peek_token (&val, cfile);
- if (token != seperator) {
- if (!*max)
- break;
- if (token != RBRACE && token != LBRACE)
- token = next_token (&val, cfile);
- parse_warn ("too few numbers.");
- if (token != SEMI)
- skip_to_semi (cfile);
- return (unsigned char *)0;
- }
- token = next_token (&val, cfile);
- }
- token = next_token (&val, cfile);
-
- if (token == EOF) {
- parse_warn ("unexpected end of file");
- break;
- }
-
- /* Allow NUMBER_OR_NAME if base is 16. */
- if (token != NUMBER &&
- (base != 16 || token != NUMBER_OR_NAME)) {
- parse_warn ("expecting numeric value.");
- skip_to_semi (cfile);
- return (unsigned char *)0;
- }
- /* If we can, convert the number now; otherwise, build
- a linked list of all the numbers. */
- if (s) {
- convert_num (s, val, base, size);
- s += size / 8;
- } else {
- t = (unsigned char *)malloc (strlen (val) + 1);
- if (!t)
- error ("no temp space for number.");
- strcpy (t, val);
- c = cons (t, c);
- }
- } while (++count != *max);
-
- /* If we had to cons up a list, convert it now. */
- if (c) {
- bufp = (unsigned char *)malloc (count * size / 8);
- if (!bufp)
- error ("can't allocate space for numeric aggregate.");
- s = bufp + count - size / 8;
- *max = count;
- }
- while (c) {
- pair cdr = c -> cdr;
- convert_num (s, (char *)(c -> car), base, size);
- s -= size / 8;
- /* Free up temp space. */
- free (c -> car);
- free (c);
- c = cdr;
- }
- return bufp;
-}
-
-void convert_num (buf, str, base, size)
- unsigned char *buf;
- char *str;
- int base;
- int size;
-{
- char *ptr = str;
- int negative = 0;
- u_int32_t val = 0;
- int tval;
- int max;
-
- if (*ptr == '-') {
- negative = 1;
- ++ptr;
- }
-
- /* If base wasn't specified, figure it out from the data. */
- if (!base) {
- if (ptr [0] == '0') {
- if (ptr [1] == 'x') {
- base = 16;
- ptr += 2;
- } else if (isascii (ptr [1]) && isdigit (ptr [1])) {
- base = 8;
- ptr += 1;
- } else {
- base = 10;
- }
- } else {
- base = 10;
- }
- }
-
- do {
- tval = *ptr++;
- /* XXX assumes ASCII... */
- if (tval >= 'a')
- tval = tval - 'a' + 10;
- else if (tval >= 'A')
- tval = tval - 'A' + 10;
- else if (tval >= '0')
- tval -= '0';
- else {
- warn ("Bogus number: %s.", str);
- break;
- }
- if (tval >= base) {
- warn ("Bogus number: %s: digit %d not in base %d\n",
- str, tval, base);
- break;
- }
- val = val * base + tval;
- } while (*ptr);
-
- if (negative)
- max = (1 << (size - 1));
- else
- max = (1 << (size - 1)) + ((1 << (size - 1)) - 1);
- if (val > max) {
- switch (base) {
- case 8:
- warn ("value %s%o exceeds max (%d) for precision.",
- negative ? "-" : "", val, max);
- break;
- case 16:
- warn ("value %s%x exceeds max (%d) for precision.",
- negative ? "-" : "", val, max);
- break;
- default:
- warn ("value %s%u exceeds max (%d) for precision.",
- negative ? "-" : "", val, max);
- break;
- }
- }
-
- if (negative) {
- switch (size) {
- case 8:
- *buf = -(unsigned long)val;
- break;
- case 16:
- putShort (buf, -(unsigned long)val);
- break;
- case 32:
- putLong (buf, -(unsigned long)val);
- break;
- default:
- warn ("Unexpected integer size: %d\n", size);
- break;
- }
- } else {
- switch (size) {
- case 8:
- *buf = (u_int8_t)val;
- break;
- case 16:
- putUShort (buf, (u_int16_t)val);
- break;
- case 32:
- putULong (buf, val);
- break;
- default:
- warn ("Unexpected integer size: %d\n", size);
- break;
- }
- }
-}
diff --git a/server/db.c b/server/db.c
deleted file mode 100644
index afdaff2e..00000000
--- a/server/db.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/* db.c
-
- Persistent database management routines for DHCPD... */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: db.c,v 1.8 1996/09/02 21:16:24 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-FILE *db_file;
-
-static int counting = 0;
-static int count = 0;
-TIME write_time;
-
-/* Write the specified lease to the current lease database file. */
-
-int write_lease (lease)
- struct lease *lease;
-{
- struct tm *t;
- char tbuf [64];
- int errors = 0;
-
- if (counting)
- ++count;
- errno = 0;
- fprintf (db_file, "lease %s {\n", piaddr (lease -> ip_addr));
- if (errno) {
- ++errors;
- }
-
- t = gmtime (&lease -> starts);
- sprintf (tbuf, "%d %d/%d/%d %02d:%02d:%02d;",
- t -> tm_wday, t -> tm_year + 1900,
- t -> tm_mon + 1, t -> tm_mday,
- t -> tm_hour, t -> tm_min, t -> tm_sec);
- errno = 0;
- fprintf (db_file, "\tstarts %s\n", tbuf);
- if (errno) {
- ++errors;
- }
-
- t = gmtime (&lease -> ends);
- sprintf (tbuf, "%d %d/%d/%d %02d:%02d:%02d;",
- t -> tm_wday, t -> tm_year + 1900,
- t -> tm_mon + 1, t -> tm_mday,
- t -> tm_hour, t -> tm_min, t -> tm_sec);
- errno = 0;
- fprintf (db_file, "\tends %s", tbuf);
- if (errno) {
- ++errors;
- }
-
- if (lease -> hardware_addr.hlen) {
- errno = 0;
- fprintf (db_file, "\n\thardware %s %s;",
- hardware_types [lease -> hardware_addr.htype],
- print_hw_addr (lease -> hardware_addr.htype,
- lease -> hardware_addr.hlen,
- lease -> hardware_addr.haddr));
- if (errno) {
- ++errors;
- }
- }
- if (lease -> uid_len) {
- int i;
- errno = 0;
- fprintf (db_file, "\n\tuid %x", lease -> uid [0]);
- if (errno) {
- ++errors;
- }
- for (i = 1; i < lease -> uid_len; i++) {
- errno = 0;
- fprintf (db_file, ":%x", lease -> uid [i]);
- if (errno) {
- ++errors;
- }
- }
- putc (';', db_file);
- }
- if (lease -> flags & BOOTP_LEASE) {
- errno = 0;
- fprintf (db_file, "\n\tdynamic-bootp;");
- if (errno) {
- ++errors;
- }
- }
- errno = 0;
- fputs ("\n}\n", db_file);
- if (errno) {
- ++errors;
- }
- if (errors)
- note ("write_lease: unable to write lease %s",
- piaddr (lease -> ip_addr));
- return !errors;
-}
-
-/* Commit any leases that have been written out... */
-
-int commit_leases ()
-{
- /* Commit any outstanding writes to the lease database file.
- We need to do this even if we're rewriting the file below,
- just in case the rewrite fails. */
- if (fflush (db_file) == EOF) {
- note ("commit_leases: unable to commit: %m");
- return 0;
- }
- if (fsync (fileno (db_file)) < 0) {
- note ("commit_leases: unable to commit: %m");
- return 0;
- }
-
- /* If we've written more than a thousand leases or if
- we haven't rewritten the lease database in over an
- hour, rewrite it now. */
- if (count > 1000 || (count && cur_time - write_time > 3600)) {
- count = 0;
- write_time = cur_time;
- new_lease_file ();
- }
- return 1;
-}
-
-void db_startup ()
-{
- /* Read in the existing lease file... */
- read_leases ();
-
- new_lease_file ();
-}
-
-void new_lease_file ()
-{
- char newfname [512];
- char backfname [512];
- TIME t;
-
- /* If we already have an open database, close it. */
- if (db_file) {
- fclose (db_file);
- }
-
- /* Make a temporary lease file... */
- time (&t);
- sprintf (newfname, "%s.%d", path_dhcpd_db, (int) (t & 32767));
- if ((db_file = fopen (newfname, "w")) == NULL) {
- error ("Can't start new lease file: %m");
- }
-
- /* Write out all the leases that we know of... */
- counting = 0;
- write_leases ();
-
- /* Get the old database out of the way... */
- sprintf (backfname, "%s~", path_dhcpd_db);
- if (unlink (backfname) < 0 && errno != ENOENT)
- error ("Can't remove old lease database backup %s: %m",
- backfname);
- if (link (path_dhcpd_db, backfname) < 0)
- error ("Can't backup lease database %s to %s: %m",
- path_dhcpd_db, backfname);
-
- /* Move in the new file... */
- if (rename (newfname, path_dhcpd_db) < 0)
- error ("Can't install new lease database %s to %s: %m",
- newfname, path_dhcpd_db);
-
- counting = 1;
-}
diff --git a/server/dhcp.c b/server/dhcp.c
deleted file mode 100644
index fc5e2e1a..00000000
--- a/server/dhcp.c
+++ /dev/null
@@ -1,1162 +0,0 @@
-/* dhcp.c
-
- DHCP Protocol engine. */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char copyright[] =
-"$Id: dhcp.c,v 1.34 1996/09/11 05:52:18 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
-#endif /* not lint */
-
-#include "dhcpd.h"
-
-static unsigned char dhcp_message [256];
-
-void dhcp (packet)
- struct packet *packet;
-{
- if (!locate_network (packet))
- return;
-
- switch (packet -> packet_type) {
- case DHCPDISCOVER:
- dhcpdiscover (packet);
- break;
-
- case DHCPREQUEST:
- dhcprequest (packet);
- break;
-
- case DHCPRELEASE:
- dhcprelease (packet);
- break;
-
- case DHCPDECLINE:
- dhcpdecline (packet);
- break;
-
- case DHCPINFORM:
- dhcpinform (packet);
- break;
-
- default:
- break;
- }
-}
-
-void dhcpdiscover (packet)
- struct packet *packet;
-{
- struct lease *lease = find_lease (packet, packet -> shared_network);
- struct host_decl *hp;
-
- note ("DHCPDISCOVER from %s via %s",
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr),
- packet -> raw -> giaddr.s_addr
- ? inet_ntoa (packet -> raw -> giaddr)
- : packet -> interface -> name);
-
- /* Sourceless packets don't make sense here. */
- if (!packet -> shared_network) {
- note ("Packet from unknown subnet: %s",
- inet_ntoa (packet -> raw -> giaddr));
- return;
- }
-
- /* If we didn't find a lease, try to allocate one... */
- if (!lease) {
- lease = packet -> shared_network -> last_lease;
-
- /* If there are no leases in that subnet that have
- expired, we have nothing to offer this client. */
- if (!lease || lease -> ends > cur_time) {
- note ("no free leases on subnet %s",
- packet -> shared_network -> name);
- return;
- }
-
- /* Try to find a host_decl that matches the client
- identifier or hardware address on the packet, and
- has no fixed IP address. If there is one, hang
- it off the lease so that its option definitions
- can be used. */
- if (((packet -> options [DHO_DHCP_CLIENT_IDENTIFIER].len
- != 0) &&
- ((hp = find_hosts_by_uid
- (packet -> options [DHO_DHCP_CLIENT_IDENTIFIER].data,
- packet -> options [DHO_DHCP_CLIENT_IDENTIFIER].len))
- != (struct host_decl *)0)) ||
- ((hp = find_hosts_by_haddr (packet -> raw -> htype,
- packet -> raw -> chaddr,
- packet -> raw -> hlen))
- != (struct host_decl *)0)) {
- for (; hp; hp = hp -> n_ipaddr) {
- if (!hp -> fixed_addr) {
- lease -> host = hp;
- break;
- }
- }
- } else {
- lease -> host = (struct host_decl *)0;
- }
- }
-
- /* If this subnet won't boot unknown clients, ignore the
- request. */
- if (!lease -> host &&
- !lease -> subnet -> group -> boot_unknown_clients) {
- note ("Ignoring unknown client %s",
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr));
- } else
- ack_lease (packet, lease, DHCPOFFER, cur_time + 120);
-}
-
-void dhcprequest (packet)
- struct packet *packet;
-{
- struct lease *lease;
- struct iaddr cip;
- struct subnet *subnet;
-
- if (packet -> options [DHO_DHCP_REQUESTED_ADDRESS].len) {
- cip.len = 4;
- memcpy (cip.iabuf,
- packet -> options [DHO_DHCP_REQUESTED_ADDRESS].data,
- 4);
- } else {
- cip.len = 4;
- memcpy (cip.iabuf, &packet -> raw -> ciaddr.s_addr, 4);
- }
-
- /* Find the lease that matches the address requested by the
- client. */
- subnet = find_subnet (cip);
- lease = find_lease (packet, (subnet
- ? subnet -> shared_network
- : (struct shared_network *)0));
-
- note ("DHCPREQUEST for %s from %s via %s",
- piaddr (cip),
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr),
- packet -> raw -> giaddr.s_addr
- ? inet_ntoa (packet -> raw -> giaddr)
- : packet -> interface -> name);
-
-
- /* If a client on a given network wants to request a lease on
- an address on a different network, NAK it. If the Requested
- Address option was used, the protocol says that it must have
- been broadcast, so we can trust the source network information.
-
- If ciaddr was specified and Requested Address was not, then
- we really only know for sure what network a packet came from
- if it came through a BOOTP gateway - if it came through an
- IP router, we'll just have to assume that it's cool.
-
- This violates the protocol spec in the case that the client
- is in the REBINDING state and broadcasts a DHCPREQUEST on
- the local wire. We're supposed to check ciaddr for
- validity in that case, but if the packet was unicast
- through a router from a client in the RENEWING state, it
- would look exactly the same to us and it would be very
- bad to send a DHCPNAK. I think we just have to live with
- this. */
- if ((packet -> raw -> ciaddr.s_addr &&
- packet -> raw -> giaddr.s_addr) ||
- packet -> options [DHO_DHCP_REQUESTED_ADDRESS].len) {
-
- /* If we don't know where it came from but we do know
- where it claims to have come from, it didn't come
- from there. Fry it. */
- if (!packet -> shared_network) {
- if (subnet) {
- nak_lease (packet, &cip);
- return;
- }
- /* Otherwise, ignore it. */
- return;
- }
-
- /* If we do know where it came from and we don't know
- where it claims to have come from, same deal - fry it. */
- subnet = find_grouped_subnet (packet -> shared_network, cip);
- if (!subnet) {
- nak_lease (packet, &cip);
- return;
- }
- }
-
- /* If we own the lease that the client is asking for,
- and it's already been assigned to the client, ack it. */
- if (lease &&
- ((lease -> uid_len && lease -> uid_len ==
- packet -> options [DHO_DHCP_CLIENT_IDENTIFIER].len &&
- !memcmp (packet -> options
- [DHO_DHCP_CLIENT_IDENTIFIER].data,
- lease -> uid, lease -> uid_len)) ||
- (lease -> hardware_addr.hlen == packet -> raw -> hlen &&
- lease -> hardware_addr.htype == packet -> raw -> htype &&
- !memcmp (lease -> hardware_addr.haddr,
- packet -> raw -> chaddr,
- packet -> raw -> hlen)))) {
- ack_lease (packet, lease, DHCPACK, 0);
- return;
- }
-
- /* Otherwise, if we have a lease for this client,
- release it, and in any case don't reply to the
- DHCPREQUEST. */
- if (packet -> options [DHO_DHCP_SERVER_IDENTIFIER].len
- && memcmp (packet ->
- options [DHO_DHCP_SERVER_IDENTIFIER].data,
- server_identifier.iabuf,
- server_identifier.len)) {
- if (lease)
- release_lease (lease);
- return;
- }
-}
-
-void dhcprelease (packet)
- struct packet *packet;
-{
- struct lease *lease = find_lease (packet, packet -> shared_network);
-
- note ("DHCPRELEASE of %s from %s via %s",
- inet_ntoa (packet -> raw -> ciaddr),
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr),
- packet -> raw -> giaddr.s_addr
- ? inet_ntoa (packet -> raw -> giaddr)
- : packet -> interface -> name);
-
-
- /* If we found a lease, release it. */
- if (lease) {
- release_lease (lease);
- }
-}
-
-void dhcpdecline (packet)
- struct packet *packet;
-{
- struct lease *lease = find_lease (packet, packet -> shared_network);
- struct iaddr cip;
-
- if (packet -> options [DHO_DHCP_REQUESTED_ADDRESS].len) {
- cip.len = 4;
- memcpy (cip.iabuf,
- packet -> options [DHO_DHCP_REQUESTED_ADDRESS].data,
- 4);
- } else {
- cip.len = 0;
- }
-
- note ("DHCPDECLINE on %s from %s via %s",
- piaddr (cip),
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr),
- packet -> raw -> giaddr.s_addr
- ? inet_ntoa (packet -> raw -> giaddr)
- : packet -> interface -> name);
-
-
- /* If we found a lease, mark it as unusable and complain. */
- if (lease) {
- abandon_lease (lease);
- }
-}
-
-void dhcpinform (packet)
- struct packet *packet;
-{
- note ("DHCPINFORM from %s",
- inet_ntoa (packet -> raw -> ciaddr));
-}
-
-void nak_lease (packet, cip)
- struct packet *packet;
- struct iaddr *cip;
-{
- struct sockaddr_in to;
- struct in_addr from;
- int result;
- struct dhcp_packet raw;
- unsigned char nak = DHCPNAK;
- struct packet outgoing;
- struct hardware hto;
-
- struct tree_cache *options [256];
- struct tree_cache dhcpnak_tree;
- struct tree_cache dhcpmsg_tree;
-
- memset (options, 0, sizeof options);
- memset (&outgoing, 0, sizeof outgoing);
- memset (&raw, 0, sizeof raw);
- outgoing.raw = &raw;
-
- /* Set DHCP_MESSAGE_TYPE to DHCPNAK */
- options [DHO_DHCP_MESSAGE_TYPE] = &dhcpnak_tree;
- options [DHO_DHCP_MESSAGE_TYPE] -> value = &nak;
- options [DHO_DHCP_MESSAGE_TYPE] -> len = sizeof nak;
- options [DHO_DHCP_MESSAGE_TYPE] -> buf_size = sizeof nak;
- options [DHO_DHCP_MESSAGE_TYPE] -> timeout = 0xFFFFFFFF;
- options [DHO_DHCP_MESSAGE_TYPE] -> tree = (struct tree *)0;
-
- /* Set DHCP_MESSAGE to whatever the message is */
- options [DHO_DHCP_MESSAGE] = &dhcpmsg_tree;
- options [DHO_DHCP_MESSAGE] -> value = dhcp_message;
- options [DHO_DHCP_MESSAGE] -> len = strlen (dhcp_message);
- options [DHO_DHCP_MESSAGE] -> buf_size = strlen (dhcp_message);
- options [DHO_DHCP_MESSAGE] -> timeout = 0xFFFFFFFF;
- options [DHO_DHCP_MESSAGE] -> tree = (struct tree *)0;
-
- /* Do not use the client's requested parameter list. */
- packet -> options [DHO_DHCP_PARAMETER_REQUEST_LIST].len = 0;
- packet -> options [DHO_DHCP_PARAMETER_REQUEST_LIST].data =
- (unsigned char *)0;
-
- /* Set up the option buffer... */
- cons_options (packet, &outgoing, options, 0, 0);
-
-/* memset (&raw.ciaddr, 0, sizeof raw.ciaddr);*/
- memcpy (&raw.siaddr, server_identifier.iabuf, 4);
- raw.giaddr = packet -> raw -> giaddr;
- memcpy (raw.chaddr, packet -> raw -> chaddr, sizeof raw.chaddr);
- raw.hlen = packet -> raw -> hlen;
- raw.htype = packet -> raw -> htype;
-
- raw.xid = packet -> raw -> xid;
- raw.secs = packet -> raw -> secs;
- raw.flags = packet -> raw -> flags | htons (BOOTP_BROADCAST);
- raw.hops = packet -> raw -> hops;
- raw.op = BOOTREPLY;
-
- /* Report what we're sending... */
- note ("DHCPNAK on %s to %s via %s",
- piaddr (*cip),
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr),
- packet -> raw -> giaddr.s_addr
- ? inet_ntoa (packet -> raw -> giaddr)
- : packet -> interface -> name);
-
-
-
-#ifdef DEBUG_PACKET
- dump_packet (packet);
- dump_raw ((unsigned char *)packet -> raw, packet -> packet_length);
- dump_packet (&outgoing);
- dump_raw ((unsigned char *)&raw, outgoing.packet_length);
-#endif
-
- hto.htype = packet -> raw -> htype;
- hto.hlen = packet -> raw -> hlen;
- memcpy (hto.haddr, packet -> raw -> chaddr, hto.hlen);
-
- /* Set up the common stuff... */
- to.sin_family = AF_INET;
-#ifdef HAVE_SA_LEN
- to.sin_len = sizeof to;
-#endif
- memset (to.sin_zero, 0, sizeof to.sin_zero);
-
- if (server_identifier.len)
- memcpy (&from, server_identifier.iabuf, 4);
- else
- memset (&from, 0, 4);
-
- /* If this was gatewayed, send it back to the gateway.
- Otherwise, broadcast it on the local network. */
- if (raw.giaddr.s_addr) {
- to.sin_addr = raw.giaddr;
- to.sin_port = server_port;
-
- if (outgoing.packet_length < BOOTP_MIN_LEN)
- outgoing.packet_length = BOOTP_MIN_LEN;
-
-#ifdef USE_FALLBACK
- result = send_fallback (&fallback_interface,
- packet, &raw, outgoing.packet_length,
- from, &to, &hto);
- if (result < 0)
- warn ("send_fallback: %m");
- return;
-#endif
- } else {
- to.sin_addr.s_addr = htonl (INADDR_BROADCAST);
- to.sin_port = packet->client_port;
- }
-
- errno = 0;
- result = send_packet (packet -> interface,
- packet, &raw, outgoing.packet_length,
- from, &to, (struct hardware *)0);
- if (result < 0)
- warn ("send_packet: %m");
-}
-
-void ack_lease (packet, lease, offer, when)
- struct packet *packet;
- struct lease *lease;
- unsigned char offer;
- TIME when;
-{
- struct lease lt;
- TIME lease_time;
- TIME offered_lease_time;
-
- int bufs = 0;
- struct packet outgoing;
- struct dhcp_packet raw;
- struct tree_cache *options [256];
- struct sockaddr_in to;
- struct in_addr from;
- struct hardware hto;
- int result;
-
- unsigned char lease_time_buf [4];
- unsigned char lease_t1_buf [4];
- unsigned char lease_t2_buf [4];
- struct tree_cache lease_time_tree;
- struct tree_cache lease_t1_tree;
- struct tree_cache lease_t2_tree;
- struct tree_cache dhcpoffer_tree;
- struct tree_cache server_id_tree;
- struct tree_cache vendor_class_tree;
- struct tree_cache user_class_tree;
- struct tree_cache hostname_tree;
- struct tree_cache netmask_tree;
-
- struct class *vendor_class, *user_class;
- char *filename;
- char *server_name;
- int i;
-
- if (packet -> options [DHO_DHCP_CLASS_IDENTIFIER].len) {
- vendor_class =
- find_class (0,
- packet ->
- options [DHO_DHCP_CLASS_IDENTIFIER].data,
- packet ->
- options [DHO_DHCP_CLASS_IDENTIFIER].len);
- } else {
- vendor_class = (struct class *)0;
- }
-
- if (packet -> options [DHO_DHCP_USER_CLASS_ID].len) {
- user_class =
- find_class (0,
- packet ->
- options [DHO_DHCP_USER_CLASS_ID].data,
- packet ->
- options [DHO_DHCP_USER_CLASS_ID].len);
- } else {
- user_class = (struct class *)0;
- }
-
- /* Choose a filename; first from the host_decl, if any, then from
- the user class, then from the vendor class. */
- if (lease -> host && lease -> host -> group -> filename)
- filename = lease -> host -> group -> filename;
- else if (user_class && user_class -> group -> filename)
- filename = user_class -> group -> filename;
- else if (vendor_class && vendor_class -> group -> filename)
- filename = vendor_class -> group -> filename;
- else filename = (char *)0;
-
- /* Choose a server name as above. */
- if (lease -> host && lease -> host -> group -> server_name)
- server_name = lease -> host -> group -> server_name;
- else if (user_class && user_class -> group -> server_name)
- server_name = user_class -> group -> server_name;
- else if (vendor_class && vendor_class -> group -> server_name)
- server_name = vendor_class -> group -> server_name;
- else server_name = (char *)0;
-
- /* At this point, we have a lease that we can offer the client.
- Now we construct a lease structure that contains what we want,
- and call supersede_lease to do the right thing with it. */
-
- memset (&lt, 0, sizeof lt);
-
- /* Use the ip address of the lease that we finally found in
- the database. */
- lt.ip_addr = lease -> ip_addr;
-
- /* Start now. */
- lt.starts = cur_time;
-
- /* Figure out how long a lease to assign. If this is a
- dynamic BOOTP lease, its duration must be infinite. */
- if (offer) {
- if (packet -> options [DHO_DHCP_LEASE_TIME].len == 4) {
- lease_time = getULong
- (packet -> options [DHO_DHCP_LEASE_TIME].data);
-
- /* Don't let the client ask for a longer lease than
- is supported for this subnet or host. */
- if (lease -> host &&
- lease -> host -> group -> max_lease_time) {
- if (lease_time >
- lease -> host -> group -> max_lease_time)
- lease_time = (lease -> host ->
- group -> max_lease_time);
- } else {
- if (lease_time >
- lease -> subnet -> group -> max_lease_time)
- lease_time = (lease -> subnet ->
- group -> max_lease_time);
- }
- } else {
- if (lease -> host
- && lease -> host -> group -> default_lease_time)
- lease_time = (lease -> host ->
- group -> default_lease_time);
- else
- lease_time = (lease -> subnet ->
- group -> default_lease_time);
- }
-
- lt.offered_expiry = cur_time + lease_time;
- if (when)
- lt.ends = when;
- else
- lt.ends = lt.offered_expiry;
- } else {
- if (lease -> host &&
- lease -> host -> group -> bootp_lease_length)
- lt.ends = (cur_time +
- lease -> host ->
- group -> bootp_lease_length);
- else if (lease -> subnet -> group -> bootp_lease_length)
- lt.ends = (cur_time +
- lease -> subnet ->
- group -> bootp_lease_length);
- else if (lease -> host &&
- lease -> host -> group -> bootp_lease_cutoff)
- lt.ends = lease -> host -> group -> bootp_lease_cutoff;
- else
- lt.ends = (lease -> subnet ->
- group -> bootp_lease_cutoff);
- lt.offered_expiry = lt.ends;
- lt.flags = BOOTP_LEASE;
- }
-
- lt.timestamp = cur_time;
-
- /* Record the uid, if given... */
- if (packet -> options [DHO_DHCP_CLIENT_IDENTIFIER].len) {
- lt.uid_len =
- packet -> options [DHO_DHCP_CLIENT_IDENTIFIER].len;
- lt.uid = packet -> options [DHO_DHCP_CLIENT_IDENTIFIER].data;
- packet -> options [DHO_DHCP_CLIENT_IDENTIFIER].data =
- (unsigned char *)0;
- packet -> options [DHO_DHCP_CLIENT_IDENTIFIER].len = 0;
- }
-
- /* Record the hardware address, if given... */
- lt.hardware_addr.hlen = packet -> raw -> hlen;
- lt.hardware_addr.htype = packet -> raw -> htype;
- memcpy (lt.hardware_addr.haddr, packet -> raw -> chaddr,
- packet -> raw -> hlen);
-
- lt.host = lease -> host;
- lt.subnet = lease -> subnet;
- lt.shared_network = lease -> shared_network;
-
- /* Record the transaction id... */
- lt.xid = packet -> raw -> xid;
-
- /* Don't call supersede_lease on a mocked-up lease. */
- if (lease -> flags & STATIC_LEASE)
- ;
- else
- /* Install the new information about this lease in the database.
- If this is a DHCPACK or a dynamic BOOTREPLY and we can't write
- the lease, don't ACK it (or BOOTREPLY it) either. */
- if (!(supersede_lease (lease, &lt, !offer || offer == DHCPACK)
- || (offer && offer != DHCPACK)))
- return;
-
- /* Send a response to the client... */
-
- memset (&outgoing, 0, sizeof outgoing);
- memset (&raw, 0, sizeof raw);
- outgoing.raw = &raw;
-
- /* Copy in the filename if given; otherwise, flag the filename
- buffer as available for options. */
- if (filename)
- strncpy (raw.file, filename, sizeof raw.file);
- else
- bufs |= 1;
-
- /* Copy in the server name if given; otherwise, flag the
- server_name buffer as available for options. */
- if (server_name)
- strncpy (raw.sname, server_name, sizeof raw.sname);
- else
- bufs |= 2; /* XXX */
-
- memcpy (raw.chaddr, packet -> raw -> chaddr, packet -> raw -> hlen);
- raw.hlen = packet -> raw -> hlen;
- raw.htype = packet -> raw -> htype;
-
- /* Start out with the subnet options... */
- memcpy (options, lease -> subnet -> group -> options, sizeof options);
-
- /* Vendor and user classes are only supported for DHCP clients. */
- if (offer) {
- /* If we have a vendor class, install those options,
- superseding any subnet options. */
- if (vendor_class) {
- for (i = 0; i < 256; i++)
- if (vendor_class -> group -> options [i])
- options [i] = (vendor_class -> group ->
- options [i]);
- }
-
- /* If we have a user class, install those options,
- superseding any subnet and vendor class options. */
- if (user_class) {
- for (i = 0; i < 256; i++)
- if (user_class -> group -> options [i])
- options [i] = (user_class -> group ->
- options [i]);
- }
-
- }
-
- /* If we have a host_decl structure, install the associated
- options, superseding anything that's in the way. */
- if (lease -> host) {
- for (i = 0; i < 256; i++)
- if (lease -> host -> group -> options [i])
- options [i] = (lease -> host ->
- group -> options [i]);
- }
-
- /* If we didn't get a hostname from an option somewhere, see if
- we can get one from the lease. */
- if (!options [DHO_HOST_NAME] && lease -> hostname) {
- options [DHO_HOST_NAME] = &hostname_tree;
- options [DHO_HOST_NAME] -> value =
- (unsigned char *)lease -> hostname;
- options [DHO_HOST_NAME] -> buf_size =
- options [DHO_HOST_NAME] -> len =
- strlen (lease -> hostname);
- options [DHO_HOST_NAME] -> timeout = 0xFFFFFFFF;
- options [DHO_HOST_NAME] -> tree = (struct tree *)0;
- }
-
- /* Now, if appropriate, put in DHCP-specific options that
- override those. */
- if (offer) {
- options [DHO_DHCP_MESSAGE_TYPE] = &dhcpoffer_tree;
- options [DHO_DHCP_MESSAGE_TYPE] -> value = &offer;
- options [DHO_DHCP_MESSAGE_TYPE] -> len = sizeof offer;
- options [DHO_DHCP_MESSAGE_TYPE] -> buf_size = sizeof offer;
- options [DHO_DHCP_MESSAGE_TYPE] -> timeout = 0xFFFFFFFF;
- options [DHO_DHCP_MESSAGE_TYPE] -> tree = (struct tree *)0;
-
- options [DHO_DHCP_SERVER_IDENTIFIER] = &server_id_tree;
- options [DHO_DHCP_SERVER_IDENTIFIER] ->
- value = server_identifier.iabuf;
- options [DHO_DHCP_SERVER_IDENTIFIER] ->
- len = server_identifier.len;
- options [DHO_DHCP_SERVER_IDENTIFIER] ->
- buf_size = server_identifier.len;
- options [DHO_DHCP_SERVER_IDENTIFIER] ->
- timeout = 0xFFFFFFFF;
- options [DHO_DHCP_SERVER_IDENTIFIER] ->
- tree = (struct tree *)0;
-
- /* Sanity check the lease time. */
- if ((lease->offered_expiry - cur_time) < 15)
- offered_lease_time = (lease -> subnet ->
- group -> default_lease_time);
- else if (lease -> offered_expiry - cur_time >
- lease -> subnet -> group -> max_lease_time)
- offered_lease_time = (lease -> subnet ->
- group -> max_lease_time);
- else
- offered_lease_time =
- lease -> offered_expiry - cur_time;
-
- putULong (lease_time_buf, offered_lease_time);
- options [DHO_DHCP_LEASE_TIME] = &lease_time_tree;
- options [DHO_DHCP_LEASE_TIME] -> value = lease_time_buf;
- options [DHO_DHCP_LEASE_TIME] -> len = sizeof lease_time_buf;
- options [DHO_DHCP_LEASE_TIME] ->
- buf_size = sizeof lease_time_buf;
- options [DHO_DHCP_LEASE_TIME] -> timeout = 0xFFFFFFFF;
- options [DHO_DHCP_LEASE_TIME] -> tree = (struct tree *)0;
-
- /* Renewal time is lease time * 0.5. */
- offered_lease_time /= 2;
- putULong (lease_t1_buf, offered_lease_time);
- options [DHO_DHCP_RENEWAL_TIME] = &lease_t1_tree;
- options [DHO_DHCP_RENEWAL_TIME] -> value = lease_t1_buf;
- options [DHO_DHCP_RENEWAL_TIME] -> len = sizeof lease_t1_buf;
- options [DHO_DHCP_RENEWAL_TIME] ->
- buf_size = sizeof lease_t1_buf;
- options [DHO_DHCP_RENEWAL_TIME] -> timeout = 0xFFFFFFFF;
- options [DHO_DHCP_RENEWAL_TIME] -> tree = (struct tree *)0;
-
- /* Rebinding time is lease time * 0.875. */
- offered_lease_time += (offered_lease_time / 2
- + offered_lease_time / 4);
- putULong (lease_t2_buf, offered_lease_time);
- options [DHO_DHCP_REBINDING_TIME] = &lease_t2_tree;
- options [DHO_DHCP_REBINDING_TIME] -> value = lease_t2_buf;
- options [DHO_DHCP_REBINDING_TIME] -> len = sizeof lease_t2_buf;
- options [DHO_DHCP_REBINDING_TIME] ->
- buf_size = sizeof lease_t2_buf;
- options [DHO_DHCP_REBINDING_TIME] -> timeout = 0xFFFFFFFF;
- options [DHO_DHCP_REBINDING_TIME] -> tree = (struct tree *)0;
-
- /* If we used the vendor class the client specified, we
- have to return it. */
- if (vendor_class) {
- options [DHO_DHCP_CLASS_IDENTIFIER] =
- &vendor_class_tree;
- options [DHO_DHCP_CLASS_IDENTIFIER] ->
- value = (unsigned char *)vendor_class -> name;
- options [DHO_DHCP_CLASS_IDENTIFIER] ->
- len = strlen (vendor_class -> name);
- options [DHO_DHCP_CLASS_IDENTIFIER] ->
- buf_size = strlen (vendor_class -> name);
- options [DHO_DHCP_CLASS_IDENTIFIER] ->
- timeout = 0xFFFFFFFF;
- options [DHO_DHCP_CLASS_IDENTIFIER] ->
- tree = (struct tree *)0;
- }
-
- /* If we used the user class the client specified, we
- have to return it. */
- if (user_class) {
- options [DHO_DHCP_USER_CLASS_ID] = &user_class_tree;
- options [DHO_DHCP_USER_CLASS_ID] ->
- value = (unsigned char *)user_class -> name;
- options [DHO_DHCP_USER_CLASS_ID] ->
- len = strlen (user_class -> name);
- options [DHO_DHCP_USER_CLASS_ID] ->
- buf_size = strlen (user_class -> name);
- options [DHO_DHCP_USER_CLASS_ID] ->
- timeout = 0xFFFFFFFF;
- options [DHO_DHCP_USER_CLASS_ID] ->
- tree = (struct tree *)0;
- }
- }
-
- /* Use the subnet mask from the subnet declaration if no other
- mask has been provided. */
- if (!options [DHO_SUBNET_MASK]) {
- options [DHO_SUBNET_MASK] = &netmask_tree;
- netmask_tree.value = lease -> subnet -> netmask.iabuf;
- netmask_tree.len = lease -> subnet -> netmask.len;
- netmask_tree.buf_size = lease -> subnet -> netmask.len;
- netmask_tree.timeout = 0xFFFFFFFF;
- netmask_tree.tree = (struct tree *)0;
- }
-
- /* See if this is a Microsoft client that NUL-terminates its
- strings and expects us to do likewise... */
- if (packet -> options [DHO_HOST_NAME].data &&
- packet -> options [DHO_HOST_NAME].data
- [packet -> options [DHO_HOST_NAME].len - 1] == '\0')
- cons_options (packet, &outgoing, options, bufs, 1);
- else
- cons_options (packet, &outgoing, options, bufs, 0);
- if (!offer && outgoing.packet_length < BOOTP_MIN_LEN)
- outgoing.packet_length = BOOTP_MIN_LEN;
-
- raw.ciaddr = packet -> raw -> ciaddr;
- memcpy (&raw.yiaddr, lease -> ip_addr.iabuf, 4);
-
- /* Figure out the address of the next server. */
- if (lease -> host && lease -> host -> group -> next_server.len)
- memcpy (&raw.siaddr,
- lease -> host -> group -> next_server.iabuf, 4);
- else if (lease -> subnet -> group -> next_server.len)
- memcpy (&raw.siaddr,
- lease -> subnet -> group -> next_server.iabuf, 4);
- else if (lease -> subnet -> interface_address.len)
- memcpy (&raw.siaddr,
- lease -> subnet -> interface_address.iabuf, 4);
- else
- memcpy (&raw.siaddr, server_identifier.iabuf, 4);
-
- raw.giaddr = packet -> raw -> giaddr;
-
- raw.xid = packet -> raw -> xid;
- raw.secs = packet -> raw -> secs;
- raw.flags = packet -> raw -> flags;
- raw.hops = packet -> raw -> hops;
- raw.op = BOOTREPLY;
-
- /* Say what we're doing... */
- note ("%s on %s to %s via %s",
- (offer
- ? (offer == DHCPACK ? "DHCPACK" : "DHCPOFFER")
- : "BOOTREPLY"),
- piaddr (lease -> ip_addr),
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr),
- packet -> raw -> giaddr.s_addr
- ? inet_ntoa (packet -> raw -> giaddr)
- : packet -> interface -> name);
-
- /* Set up the hardware address... */
- hto.htype = packet -> raw -> htype;
- hto.hlen = packet -> raw -> hlen;
- memcpy (hto.haddr, packet -> raw -> chaddr, hto.hlen);
-
- to.sin_family = AF_INET;
-#ifdef HAVE_SA_LEN
- to.sin_len = sizeof to;
-#endif
- memset (to.sin_zero, 0, sizeof to.sin_zero);
-
- if (server_identifier.len)
- memcpy (&from, server_identifier.iabuf, 4);
- else
- memset (&from, 0, 4);
-
-#ifdef DEBUG_PACKET
- dump_packet (packet);
- dump_raw ((unsigned char *)packet -> raw, packet -> packet_length);
- dump_packet (&outgoing);
- dump_raw ((unsigned char *)&raw, outgoing.packet_length);
-#endif
-
- /* If this was gatewayed, send it back to the gateway... */
- if (raw.giaddr.s_addr) {
- to.sin_addr = raw.giaddr;
- to.sin_port = server_port;
-
- if (outgoing.packet_length < BOOTP_MIN_LEN)
- outgoing.packet_length = BOOTP_MIN_LEN;
-
-#ifdef USE_FALLBACK
- result = send_fallback (&fallback_interface,
- packet, &raw, outgoing.packet_length,
- raw.siaddr, &to, &hto);
- if (result < 0)
- warn ("send_fallback: %m");
- return;
-#endif
-
- /* If it comes from a client who already knows its address and
- is not requesting a broadcast response, sent it directly to
- that client. */
- } else if (raw.ciaddr.s_addr && offer == DHCPACK &&
- !(raw.flags & BOOTP_BROADCAST)) {
- to.sin_addr = packet -> raw -> ciaddr;
- to.sin_port = htons (ntohs (server_port) + 1); /* XXX */
-
-#ifdef USE_FALLBACK
- result = send_fallback (&fallback_interface,
- packet, &raw, outgoing.packet_length,
- raw.siaddr, &to, &hto);
- if (result < 0)
- warn ("send_fallback: %m");
- return;
-#endif
-
- /* Otherwise, broadcast it on the local network. */
- } else {
- to.sin_addr.s_addr = htonl (INADDR_BROADCAST);
- to.sin_port = htons (ntohs (server_port) + 1); /* XXX */
- }
-
-
- result = send_packet (packet -> interface,
- packet, &raw, outgoing.packet_length,
- raw.siaddr, &to, &hto);
- if (result < 0)
- warn ("sendpkt: %m");
-}
-
-struct lease *find_lease (packet, share)
- struct packet *packet;
- struct shared_network *share;
-{
- struct lease *uid_lease, *ip_lease, *hw_lease;
- struct lease *lease = (struct lease *)0;
- struct iaddr cip;
- struct host_decl *hp, *host = (struct host_decl *)0;
- struct lease *fixed_lease;
-
- /* Try to find a host or lease that's been assigned to the
- specified unique client identifier. */
- if (packet -> options [DHO_DHCP_CLIENT_IDENTIFIER].len) {
- /* First, try to find a fixed host entry for the specified
- client identifier... */
- hp = find_hosts_by_uid (packet -> options
- [DHO_DHCP_CLIENT_IDENTIFIER].data,
- packet -> options
- [DHO_DHCP_CLIENT_IDENTIFIER].len);
- if (hp) {
- host = hp;
- fixed_lease = mockup_lease (packet, share, hp);
- uid_lease = (struct lease *)0;
- } else {
- uid_lease = find_lease_by_uid
- (packet -> options
- [DHO_DHCP_CLIENT_IDENTIFIER].data,
- packet -> options
- [DHO_DHCP_CLIENT_IDENTIFIER].len);
- /* Find the lease matching this uid that's on the
- network the packet came from (if any). */
- for (; uid_lease; uid_lease = uid_lease -> n_uid)
- if (uid_lease -> shared_network == share)
- break;
- fixed_lease = (struct lease *)0;
- }
- } else {
- uid_lease = (struct lease *)0;
- fixed_lease = (struct lease *)0;
- }
-
- /* If we didn't find a fixed lease using the uid, try doing
- it with the hardware address... */
- if (!fixed_lease) {
- hp = find_hosts_by_haddr (packet -> raw -> htype,
- packet -> raw -> chaddr,
- packet -> raw -> hlen);
- if (hp) {
- host = hp; /* Save it for later. */
- fixed_lease = mockup_lease (packet, share, hp);
- }
- }
-
- /* Try to find a lease that's been attached to the client's
- hardware address... */
- hw_lease = find_lease_by_hw_addr (packet -> raw -> chaddr,
- packet -> raw -> hlen);
- /* Find the lease that's on the network the packet came from
- (if any). */
- for (; hw_lease; hw_lease = hw_lease -> n_hw)
- if (hw_lease -> shared_network == share)
- break;
-
- /* Try to find a lease that's been allocated to the client's
- IP address. */
- if (packet -> options [DHO_DHCP_REQUESTED_ADDRESS].len &&
- packet -> options [DHO_DHCP_REQUESTED_ADDRESS].len == 4) {
- cip.len = 4;
- memcpy (cip.iabuf,
- packet -> options [DHO_DHCP_REQUESTED_ADDRESS].data,
- cip.len);
- ip_lease = find_lease_by_ip_addr (cip);
- } else if (packet -> raw -> ciaddr.s_addr) {
- cip.len = 4;
- memcpy (cip.iabuf, &packet -> raw -> ciaddr, 4);
- ip_lease = find_lease_by_ip_addr (cip);
- } else
- ip_lease = (struct lease *)0;
-
- /* If the requested IP address isn't on the network the packet
- came from, don't use it (this is probably taken care of at
- a higher level, but it's cheap to make sure here too). */
- if (ip_lease && ip_lease -> shared_network != share)
- ip_lease = (struct lease *)0;
-
- /* Toss ip_lease if it hasn't yet expired and the uid doesn't
- match */
- if (ip_lease &&
- ip_lease -> ends >= cur_time &&
- ip_lease -> uid && ip_lease != uid_lease)
- ip_lease = (struct lease *)0;
-
- /* Toss hw_lease if it hasn't yet expired and the uid doesn't
- match, except that if the hardware address matches and the
- client is now doing dynamic BOOTP (and thus hasn't provided
- a uid) we let the client get away with it. */
- if (hw_lease &&
- hw_lease -> ends >= cur_time &&
- hw_lease -> uid && hw_lease != uid_lease &&
- (packet -> packet_type != 0 ||
- !(hw_lease -> flags & DYNAMIC_BOOTP_OK)))
- hw_lease = (struct lease *)0;
-
- /* Toss extra pointers to the same lease... */
- if (ip_lease == hw_lease)
- ip_lease = (struct lease *)0;
- if (hw_lease == uid_lease)
- hw_lease = (struct lease *)0;
- if (ip_lease == uid_lease)
- ip_lease = (struct lease *)0;
-
- /* If we got an ip address lease, make sure it isn't assigned to
- some *other* client! If it was assigned to this client, we'd
- have zeroed it out above, so the only way we can take it at this
- point is if some other client had it but it's timed out, or if no
- other client has ever had it. */
- if (ip_lease &&
- ip_lease -> ends >= cur_time)
- ip_lease = (struct lease *)0;
-
- /* If we've already eliminated the lease, it wasn't there to
- begin with. If we have come up with a matching lease,
- set the message to bad network in case we have to throw it out. */
- if (!ip_lease && !hw_lease && !uid_lease) {
- strcpy (dhcp_message, "requested address not available");
- } else {
- strcpy (dhcp_message, "requested address on bad subnet");
- }
-
- /* Now eliminate leases that are on the wrong network... */
- if (ip_lease &&
- (share != ip_lease -> shared_network)) {
- release_lease (ip_lease);
- ip_lease = (struct lease *)0;
- }
- if (uid_lease &&
- (share != uid_lease -> shared_network)) {
- release_lease (uid_lease);
- uid_lease = (struct lease *)0;
- }
- if (hw_lease &&
- (share != hw_lease -> shared_network)) {
- release_lease (hw_lease);
- hw_lease = (struct lease *)0;
- }
-
- /* At this point, if fixed_lease is nonzero, we can assign it to
- this client. */
- if (fixed_lease) {
- lease = fixed_lease;
- }
-
- /* If we got a lease that matched the ip address and don't have
- a better offer, use that; otherwise, release it. */
- if (ip_lease) {
- if (lease) {
- release_lease (ip_lease);
- } else {
- lease = ip_lease;
- lease -> host = (struct host_decl *)0;
- }
- }
-
- /* If we got a lease that matched the client identifier, we may want
- to use it, but if we already have a lease we like, we must free
- the lease that matched the client identifier. */
- if (uid_lease) {
- if (lease) {
- release_lease (uid_lease);
- } else {
- lease = uid_lease;
- lease -> host = (struct host_decl *)0;
- }
- }
-
- /* The lease that matched the hardware address is treated likewise. */
- if (hw_lease) {
- if (lease) {
- release_lease (hw_lease);
- } else {
- lease = hw_lease;
- lease -> host = (struct host_decl *)0;
- }
- }
-
- /* If we found a host_decl but no matching address, try to
- find a host_decl that has no address, and if there is one,
- hang it off the lease so that we can use the supplied
- options. */
- if (lease && host && !lease -> host) {
- for (; host; host = host -> n_ipaddr) {
- if (!host -> fixed_addr) {
- lease -> host = host;
- break;
- }
- }
- }
-
- return lease;
-}
-
-/* Search the provided host_decl structure list for an address that's on
- the specified shared network. If one is found, mock up and return a
- lease structure for it; otherwise return the null pointer. */
-
-struct lease *mockup_lease (packet, share, hp)
- struct packet *packet;
- struct shared_network *share;
- struct host_decl *hp;
-{
- static struct lease mock;
-
- mock.subnet = find_host_for_network (&hp, &mock.ip_addr, share);
- if (!mock.subnet)
- return (struct lease *)0;
- mock.next = mock.prev = (struct lease *)0;
- mock.shared_network = mock.subnet -> shared_network;
- mock.host = hp;
-
- if (hp -> group -> options [DHO_DHCP_CLIENT_IDENTIFIER]) {
- mock.uid = hp -> group ->
- options [DHO_DHCP_CLIENT_IDENTIFIER] -> value;
- mock.uid_len = hp -> group ->
- options [DHO_DHCP_CLIENT_IDENTIFIER] -> len;
- } else {
- mock.uid = (unsigned char *)0;
- mock.uid_len = 0;
- }
-
- mock.hardware_addr = hp -> interface;
- mock.starts = mock.timestamp = mock.ends = MIN_TIME;
- mock.flags = STATIC_LEASE;
- return &mock;
-}
diff --git a/server/dhcpd.8 b/server/dhcpd.8
deleted file mode 100644
index c0f9aa9a..00000000
--- a/server/dhcpd.8
+++ /dev/null
@@ -1,308 +0,0 @@
-.\" dhcpd.8
-.\"
-.\" Copyright (c) 1995, 1996 The Internet Software Consortium.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\"
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of The Internet Software Consortium nor the names
-.\" of its contributors may be used to endorse or promote products derived
-.\" from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
-.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-.\" DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
-.\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" This software has been written for the Internet Software Consortium
-.\" by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
-.\" Enterprises. To learn more about the Internet Software Consortium,
-.\" see ``http://www.isc.org/isc''. To learn more about Vixie
-.\" Enterprises, see ``http://www.vix.com''.
-.TH dhcpd 8
-.SH NAME
-dhcpd - Dynamic Host Configuration Protocol Server
-.SH SYNOPSIS
-.B dhcpd
-[
-.B -p
-.I port
-]
-[
-.B -f
-]
-[
-.B -d
-]
-[
-.B -cf
-.I config-file
-]
-[
-.B -lf
-.I lease-file
-]
-[
-.I if0
-[
-.I ...ifN
-]
-]
-.SH DESCRIPTION
-The Internet Software Consortium DHCP Server, dhcpd, implements the
-Dynamic Host Configuration Protocol (DHCP) and the Internet Bootstrap
-Protocol (BOOTP). DHCP allows hosts on a TCP/IP network to request
-and be assigned IP addresses, and also to discover information about
-the network to which they are attached. BOOTP provides similar
-functionality, with certain restrictions.
-.SH OPERATION
-.PP
-The DHCP protocol allows a host which is unknown to the network
-administrator to be automatically assigned a new IP address out of a
-pool of IP addresses for its network. In order for this to work, the
-network administrator allocates address pools in each subnet and
-enters them into the dhcpd.conf(5) file.
-.PP
-On startup, dhcpd reads the
-.IR dhcpd.conf
-file and stores a list of available addresses on each subnet in
-memory. When a client requests an address using the DHCP protocol,
-dhcpd allocates an address for it. Each client is assigned a lease,
-which expires after an amount of time chosen by the administrator (by
-default, one day). Before leases expire, the clients to which leases
-are assigned are expected to renew them in order to continue to use
-the addresses. Once a lease has expired, the client to which that
-lease was assigned is no longer permitted to use the leased IP
-address.
-.PP
-In order to keep track of leases across system reboots and server
-restarts, dhcpd keeps a list of leases it has assigned in the
-dhcpd.leases(5) file. Before dhcpd grants a lease to a host, it
-records the lease in this file and makes sure that the contents of the
-file are flushed to disk. This ensures that even in the event of a
-system crash, dhcpd will not forget about a lease that it has
-assigned. On startup, after reading the dhcpd.conf file, dhcpd
-reads the dhcpd.leases file to refresh its memory about what leases
-have been assigned.
-.PP
-New leases are appended to the end of the dhcpd.leases
-file. In order to prevent the file from becoming arbitrarily large,
-from time to time dhcpd creates a new dhcpd.leases file from its
-in-core lease database. Once this file has been written to disk, the
-old file is renamed
-.IR dhcpd.leases~ ,
-and the new file is renamed dhcpd.leases. If the system crashes in
-the middle of this process, whichever dhcpd.leases file remains will
-contain all the lease information, so there is no need for a special
-crash recovery process.
-.PP
-BOOTP support is also provided by this server. Unlike DHCP, the BOOTP
-protocol does not provide a protocol for recovering
-dynamically-assigned addresses once they are no longer needed. It is
-still possible to dynamically assign addresses to BOOTP clients, but
-some administrative process for reclaiming addresses is required. By
-default, leases are granted to BOOTP clients in perpetuity, although
-the network administrator may set an earlier cutoff date or a shorter
-lease length for BOOTP leases if that makes sense.
-.PP
-BOOTP clients may also be served in the old standard way, which is to
-simply provide a declaration in the dhcpd.conf file for each
-BOOTP client, permanently assigning an address to each client.
-.PP
-Whenever changes are made to the dhcpd.conf file, dhcpd must be
-restarted. To restart dhcpd, send a SIGTERM (signal 15) to the
-process ID contained in
-.IR RUNDIR/dhcpd.pid ,
-and then re-invoke dhcpd. Because the DHCP server database is not as
-lightweight as a BOOTP database, dhcpd does not automatically restart
-itself when it sees a change to the dhcpd.conf file.
-.SH COMMAND LINE
-.PP
-The names of the network interfaces on which dhcpd should listen for
-broadcasts may be specified on the command line. This should be done
-on systems where dhcpd is unable to identify non-broadcast interfaces,
-but should not be required on other systems. If no interface names
-are specified on the command line dhcpd will identify all network
-interfaces which are up, elimininating non-broadcast interfaces if
-possible, and listen for DHCP broadcasts on each interface.
-.PP
-If dhcpd should listen on a port other than the standard (port 67),
-the
-.B -p
-flag may used. It should be followed by the udp port number on which
-dhcpd should listen. This is mostly useful for debugging purposes.
-.PP
-To run dhcpd as a foreground process, rather than allowing it to run
-as a daemon in the background, the
-.B -f
-flag should be specified. This is useful when running dhcpd under a
-debugger, or when running it out of inittab on System V systems.
-.PP
-To have dhcpd log to the standard error descriptor, specify the
-.B -d
-flag. This can be useful for debugging, and also at sites where a
-complete log of all dhcp activity must be kept but syslogd is not
-reliable or otherwise cannot be used. Normally, dhcpd will log all
-output using the syslog(3) function with the log facility set to
-LOG_DAEMON.
-.PP
-Dhcpd can be made to use an alternate configuration file with the
-.B -cf
-flag, or an alternate lease file with the
-.B -lf
-flag. Because of the importance of using the same lease database at
-all times when running dhcpd in production, these options should be
-used \fBonly\fR for testing lease files or database files in a
-non-production environment.
-.SH CONFIGURATION
-The syntax of the dhcpd.conf(8) file is discussed seperately. This
-section should be used as an overview of the configuration process,
-and the dhcpd.conf(8) documentation should be consulted for detailed
-reference information.
-.PP
-.SH Subnets
-dhcpd needs to know the subnet numbers and netmasks of all subnets for
-which it will be providing service. In addition, in order to
-dynamically allocate addresses, it must be assigned one or more ranges
-of addresses on each subnet which it can in turn assign to client
-hosts as they boot. Thus, a very simple configuration providing DHCP
-support might look like this:
-.nf
-.sp 1
- subnet 239.252.197.0 netmask 255.255.255.0 {
- range 239.252.197.10 239.252.197.250;
- }
-.fi
-.PP
-Multiple address ranges may be specified like this:
-.nf
-.sp 1
- subnet 239.252.197.0 netmask 255.255.255.0 {
- range 239.252.197.10 239.252.197.107;
- range 239.252.197.113 239.252.197.250;
- }
-.fi
-.PP
-If a subnet will only be provided with BOOTP service and no dynamic
-address assignment, the range clause can be left out entirely, but the
-subnet statement must appear.
-.PP
-.SH Lease Lengths
-DHCP leases can be assigned almost any length from zero seconds to
-infinity. What lease length makes sense for any given subnet, or for
-any given installation, will vary depending on the kinds of hosts
-being served.
-.PP
-For example, in an office environment where systems are added from
-time to time and removed from time to time, but move relatively
-infrequently, it might make sense to allow lease times of a month of
-more. In a final test environment on a manufacturing floor, it may
-make more sense to assign a maximum lease length of 30 minutes -
-enough time to go through a simple test procedure on a network
-appliance before packaging it up for delivery.
-.PP
-It is possible to specify two lease lengths: the default length that
-will be assigned if a client doesn't ask for any particular lease
-length, and a maximum lease length. These are specified as clauses
-to the subnet command:
-.nf
-.sp 1
- subnet 239.252.197.0 netmask 255.255.255.0 {
- range 239.252.197.10 239.252.197.107;
- default-lease-time 600;
- max-lease-time 7200;
- |
-.fi
-.PP
-This particular subnet declaration specifies a default lease time of
-600 seconds (ten minutes), and a maximum lease time of 7200 seconds
-(two hours). Other common values would be 86400 (one day), 604800
-(one week) and 2592000 (30 days).
-.PP
-Each subnet need not have the same lease\(emin the case of an office
-environment and a manufacturing environment served by the same DHCP
-server, it might make sense to have widely disparate values for
-default and maximum lease times on each subnet.
-.SH BOOTP Support
-Each BOOTP client must be explicitly declared in the dhcpd.conf
-file. A very basic client declaration will specify the client
-network interface's hardware address and the IP address to assign to
-that client. If the client needs to be able to load a boot file from
-the server, that file's name must be specified. A simple bootp
-client declaration might look like this:
-.nf
-.sp 1
- host haagen {
- hardware ethernet 08:00:2b:4c:59:23;
- fixed-address 239.252.197.9;
- filename "/tftpboot/haagen.boot";
- }
-.fi
-.SH Options
-DHCP (and also BOOTP with Vendor Extensions) provide a mechanism
-whereby the server can provide the client with information about how
-to configure its network interface (e.g., subnet mask), and also how
-the client can access various network services (e.g., DNS, IP routers,
-and so on).
-.PP
-These options can be specified on a per-subnet basis, and, for BOOTP
-clients, also on a per-client basis. In the event that a BOOTP
-client declaration specifies options that are also specified in its
-subnet declaration, the options specified in the client declaration
-take precedence. An reasonably complete DHCP configuration might
-look something like this:
-.nf
-.sp 1
- subnet 239.252.197.0 netmask 255.255.255.0 {
- range 239.252.197.10 239.252.197.250;
- default-lease-time 600 max-lease-time 7200;
- option subnet-mask 255.255.255.0;
- option broadcast-address 239.252.197.255;
- option routers 239.252.197.1;
- option domain-name-servers 239.252.197.2, 239.252.197.3;
- option domain-name "isc.org";
- }
-.fi
-.PP
-A bootp host on that subnet that needs to be in a different domain and
-use a different name server might be declared as follows:
-.nf
-.sp 1
- host haagen hardware ethernet 08:00:2b:4c:59:23 {
- fixed-address 239.252.197.9;
- filename "/tftpboot/haagen.boot";
- option domain-name-servers 192.5.5.1;
- option domain-name "vix.com";
- }
-.fi
-.PP
-A more complete description of the dhcpd.conf file syntax is provided
-in dhcpd.conf(5).
-.SH FILES
-.B ETCDIR/dhcpd.conf, DBDIR/dhcpd.leases, RUNDIR/dhcpd.pid,
-.B DBDIR/dhcpd.leases~.
-.SH SEE ALSO
-dhcpd.conf(5), dhcpd.leases(5)
-.SH AUTHOR
-.B dhcpd(8)
-was written by Ted Lemon <mellon@vix.com>
-under a contract with Vixie Labs. Funding
-for this project was provided by the Internet Software Corporation.
-Information about the Internet Software Consortium can be found at
-.B http://www.isc.org/isc.
diff --git a/server/dhcpd.c b/server/dhcpd.c
deleted file mode 100644
index b46b74bb..00000000
--- a/server/dhcpd.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/* dhcpd.c
-
- DHCP Server Daemon. */
-
-/*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software has been written for the Internet Software Consortium
- * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
- * Enterprises. To learn more about the Internet Software Consortium,
- * see ``http://www.vix.com/isc''. To learn more about Vixie
- * Enterprises, see ``http://www.vix.com''.
- */
-
-#ifndef lint
-static char ocopyright[] =
-"$Id: dhcpd.c,v 1.36 1996/09/12 09:28:13 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
-#endif
-
-static char copyright[] =
-"Copyright 1995, 1996 The Internet Software Consortium.";
-static char arr [] = "All rights reserved.";
-static char message [] = "Internet Software Consortium DHCPD $Name: $";
-
-#include "dhcpd.h"
-
-static void usage PROTO ((void));
-
-TIME cur_time;
-struct group root_group;
-
-struct iaddr server_identifier;
-int server_identifier_matched;
-
-#ifdef USE_FALLBACK
-struct interface_info fallback_interface;
-#endif
-
-u_int16_t server_port;
-int log_priority;
-#ifdef DEBUG
-int log_perror = -1;
-#else
-int log_perror = 1;
-#endif
-
-char *path_dhcpd_conf = _PATH_DHCPD_CONF;
-char *path_dhcpd_db = _PATH_DHCPD_DB;
-char *path_dhcpd_pid = _PATH_DHCPD_PID;
-
-int main (argc, argv, envp)
- int argc;
- char **argv, **envp;
-{
- int i, status;
- struct servent *ent;
- char *s;
-#ifndef DEBUG
- int pidfilewritten = 0;
- int pid;
- char pbuf [20];
- int daemon = 1;
-#endif
-
- /* Initially, log errors to stderr as well as to syslogd. */
-#ifdef SYSLOG_4_2
- openlog ("dhcpd", LOG_NDELAY);
- log_priority = DHCPD_LOG_FACILITY;
-#else
- openlog ("dhcpd", LOG_NDELAY, DHCPD_LOG_FACILITY);
-#endif
-
-#ifndef DEBUG
-#ifndef SYSLOG_4_2
- setlogmask (LOG_UPTO (LOG_INFO));
-#endif
-#endif
- note (message);
- note (copyright);
- note (arr);
-
- for (i = 1; i < argc; i++) {
- if (!strcmp (argv [i], "-p")) {
- if (++i == argc)
- usage ();
- for (s = argv [i]; *s; s++)
- if (!isdigit (*s))
- error ("%s: not a valid UDP port",
- argv [i]);
- status = atoi (argv [i]);
- if (status < 1 || status > 65535)
- error ("%s: not a valid UDP port",
- argv [i]);
- server_port = htons (status);
- debug ("binding to user-specified port %d",
- ntohs (server_port));
- } else if (!strcmp (argv [i], "-f")) {
-#ifndef DEBUG
- daemon = 0;
-#endif
- } else if (!strcmp (argv [i], "-d")) {
-#ifndef DEBUG
- daemon = 0;
-#endif
- log_perror = -1;
- } else if (!strcmp (argv [i], "-cf")) {
- if (++i == argc)
- usage ();
- path_dhcpd_conf = argv [i];
- } else if (!strcmp (argv [i], "-lf")) {
- if (++i == argc)
- usage ();
- path_dhcpd_db = argv [i];
- } else if (argv [i][0] == '-') {
- usage ();
- } else {
- struct interface_info *tmp =
- ((struct interface_info *)
- dmalloc (sizeof *tmp, "get_interface_list"));
- if (!tmp)
- error ("Insufficient memory to %s %s",
- "record interface", argv [i]);
- memset (tmp, 0, sizeof *tmp);
- strcpy (tmp -> name, argv [i]);
- tmp -> next = interfaces;
- tmp -> flags = INTERFACE_REQUESTED;
- interfaces = tmp;
- }
- }
-
- /* If we were requested to log to stdout on the command line,
- keep doing so; otherwise, stop. */
- if (log_perror == -1)
- log_perror = 1;
- else
- log_perror = 0;
-
-#ifndef DEBUG
- if (daemon) {
- /* Become a daemon... */
- if ((pid = fork ()) < 0)
- error ("Can't fork daemon: %m");
- else if (pid)
- exit (0);
- /* Become session leader and get pid... */
- close (0);
- close (1);
- close (2);
- pid = setsid ();
- }
-
- /* Read previous pid file. */
- if ((i = open (path_dhcpd_pid, O_RDONLY)) >= 0) {
- status = read (i, pbuf, (sizeof pbuf) - 1);
- close (i);
- pbuf [status] = 0;
- pid = atoi (pbuf);
-
- /* If the previous server process is not still running,
- write a new pid file immediately. */
- if (pid && kill (pid, 0) < 0) {
- unlink (path_dhcpd_pid);
- if ((i = open (path_dhcpd_pid,
- O_WRONLY | O_CREAT, 0640)) >= 0) {
- sprintf (pbuf, "%d\n", (int)getpid ());
- write (i, pbuf, strlen (pbuf));
- close (i);
- pidfilewritten = 1;
- }
- }
- }
-#endif /* !DEBUG */
-
- /* Default to the DHCP/BOOTP port. */
- if (!server_port)
- {
- ent = getservbyname ("dhcp", "udp");
- if (!ent)
- server_port = htons (67);
- else
- server_port = ent -> s_port;
- endservent ();
- }
-
- /* Get the current time... */
- GET_TIME (&cur_time);
-
- /* Read the dhcpd.conf file... */
- if (!readconf ())
- error ("Configuration file errors encountered -- exiting");
-
- /* Start up the database... */
- db_startup ();
-
- /* Discover all the network interfaces and initialize them. */
- discover_interfaces (1);
-
-#ifndef DEBUG
- /* If we didn't write the pid file earlier because we found a
- process running the logged pid, but we made it to here,
- meaning nothing is listening on the bootp port, then write
- the pid file out - what's in it now is bogus anyway. */
- if (!pidfilewritten) {
- unlink (path_dhcpd_pid);
- if ((i = open (path_dhcpd_pid,
- O_WRONLY | O_CREAT, 0640)) >= 0) {
- sprintf (pbuf, "%d\n", (int)getpid ());
- write (i, pbuf, strlen (pbuf));
- close (i);
- pidfilewritten = 1;
- }
- }
-#endif /* !DEBUG */
-
- /* Receive packets and dispatch them... */
- dispatch ();
-
- /* Not reached */
- return 0;
-}
-
-/* Print usage message. */
-
-static void usage ()
-{
- error ("Usage: dhcpd [-p <UDP port #>] [-d] [-f] [-cf config-file]%s",
- "\n [-lf lease-file] [if0 [...ifN]]");
-}
-
-void cleanup ()
-{
-}
diff --git a/server/dhcpd.cat8 b/server/dhcpd.cat8
deleted file mode 100644
index d046e509..00000000
--- a/server/dhcpd.cat8
+++ /dev/null
@@ -1,330 +0,0 @@
-
-
-
-dhcpd(8) dhcpd(8)
-
-
-NNAAMMEE
- dhcpd - Dynamic Host Configuration Protocol Server
-
-SSYYNNOOPPSSIISS
- ddhhccppdd [ --pp _p_o_r_t ] [ --ff ] [ --dd ] [ --ccff _c_o_n_f_i_g_-_f_i_l_e ] [ --llff
- _l_e_a_s_e_-_f_i_l_e ] [ _i_f_0 [ _._._._i_f_N ] ]
-
-DDEESSCCRRIIPPTTIIOONN
- The Internet Software Consortium DHCP Server, dhcpd,
- implements the Dynamic Host Configuration Protocol (DHCP)
- and the Internet Bootstrap Protocol (BOOTP). DHCP allows
- hosts on a TCP/IP network to request and be assigned IP
- addresses, and also to discover information about the net-
- work to which they are attached. BOOTP provides similar
- functionality, with certain restrictions.
-
-OOPPEERRAATTIIOONN
- The DHCP protocol allows a host which is unknown to the
- network administrator to be automatically assigned a new
- IP address out of a pool of IP addresses for its network.
- In order for this to work, the network administrator allo-
- cates address pools in each subnet and enters them into
- the dhcpd.conf(5) file.
-
- On startup, dhcpd reads the _d_h_c_p_d_._c_o_n_f file and stores a
- list of available addresses on each subnet in memory.
- When a client requests an address using the DHCP protocol,
- dhcpd allocates an address for it. Each client is
- assigned a lease, which expires after an amount of time
- chosen by the administrator (by default, one day). Before
- leases expire, the clients to which leases are assigned
- are expected to renew them in order to continue to use the
- addresses. Once a lease has expired, the client to which
- that lease was assigned is no longer permitted to use the
- leased IP address.
-
- In order to keep track of leases across system reboots and
- server restarts, dhcpd keeps a list of leases it has
- assigned in the dhcpd.leases(5) file. Before dhcpd
- grants a lease to a host, it records the lease in this
- file and makes sure that the contents of the file are
- flushed to disk. This ensures that even in the event of
- a system crash, dhcpd will not forget about a lease that
- it has assigned. On startup, after reading the
- dhcpd.conf file, dhcpd reads the dhcpd.leases file to
- refresh its memory about what leases have been assigned.
-
- New leases are appended to the end of the dhcpd.leases
- file. In order to prevent the file from becoming arbi-
- trarily large, from time to time dhcpd creates a new
- dhcpd.leases file from its in-core lease database. Once
- this file has been written to disk, the old file is
- renamed _d_h_c_p_d_._l_e_a_s_e_s_~, and the new file is renamed
- dhcpd.leases. If the system crashes in the middle of
-
-
-
- 1
-
-
-
-
-
-dhcpd(8) dhcpd(8)
-
-
- this process, whichever dhcpd.leases file remains will
- contain all the lease information, so there is no need for
- a special crash recovery process.
-
- BOOTP support is also provided by this server. Unlike
- DHCP, the BOOTP protocol does not provide a protocol for
- recovering dynamically-assigned addresses once they are no
- longer needed. It is still possible to dynamically
- assign addresses to BOOTP clients, but some administrative
- process for reclaiming addresses is required. By
- default, leases are granted to BOOTP clients in perpetu-
- ity, although the network administrator may set an earlier
- cutoff date or a shorter lease length for BOOTP leases if
- that makes sense.
-
- BOOTP clients may also be served in the old standard way,
- which is to simply provide a declaration in the dhcpd.conf
- file for each BOOTP client, permanently assigning an
- address to each client.
-
- Whenever changes are made to the dhcpd.conf file, dhcpd
- must be restarted. To restart dhcpd, send a SIGTERM
- (signal 15) to the process ID contained in
- _/_v_a_r_/_r_u_n_/_d_h_c_p_d_._p_i_d, and then re-invoke dhcpd. Because the
- DHCP server database is not as lightweight as a BOOTP
- database, dhcpd does not automatically restart itself when
- it sees a change to the dhcpd.conf file.
-
-CCOOMMMMAANNDD LLIINNEE
- The names of the network interfaces on which dhcpd should
- listen for broadcasts may be specified on the command
- line. This should be done on systems where dhcpd is
- unable to identify non-broadcast interfaces, but should
- not be required on other systems. If no interface names
- are specified on the command line dhcpd will identify all
- network interfaces which are up, elimininating non-
- broadcast interfaces if possible, and listen for DHCP
- broadcasts on each interface.
-
- If dhcpd should listen on a port other than the standard
- (port 67), the --pp flag may used. It should be followed by
- the udp port number on which dhcpd should listen. This is
- mostly useful for debugging purposes.
-
- To run dhcpd as a foreground process, rather than allowing
- it to run as a daemon in the background, the --ff flag
- should be specified. This is useful when running dhcpd
- under a debugger, or when running it out of inittab on
- System V systems.
-
- To have dhcpd log to the standard error descriptor, spec-
- ify the --dd flag. This can be useful for debugging, and
- also at sites where a complete log of all dhcp activity
- must be kept but syslogd is not reliable or otherwise
-
-
-
- 2
-
-
-
-
-
-dhcpd(8) dhcpd(8)
-
-
- cannot be used. Normally, dhcpd will log all output
- using the syslog(3) function with the log facility set to
- LOG_DAEMON.
-
- Dhcpd can be made to use an alternate configuration file
- with the --ccff flag, or an alternate lease file with the --llff
- flag. Because of the importance of using the same lease
- database at all times when running dhcpd in production,
- these options should be used oonnllyy for testing lease files
- or database files in a non-production environment.
-
-CCOONNFFIIGGUURRAATTIIOONN
- The syntax of the dhcpd.conf(8) file is discussed seper-
- ately. This section should be used as an overview of the
- configuration process, and the dhcpd.conf(8) documentation
- should be consulted for detailed reference information.
-
-
-SSuubbnneettss
- dhcpd needs to know the subnet numbers and netmasks of all
- subnets for which it will be providing service. In addi-
- tion, in order to dynamically allocate addresses, it must
- be assigned one or more ranges of addresses on each subnet
- which it can in turn assign to client hosts as they boot.
- Thus, a very simple configuration providing DHCP support
- might look like this:
-
- subnet 239.252.197.0 netmask 255.255.255.0 {
- range 239.252.197.10 239.252.197.250;
- }
-
- Multiple address ranges may be specified like this:
-
- subnet 239.252.197.0 netmask 255.255.255.0 {
- range 239.252.197.10 239.252.197.107;
- range 239.252.197.113 239.252.197.250;
- }
-
- If a subnet will only be provided with BOOTP service and
- no dynamic address assignment, the range clause can be
- left out entirely, but the subnet statement must appear.
-
-
-LLeeaassee LLeennggtthhss
- DHCP leases can be assigned almost any length from zero
- seconds to infinity. What lease length makes sense for
- any given subnet, or for any given installation, will vary
- depending on the kinds of hosts being served.
-
- For example, in an office environment where systems are
- added from time to time and removed from time to time, but
- move relatively infrequently, it might make sense to allow
- lease times of a month of more. In a final test environ-
- ment on a manufacturing floor, it may make more sense to
-
-
-
- 3
-
-
-
-
-
-dhcpd(8) dhcpd(8)
-
-
- assign a maximum lease length of 30 minutes - enough time
- to go through a simple test procedure on a network appli-
- ance before packaging it up for delivery.
-
- It is possible to specify two lease lengths: the default
- length that will be assigned if a client doesn't ask for
- any particular lease length, and a maximum lease length.
- These are specified as clauses to the subnet command:
-
- subnet 239.252.197.0 netmask 255.255.255.0 {
- range 239.252.197.10 239.252.197.107;
- default-lease-time 600;
- max-lease-time 7200;
- |
-
- This particular subnet declaration specifies a default
- lease time of 600 seconds (ten minutes), and a maximum
- lease time of 7200 seconds (two hours). Other common
- values would be 86400 (one day), 604800 (one week) and
- 2592000 (30 days).
-
- Each subnet need not have the same lease--in the case of
- an office environment and a manufacturing environment
- served by the same DHCP server, it might make sense to
- have widely disparate values for default and maximum lease
- times on each subnet.
-
-BBOOOOTTPP SSuuppppoorrtt
- Each BOOTP client must be explicitly declared in the
- dhcpd.conf file. A very basic client declaration will
- specify the client network interface's hardware address
- and the IP address to assign to that client. If the
- client needs to be able to load a boot file from the
- server, that file's name must be specified. A simple
- bootp client declaration might look like this:
-
- host haagen {
- hardware ethernet 08:00:2b:4c:59:23;
- fixed-address 239.252.197.9;
- filename "/tftpboot/haagen.boot";
- }
-
-OOppttiioonnss
- DHCP (and also BOOTP with Vendor Extensions) provide a
- mechanism whereby the server can provide the client with
- information about how to configure its network interface
- (e.g., subnet mask), and also how the client can access
- various network services (e.g., DNS, IP routers, and so
- on).
-
- These options can be specified on a per-subnet basis, and,
- for BOOTP clients, also on a per-client basis. In the
- event that a BOOTP client declaration specifies options
- that are also specified in its subnet declaration, the
-
-
-
- 4
-
-
-
-
-
-dhcpd(8) dhcpd(8)
-
-
- options specified in the client declaration take prece-
- dence. An reasonably complete DHCP configuration might
- look something like this:
-
- subnet 239.252.197.0 netmask 255.255.255.0 {
- range 239.252.197.10 239.252.197.250;
- default-lease-time 600 max-lease-time 7200;
- option subnet-mask 255.255.255.0;
- option broadcast-address 239.252.197.255;
- option routers 239.252.197.1;
- option domain-name-servers 239.252.197.2, 239.252.197.3;
- option domain-name "isc.org";
- }
-
- A bootp host on that subnet that needs to be in a differ-
- ent domain and use a different name server might be
- declared as follows:
-
- host haagen hardware ethernet 08:00:2b:4c:59:23 {
- fixed-address 239.252.197.9;
- filename "/tftpboot/haagen.boot";
- option domain-name-servers 192.5.5.1;
- option domain-name "vix.com";
- }
-
- A more complete description of the dhcpd.conf file syntax
- is provided in dhcpd.conf(5).
-
-FFIILLEESS
- //eettcc//ddhhccppdd..ccoonnff,, //vvaarr//ddbb//ddhhccppdd..lleeaasseess,, //vvaarr//rruunn//ddhhccppdd..ppiidd,,
- //vvaarr//ddbb//ddhhccppdd..lleeaasseess~~..
-
-SSEEEE AALLSSOO
- dhcpd.conf(5), dhcpd.leases(5)
-
-AAUUTTHHOORR
- ddhhccppdd((88)) was written by Ted Lemon <mellon@vix.com> under a
- contract with Vixie Labs. Funding for this project was
- provided by the Internet Software Corporation. Informa-
- tion about the Internet Software Consortium can be found
- at hhttttpp::////wwwwww..iisscc..oorrgg//iisscc..
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 5
-
-
diff --git a/server/dhcpd.conf b/server/dhcpd.conf
deleted file mode 100644
index a50dee07..00000000
--- a/server/dhcpd.conf
+++ /dev/null
@@ -1,128 +0,0 @@
-# dhcpd.conf
-#
-# Configuration file for ISC dhcpd
-#
-
-# Hosts with more than one interface MUST specify a ``server-identifier'',
-# which should be the IP address of the server's primary network interface,
-# or if there is no interface that can be described that way, at least an
-# interface whose address isn't likely to change.
-
-server-identifier toccata.fugue.com;
-
-# option definitions common to all supported networks...
-option domain-name "fugue.com";
-option domain-name-servers toccata.fugue.com;
-
-# Shared network declaration is used to group subnets which share the same
-# physical network together. The name is specified so that the shared
-# network can be referred to in log messages - it serves no other function.
-
-shared-network FUGUE {
-
-# option definitions common to this shared network.
- option subnet-mask 255.255.255.224;
- default-lease-time 600;
- max-lease-time 7200;
-
-# One of the two IP subnets that share this physical network
-#
-# Address ranges can be specified for each subnet attached to
-# a shared network. Since these subnets share the same physical
-# network, addresses are pooled together, and assignments are made
-# without regard to the actual subnet. If the optional dynamic-bootp
-# keyword is given in the address range declaration, then addresses
-# in that range can be assigned either with the DHCP protocol or the
-# BOOTP protocol; otherwise, only DHCP clients will have addresses
-# allocated from the address range.
-#
-# Note that each IP subnet can have its own options specific to that subnet.
-# options that aren't specified in the subnet are taken from the shared
-# network (if any) and then from the global option list.
-
- subnet 204.254.239.0 netmask 255.255.255.224 {
- range 204.254.239.10 204.254.239.20;
- option broadcast-address 204.254.239.31;
- option routers prelude.fugue.com;
- }
-
-# The other subnet that shares this physical network
- subnet 204.254.239.32 netmask 255.255.255.224 {
- range dynamic-bootp 204.254.239.10 204.254.239.20;
- option broadcast-address 204.254.239.31;
- option routers snarg.fugue.com;
- }
-}
-
-# IP subnets that are alone on their physical wire should be declared by
-# themselves. ISC dhcpd may still refer to them as shared networks in
-# log messages, but this is simply an artifact of the underlying data
-# structures.
-#
-# Note that options can be specified in the subnet declaration which
-# supersede the global options specified earlier.
-
-subnet 192.5.5.0 netmask 255.255.255.224 {
- range 192.5.5.26 192.5.5.30;
- option name-servers bb.home.vix.com, gw.home.vix.com;
- option domain-name "vix.com";
- option routers 192.5.5.1;
- option subnet-mask 255.255.255.224;
- option broadcast-address 192.5.5.31;
- default-lease-time 600;
- max-lease-time 7200;
-}
-
-# Hosts which require special configuration options can be listed in
-# host statements. If no address is specified, the address will be
-# allocated dynamically (if possible), but the host-specific information
-# will still come from the host declaration.
-
-host passacaglia {
- hardware ethernet 0:0:c0:5d:bd:95;
- filename "vmunix.passacaglia";
- server-name "toccata.fugue.com";
-}
-
-# Fixed IP addresses can also be specified for hosts. These addresses
-# should not also be listed as being available for dynamic assignment.
-# Hosts for which fixed IP addresses have been specified can boot using
-# BOOTP or DHCP. Hosts for which no fixed address is specified can only
-# be booted with DHCP, unless there is an address range on the subnet
-# to which a BOOTP client is connected which has the dynamic-bootp flag
-# set.
-host fantasia {
- hardware ethernet 08:00:07:26:c0:a5;
- fixed-address fantasia.fugue.com;
-}
-
-# If a DHCP or BOOTP client is mobile and might be connected to a variety
-# of networks, more than one fixed address for that host can be specified.
-# Hosts can have fixed addresses on some networks, but receive dynamically
-# allocated address on other subnets; in order to support this, a host
-# declaration for that client must be given which does not have a fixed
-# address. If a client should get different parameters depending on
-# what subnet it boots on, host declarations for each such network should
-# be given. Finally, if a domain name is given for a host's fixed address
-# and that domain name evaluates to more than one address, the address
-# corresponding to the network to which the client is attached, if any,
-# will be assigned.
-host confusia {
- hardware ethernet 02:03:04:05:06:07;
- fixed-address confusia-1.fugue.com, confusia-2.fugue.com;
- filename "vmunix.confusia";
- server-name "toccata.fugue.com";
-}
-
-host confusia {
- hardware ethernet 02:03:04:05:06:07;
- fixed-address confusia-3.fugue.com;
- filename "vmunix.confusia";
- server-name "snarg.fugue.com";
-}
-
-host confusia {
- hardware ethernet 02:03:04:05:06:07;
- filename "vmunix.confusia";
- server-name "bb.home.vix.com";
-}
diff --git a/server/dhcpd.conf.5 b/server/dhcpd.conf.5
deleted file mode 100644
index a0dbc51a..00000000
--- a/server/dhcpd.conf.5
+++ /dev/null
@@ -1,1050 +0,0 @@
-.\" dhcpd.conf.5
-.\"
-.\" Copyright (c) 1995, 1996 The Internet Software Consortium.
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\"
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of The Internet Software Consortium nor the names
-.\" of its contributors may be used to endorse or promote products derived
-.\" from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
-.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-.\" DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
-.\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" This software has been written for the Internet Software Consortium
-.\" by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
-.\" Enterprises. To learn more about the Internet Software Consortium,
-.\" see ``http://www.isc.org/isc''. To learn more about Vixie
-.\" Enterprises, see ``http://www.vix.com''.
-.TH dhcpd.conf 5
-.SH NAME
-dhcpd.conf - dhcpd configuration file
-.SH DESCRIPTION
-The dhcpd.conf file contains configuration information for
-.IR dhcpd,
-the Internet Software Consortium DHCP Server.
-.PP
-The dhcpd.conf file is a free-form ASCII text file. It is parsed by
-the recursive-descent parser built into dhcpd. 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 file essentially consists of a list of statements. Statements
-fall into two broad categories - parameters and declarations.
-.PP
-Parameter statements either say how to do something (e.g., how long a
-lease to offer), whether to do something (e.g., should dhcpd provide
-addresses to unknown clients), or what parameters to provide to the
-client (e.g., use gateway 220.177.244.7).
-.PP
-Declarations are used to describe the topology of the
-network, to describe clients on the network, to provide addresses that
-can be assigned to clients, or to apply a group of parameters to a
-group of declarations. In any group of parameters and declarations,
-all parameters must be specified before any declarations which depend
-on those parameters may be specified.
-.PP
-Declarations about network topology include the
-\fIserver-identifier\fR, the \fIshared-network\fR and the \fIsubnet\fR
-declarations. If clients on a subnet are to be assigned addresses
-dynamically, a \fIrange\fR declaration must appear within the
-\fIsubnet\fR declaration. For clients with statically assigned
-addresses, or for installations where only known clients will be
-served, each such client must have a \fIhost\fR declaration. If
-parameters are to be applied to a group of declarations which are not
-related strictly on a per-subnet basis, the \fIgroup\fR declaration
-can be used.
-.PP
-Each dhcpd.conf file must have one (and only one)
-.I server-identifier
-declaration, which tells dhcpd the identifier to use when issuing
-leases. For every subnet which will be served, and for every subnet
-to which the dhcp server is connected, there must be one \fIsubnet\fR
-declaration, which tells dhcpd how to recognize that an address is on
-that subnet. A \fIsubnet\fR declaration is required for each subnet
-even if no addresses will be dynamically allocated on that subnet.
-.PP
-Some installations have physical networks on which more than one IP
-subnet operates. For example, if there is a site-wide requirement
-that 8-bit subnet masks be used, but a department with a single
-physical ethernet network expands to the point where it has more than
-254 nodes, it may be necessary to run two 8-bit subnets on the same
-ethernet until such time as a new physical network can be added. In
-this case, the \fIsubnet\fR declarations for these two networks may be
-enclosed in a \fIshared-network\fR declaration.
-.PP
-Some sites may have departments which have clients on more than one
-subnet, but it may be desirable to offer those clients a uniform set
-of parameters which are different than what would be offered to
-clients from other departments on the same subnet. For clients which
-will be declared explicitly with \fIhost\fR declarations, these
-declarations can be enclosed in a \fIgroup\fR declaration along with
-the parameters which are common to that department. For clients
-whose addresses will be dynamically assigned, there is currently no
-way to group parameter assignments other than by network topology.
-.PP
-When a client is to be booted, its boot parameters are determined by
-first consulting that client's \fIhost\fR declaration (if any), then
-consulting the \fIgroup\fR declaration (if any) which enclosed that
-\fIhost\fR declaration, then consulting the \fIsubnet\fR declaration
-for the subnet on which the client is booting, then consulting the
-\fIshared-network\fR declaration (if any) containing that subnet, and
-finally consulting the top-level parameters which may be specified
-outside of any declaration.
-.PP
-When dhcpd tries to find a \fIhost\fR declaration for a client, it
-first looks for a \fIhost\fR declaration which has a
-\fIfixed-address\fR parameter which matches the subnet or shared
-network on which the client is booting. If it doesn't find any such
-entry, it then tries to find an entry which has no \fIfixed-address\fR
-parameter. If no such entry is found, then dhcpd acts as if there is
-no entry in the dhcpd.conf file for that client, even if there is an
-entry for that client on a different subnet or shared network.
-.SH EXAMPLES
-.PP
-A typical dhcpd.conf file will look something like this:
-.nf
-
-server-identifier dhcps.isc.org;
-.I global parameters...
-
-shared-network ISC-BIGGIE {
- \fIshared-network-specific parameters...\fR
- subnet 204.254.239.0 netmask 255.255.255.224 {
- \fIsubnet-specific parameters...\fR
- range 204.254.239.10 204.254.239.30;
- }
- subnet 204.254.239.32 netmask 255.255.255.224 {
- \fIsubnet-specific parameters...\fR
- range 204.254.239.42 204.254.239.62;
- }
-}
-
-subnet 204.254.239.64 netmask 255.255.255.224 {
- \fIsubnet-specific parameters...\fR
- range 204.254.239.74 204.254.239.94;
-}
-
-group {
- \fIgroup-specific parameters...\fR
- host zappo.test.isc.org {
- \fIhost-specific parameters...\fR
- }
- host beppo.test.isc.org {
- \fIhost-specific parameters...\fR
- }
- host harpo.test.isc.org {
- \fIhost-specific parameters...\fR
- }
-}
-
-.ce 1
-Figure 1
-
-.fi
-.PP
-Notice that after the server-identifier declaration, there's a place
-for global parameters. These might be things like the organization's
-domain name, the addresses of the name servers (if they are common to
-the entire organization), and so on. So, for example:
-.nf
-
- option domain-name "isc.org";
- option name-servers ns1.isc.org, ns2.isc.org;
-
-.ce 1
-Figure 2
-.fi
-.PP
-As you can see in Figure 2, it's legal to specify host addresses in
-parameters as domain names rather than as numeric IP addresses. If a
-given hostname resolves to more than one IP address (for example, if
-that host has two ethernet interfaces), both addresses are supplied to
-the client.
-.PP
-In Figure 1, you can see that both the shared-network statement and
-the subnet statements can have parameters. Let us say that the
-shared network \fIISC-BIGGIE\fR supports an entire department -
-perhaps the accounting department. If accounting has its own domain,
-then a shared-network-specific parameter might be:
-.nf
-
- option domain-name "accounting.isc.org";
-.fi
-.PP
-All subnet declarations appearing in the shared-network declaration
-would then have the domain-name option set to "accounting.isc.org"
-instead of just "isc.org".
-.PP
-The most obvious reason for having subnet-specific parameters as
-shown in Figure 1 is that each subnet, of necessity, has its own
-router. So for the first subnet, for example, there should be
-something like:
-.nf
-
- option routers 204.254.239.1;
-.fi
-.PP
-Note that the address here is specified numerically. This is not
-required - if you have a different domain name for each interface on
-your router, it's perfectly legitimate to use the domain name for that
-interface instead of the numeric address. However, in many cases
-there may be only one domain name for all of a router's IP addresses, and
-it would not be appropriate to use that name here.
-.PP
-In Figure 1 there is also a \fIgroup\fR statement, which provides
-common parameters for a set of three hosts - zappo, beppo and harpo.
-As you can see, these hosts are all in the test.isc.org domain, so it
-might make sense for a group-specific parameter to override the domain
-name supplied to these hosts:
-.nf
-
- option domain-name "test.isc.org";
-.fi
-.PP
-Also, given the domain they're in, these are probably test machines.
-If we wanted to test the DHCP leasing mechanism, we might set the
-lease timeout somewhat shorter than the default:
-
-.nf
- max-lease-time 120;
- default-lease-time 120;
-.fi
-.PP
-You may have noticed that while some parameters start with the
-\fIoption\fR keyword, some do not. Parameters starting with the
-\fIoption\fR keyword correspond to actual DHCP options, while
-parameters that do not start with the option keyword either control
-the behaviour of the DHCP server (e.g., how long a lease dhcpd will
-give out), or specify client parameters that are not optional in the
-DHCP protocol (for example, server-name and filename).
-.PP
-In Figure 1, each host had \fIhost-specific parameters\fR. These
-could include such things as the \fIhostname\fR option, the name of a
-file to upload (the \fIfilename parameter) and the address of the
-server from which to upload the file (the \fInext-server\fR
-parameter). In general, any parameter can appear anywhere that
-parameters are allowed, and will be applied according to the scope in
-which the parameter appears.
-.PP
-Imagine that you have a site with a lot of NCD X-Terminals. These
-terminals come in a variety of models, and you want to specify the
-boot files for each models. One way to do this would be to have host
-declarations for each server and group them by model:
-.nf
-
-group {
- filename "Xncd19r";
- next-server ncd-booter;
-
- host ncd1 { hardware ethernet 0:c0:c3:49:2b:57; }
- host ncd4 { hardware ethernet 0:c0:c3:80:fc:32; }
- host ncd8 { hardware ethernet 0:c0:c3:22:46:81; }
-}
-
-group {
- filename "Xncd19c";
- next-server ncd-booter;
-
- host ncd2 { hardware ethernet 0:c0:c3:88:2d:81; }
- host ncd3 { hardware ethernet 0:c0:c3:00:14:11; }
-}
-
-group {
- filename "XncdHMX";
- next-server ncd-booter;
-
- host ncd1 { hardware ethernet 0:c0:c3:11:90:23; }
- host ncd4 { hardware ethernet 0:c0:c3:91:a7:8; }
- host ncd8 { hardware ethernet 0:c0:c3:cc:a:8f; }
-}
-.fi
-.SH REFERENCE: DECLARATIONS
-.PP
-.B The
-.I server-identifier
-.B statement
-.PP
- \fBserver-identifier \fIhostname\fR\fB;\fR
-.PP
-The server-identifier declaration must be used exactly once in each
-dhcpd.conf file to tell dhcpd what IP address to use as its server
-identifier, as required by the DHCP protocol. On a machine with a
-single interface, the server identifier should be the primary address
-of that interface. On machines with multiple interfaces, the address
-of one such interface must be chosen. Any address may be chosen, as
-long as it is the address of one of the interfaces of that machine.
-.PP
-.B The
-.I shared-network
-.B statement
-.PP
-.nf
- \fBshared-network\fR \fIname\fR \fB{\fR
- [ \fIparameters\fR ]
- [ \fIdeclarations\fR ]
- \fB}\fR
-.fi
-.PP
-The \fIshared-network\fR statement is used to inform the DHCP server
-that some IP subnets actually share the same physical network. Any
-subnets in a shared network should be declared within a
-\fIshared-network\fR statement. Parameters specified in the
-\fIshared-network\fR statement will be used when booting clients on
-those subnets unless parameters provided at the subnet or host level
-override them. If any subnet in a shared network has addresses
-available for dynamic allocation, those addresses are collected into a
-common pool for that shared network and assigned to clients as needed.
-There is no way to distinguish on which subnet of a shared network a
-client should boot.
-.PP
-.I Name
-should be the name of the shared network. This name is used when
-printing debugging messages, so it should be descriptive for the
-shared network. The name may have the syntax of a valid domain name
-(although it will never be used as such), or it may be any arbitrary
-name, enclosed in quotes.
-.PP
-.B The
-.I subnet
-.B statement
-.PP
-.nf
- \fBsubnet\fR \fIsubnet-number\fR \fBnetmask\fR \fInetmask\fR \fB{\fR
- [ \fIparameters\fR ]
- [ \fIdeclarations\fR ]
- \fB}\fR
-.fi
-.PP
-The \fIsubnet\fR statement is used to provide dhcpd with enough
-information to tell whether or not an IP address is on that subnet.
-It may also be used to provide subnet-specific parameters and to
-specify what addresses may be dynamically allocated to clients booting
-on that subnet. Such addresses are specified using the \fIrange\fR
-declaration.
-.PP
-The
-.I subnet-number
-should be an IP address or domain name which resolves to the subnet
-number of the subnet being described. The
-.I netmask
-should be an IP address or domain name which resolves to the subnet mask
-of the subnet being described. The subnet number, together with the
-netmask, are sufficient to determine whether any given IP address is
-on the specified subnet.
-.PP
-Although a netmask must be given with every subnet declaration, it is
-recommended that if there is any variance in subnet masks at a site, a
-subnet-mask option statement be used in each subnet declaration to set
-the desired subnet mask, since any subnet-mask option statement will
-override the subnet mask declared in the subnet statement.
-.PP
-.B The
-.I range
-.B statement
-.PP
-.nf
- \fBrange\fR [ \fBdynamic-bootp\fR ] \fIlow-address\fR [ \fIhigh-address\fR]\fB;\fR
-.fi
-.PP
-For any subnet on which addresses will be assigned dynamically, there
-must be at least one \fIrange\fR statement. The range statement
-gives the lowest and highest IP addresses in a range. All IP
-addresses in the range should be in the subnet in which the
-\fIrange\fR statement is declared. The \fIdynamic-bootp\fR flag may
-be specified if addresses in the specified range may be dynamically
-assigned to BOOTP clients as well as DHCP clients. When specifying a
-single address, \fIhigh-address\fR can be omitted.
-.PP
-.B The
-.I host
-.B statement
-.PP
-.nf
- \fBhost\fR \fIhostname\fR {
- [ \fIparameters\fR ]
- [ \fIdeclarations\fR ]
- \fB}\fR
-.fi
-.PP
-There must be at least one
-.B host
-statement for every BOOTP client that is to be served.
-.B host
-statements may also be specified for DHCP clients, although this is
-not required unless booting is only enabled for known hosts.
-.PP
-If it is desirable to be able to boot a DHCP or BOOTP
-client on more than one subnet with fixed addresses, more than one
-address may be specified in the
-.I fixed-address
-parameter, or more than one
-.B host
-statement may be specified.
-.PP
-If client-specific boot parameters must change based on the network
-to which the client is attached, then multiple
-.B host
-statements should
-be used.
-.PP
-If a client is to be booted using a fixed address if it's
-possible, but should be allocated a dynamic address otherwise, then a
-.B host
-statement must be specified without a
-.B fixed-address
-clause.
-.I hostname
-should be a name identifying the host. If a \fIhostname\fR option is
-not specified for the host, \fIhostname\fR is used.
-.PP
-\fIHost\fR declarations are matched to actual DHCP or BOOTP clients
-by matching the \fRdhcp-client-identifier\fR option specified in the
-\fIhost\fR declaration to the one supplied by the client, or, if the
-\fIhost\fR declaration or the client does not provide a
-\fRdhcp-client-identifier\fR option, by matching the \fIhardware\fR
-parameter in the \fIhost\fR declaration to the network hardware
-address supplied by the client. BOOTP clients do not normally
-provide a \fIdhcp-client-identifier\fR, so the hardware address must
-be used for all clients that may boot using the BOOTP protocol.
-.PP
-.B The
-.I group
-.B statement
-.PP
-.nf
- \fBgroup\fR {
- [ \fIparameters\fR ]
- [ \fIdeclarations\fR ]
- \fB}\fR
-.fi
-.PP
-The group statement is used simply to apply one or more parameters to
-a group of declarations. It can be used to group hosts, shared
-networks, subnets, or even other groups.
-.SH REFERENCE: PARAMETERS
-.PP
-.B The
-.I default-lease-time
-.B statement
-.PP
- \fBdefault-lease-time\fR \fItime\fR\fB;\fR
-.PP
-.I Time
-should be the length in seconds that will be assigned to a lease if
-the client requesting the lease does not ask for a specific expiration
-time.
-.PP
-.B The
-.I max-lease-time
-.B statement
-.PP
- \fBmax-lease-time\fR \fItime\fR\fB;\fR
-.PP
-.I Time
-should be the maximum length in seconds that will be assigned to a
-lease if the client requesting the lease asks for a specific
-expiration time.
-.PP
-.B The
-.I hardware
-.B statement
-.PP
- \fBhardware\fR \fIhardware-type\fR \fIhardware-address\fR\fB;\fR
-.PP
-In order for a BOOTP client to be recognized, its network hardware
-address must be declared using a \fIhardware\fR clause in the
-.I host
-statement.
-.I hardware-type
-must be the name of a physical hardware interface type. Currently,
-only the
-.B ethernet
-type is recognized, although support for
-.B token-ring
-and
-.B fddi
-hardware types would also be desirable.
-The
-.I hardware-address
-should be a set of hexadecimal octets (numbers from 0 through ff)
-seperated by colons. The \fIhardwarefR statement may also be used
-for DHCP clients.
-.PP
-.B The
-.I filename
-.B statement
-.PP
- \fBfilename\fR \fB"\fR\fIfilename\fR\fB";\fR
-.PP
-The \fIfilename\fR statement can be used to specify the name of the
-initial boot file which is to be loaded by a client. The
-.I filename
-should be a filename recognizable to whatever file transfer protocol
-the client can be expected to use to load the file.
-.PP
-.B The
-.I server-name
-.B statement
-.PP
- \fBserver-name\fR \fB"\fR\fIname\fR\fB";\fR
-.PP
-The \fIserver-name\fR statement can be used to inform the client of
-the name of the server from which it is booting. \fIName\fR should
-be the name that will be provided to the client.
-.PP
-.B The
-.I next-server
-.B statement
-.PP
- \fBnext-server\fR \fIserver-name\fR\fB;\fR
-.PP
-The \fInext-server\fR statement is used to specify the host address of
-the server from which the initial boot file (specified in the
-\fIfilename\fR statement) is to be loaded. \fIServer-name\fR should
-be a numeric IP address or a domain name. If no \fInext-server\fR
-parameter applies to a given client, the address specified in the
-\fIserver-identifier\fR statement is used.
-.PP
-.B The
-.I fixed-address
-.B statement
-.PP
- \fBfixed-address\fR \fIaddress\fR [\fB,\fR \fIaddress\fR ... ]\fB;\fR
-.PP
-The \fIfixed-address\fR statement is used to assign one or more fixed
-IP addresses to a client. It should only appear in a \fIhost\fR
-declaration. If more than one address is supplied, then when the
-client boots, it will be assigned the address which corresponds to the
-network on which it is booting. If none of the addresses in the
-\fIfixed-address\fR statement are on the network on which the client
-is booting, that client will not match the \fIhost\fR declaration
-containing that \fIfixed-address\fR statement. Each \fIaddress\fR
-should be either an IP address or a domain name which resolves to one
-or more IP addresses.
-.PP
-.B The
-.I dynamic-bootp-lease-cutoff
-.B statement
-.PP
- \fBdynamic-bootp-lease-cutoff\fR \fIdate\fR\fB;\fR
-.PP
-The \fIdynamic-bootp-lease-cutoff\fR statement sets the ending time
-for all leases assigned dynamically to BOOTP clients. Because BOOTP
-clients do not have any way of renewing leases, and don't know that
-their leases could expire, by default dhcpd assignes infinite leases
-to all BOOTP clients. However, it may make sense in some situations
-to set a cutoff date for all BOOTP leases - for example, the end of a
-school term, or the time at night when a facility is closed and all
-machines are required to be powered off.
-.PP
-.I Date
-should be the date on which all assigned BOOTP leases will end. The
-date is specified in the form:
-.PP
-.ce 1
-W YYYY/MM/DD HH:MM:SS
-.PP
-W is the day of the week expressed as a number
-from zero (Sunday) to six (Saturday). YYYY is the year, including the
-century. MM is the month expressed as a number from 1 to 12. DD is
-the day of the month, counting from 1. HH is the hour, from zero to
-23. MM is the minute and SS is the second. The time is always in
-Greenwich Mean Time (GMT), not local time.
-.PP
-.B The
-.I dynamic-bootp-lease-length
-.B statement
-.PP
- \fBdynamic-bootp-lease-length\fR \fIlength\fR\fB;\fR
-.PP
-The \fIdynamic-bootp-lease-length\fR statement is used to set the
-length of leases dynamically assigned to BOOTP clients. At some
-sites, it may be possible to assume that a lease is no longer in
-use if its holder has not used BOOTP or DHCP to get its address within
-a certain time period. The period is specified in \fIlength\fR as a
-number of seconds. If a client reboots using BOOTP during the
-timeout period, the lease duration is reset to \fIlength\fR, so a
-BOOTP client that boots frequently enough will never lose its lease.
-Needless to say, this parameter should be adjusted with extreme
-caution.
-.PP
-.B The
-.I boot-unknown-clients
-.B statement
-.PP
- \fBboot-unknown-clients\fR \fIflag\fR\fB;\fR
-.PP
-The \fIboot-unknown-clients\fR statement is used to tell dhcpd whether
-or not to dynamically assign addresses to unknown clients. If
-\fIflag\fR is true (the default), then addresses are dynamically
-assigned to unknown clients when available. If \fIflag\fR is
-false, then addresses are provided only to clients which match at
-least one host declaration.
-.PP
-.B The
-.I get-lease-hostnames
-.B statement
-.PP
- \fBget-lease-hostnames\fR \fIflag\fR\fB;\fR
-.PP
-The \fIget-lease-hostnames\fR statement is used to tell dhcpd whether
-or not to look up the domain name corresponding to the IP address of
-each address in the lease pool and use that address for the DHCP
-\fIhostname\fR option. If \fIflag\fR is true, then this lookup is
-done for all addresses in the current scope. By default, or if
-\fIflag\fR is false, no lookups are done.
-.PP
-.B The
-.I use-host-decl-names
-.B statement
-.PP
- \fBuse-host-decl-names\fR \fIflag\fR\fB;\fR
-.PP
-If the \fIuse-host-decl-names\fR parameter is true in a given scope,
-then for every host declaration within that scope, the name provided
-for the host declaration will be supplied to the client as its
-hostname. So, for example,
-.PP
-.nf
- group {
- use-host-decl-names on;
-
- host joe {
- hardware ethernet 08:00:2b:4c:29:32;
- fixed-address joe.fugue.com;
- }
- }
-
-is equivalent to
-
- host joe {
- hardware ethernet 08:00:2b:4c:29:32;
- fixed-address joe.fugue.com;
- option host-name "joe";
- }
-.fi
-.PP
-An \fIoption host-name\fR statement within a host declaration will
-override the use of the name in the host declaration.
-.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 string
-data type specifies an NVT ASCII string, which must be
-enclosed in double quotes - for example, to specify a domain-name
-option, the syntax would be
-.nf
-.sp 1
- option domain-name "isc.org";
-.fi
-.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 data-string
-data type specifies either an NVT ASCII string
-enclosed in double quotes, or a series of octets specified in
-hexadecimal, seperated by colons. For example:
-.nf
-.sp 1
- option client-identifier "CLIENT-FOO";
-or
- option client-identifier 43:4c:49:45:54:2d:46:4f:4f;
-.fi
-.PP
-The documentation for the various options mentioned below is taken
-from the latest IETF draft document on DHCP options. Options which
-are not listed by name may be defined by the name option-\fInnn\fR,
-where \fInnn\fI is the decimal number of the option code. These
-options may be followed either by a string, enclosed in quotes, or by
-a series of octets, expressed as two-digit hexadecimal numbers seperated
-by colons. For example:
-.PP
-.nf
- option option-133 "my-option-133-text";
- option option-129 1:54:c9:2b:47;
-.fi
-.PP
-Because dhcpd does not know the format of these undefined option codes,
-no checking is done to ensure the correctness of the entered data.
-.PP
-The standard options are:
-.PP
- \fBoption subnet-mask\fR \fIip-address\fR\fB;\fR
-.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.
-.PP
- \fBoption time-offset\fR \fIint32\fR\fB;\fR
-.PP
-The time-offset option specifies the offset of the client's subnet in
-seconds from Coordinated Universal Time (UTC).
-.PP
- \fBoption routers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.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.
-.PP
- \fBoption time-servers\fR \fIip-address [, \fIip-address\fR ... ]\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBname-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ];
-.PP
-The name-servers option specifies a list of IEN 116 name servers
-available to the client. Servers should be listed in order of
-preference.
-.PP
- \fBoption\fR \fBdomain-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBlog-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBcookie-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBlpr-servers\fR \fIip-address \fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBimpress-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.PP
-The impress-server option specifies a list of Imagen Impress servers
-available to the client. Servers should be listed in order of
-preference.
-.PP
- \fBoption\fR \fBresource-location-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.PP
-This option specifies a list of RFC 887 Resource Location
-servers available to the client. Servers should be listed in order
-of preference.
-.PP
- \fBoption\fR \fBhost-name\fR \fIstring\fR\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBboot-size\fR \fIuint16\fR\fB;\fR
-.PP
-This option specifies the length in 512-octet blocks of the default
-boot image for the client.
-.PP
- \fBoption\fR \fBmerit-dump\fR \fIstring\fR\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBdomain-name\fR \fIstring\fR\fB;\fR
-.PP
-This option specifies the domain name that client should use when
-resolving hostnames via the Domain Name System.
-.PP
- \fBoption\fR \fBswap-server\fR \fIip-address\fR\fB;\fR
-.PP
-This specifies the IP address of the client's swap server.
-.PP
- \fBoption\fR \fBroot-path\fR \fIstring\fB;\fR\fR
-.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.
-.PP
- \fBoption\fR \fBip-forwarding\fR \fIflag\fR\fB;\fR
-.PP
-This option specifies whether the client should configure its IP
-layer for packet forwarding. A value of 0 means disable IP
-forwarding, and a value of 1 means enable IP forwarding.
-.PP
- \fBoption\fR \fBnon-local-source-routing\fR \fIflag\fR\fB;\fR
-.PP
-This option specifies whether the client should configure its IP
-layer to allow forwarding of datagrams with non-local source routes
-(see Section 3.3.5 of [4] for a discussion of this topic). A value
-of 0 means disallow forwarding of such datagrams, and a value of 1
-means allow forwarding.
-.PP
- \fBoption\fR \fBpolicy-filter\fR \fIip-address ip-address\fR [\fB,\fR \fIip-address ip-address\fR ... ]\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBmax-dgram-reassembly\fR \fIuint16\fR\fB;\fR
-.PP
-This option specifies the maximum size datagram that the client
-should be prepared to reassemble. The minimum value legal value is
-576.
-.PP
- \fBoption\fR \fBdefault-ip-ttl\fR \fIuint8;\fR
-.PP
-This option specifies the default time-to-live that the client should
-use on outgoing datagrams.
-.PP
- \fBoption\fR \fBpath-mtu-aging-timeout\fR \fIuint32\fR\fB;\fR
-.PP
-This option specifies the timeout (in seconds) to use when aging Path
-MTU values discovered by the mechanism defined in RFC 1191.
-.PP
- \fBoption\fR \fBpath-mtu-plateau-table\fR \fIuint16\fR [\fB,\fR \fIuint16\fR ... ]\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBinterface-mtu\fR \fIuint16\fR\fB;\fR
-.PP
-This option specifies the MTU to use on this interface. The minimum
-legal value for the MTU is 68.
-.PP
- \fBoption\fR \fBall-subnets-local\fR \fIflag\fR\fB;\fR
-.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 1 indicates that all subnets share
-the same MTU. A value of 0 means that the client should assume that
-some subnets of the directly connected network may have smaller MTUs.
-.PP
- \fBoption\fR \fBbroadcast-address\fR \fIip-address\fR\fB;\fR
-.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).
-.PP
- \fBoption\fR \fBperform-mask-discovery\fR \fIflag\fR\fB;\fR
-.PP
-This option specifies whether or not the client should perform subnet
-mask discovery using ICMP. A value of 0 indicates that the client
-should not perform mask discovery. A value of 1 means that the
-client should perform mask discovery.
-.PP
- \fBoption\fR \fBmask-supplier\fR \fIflag\fR\fB;\fR
-.PP
-This option specifies whether or not the client should respond to
-subnet mask requests using ICMP. A value of 0 indicates that the
-client should not respond. A value of 1 means that the client should
-respond.
-.PP
- \fBoption\fR \fBrouter-discovery\fR \fIflag\fR\fB;\fR
-.PP
-This option specifies whether or not the client should solicit
-routers using the Router Discovery mechanism defined in RFC 1256.
-A value of 0 indicates that the client should not perform
-router discovery. A value of 1 means that the client should perform
-router discovery.
-.PP
- \fBoption\fR \fBrouter-solicitation-address\fR \fIip-address\fR\fB;\fR
-.PP
-This option specifies the address to which the client should transmit
-router solicitation requests.
-.PP
- \fBoption\fR \fBstatic-routes\fR \fIip-address ip-address\fR [\fB,\fR \fIip-address ip-address\fR ... ]\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBtrailer-encapsulation\fR \fIflag\fR\fB;\fR
-.PP
-This option specifies whether or not the client should negotiate the
-use of trailers (RFC 893 [14]) when using the ARP protocol. A value
-of 0 indicates that the client should not attempt to use trailers. A
-value of 1 means that the client should attempt to use trailers.
-.PP
- \fBoption\fR \fBarp-cache-timeout\fR \fIuint32\fR\fB;\fR
-.PP
-This option specifies the timeout in seconds for ARP cache entries.
-.PP
- \fBoption\fR \fBieee802-3-encapsulation\fR \fIflag\fR\fB;\fR
-.PP
-This option specifies whether or not the client should use Ethernet
-Version 2 (RFC 894) or IEEE 802.3 (RFC 1042) encapsulation if the
-interface is an Ethernet. A value of 0 indicates that the client
-should use RFC 894 encapsulation. A value of 1 means that the client
-should use RFC 1042 encapsulation.
-.PP
- \fBoption\fR \fBdefault-tcp-ttl\fR \fIuint8\fR\fB;\fR
-.PP
-This option specifies the default TTL that the client should use when
-sending TCP segments. The minimum value is 1.
-.PP
- \fBoption\fR \fBtcp-keepalive-interval\fR \fIuint32\fR\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBtcp-keepalive-garbage\fR \fIflag\fR\fB;\fR
-.PP
-This option specifies the whether or not the client should send TCP
-keepalive messages with a octet of garbage for compatibility with
-older implementations. A value of 0 indicates that a garbage octet
-should not be sent. A value of 1 indicates that a garbage octet
-should be sent.
-.PP
- \fBoption\fR \fBnis-domain\fR \fIstring\fR\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBnis-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.PP
-This option specifies a list of IP addresses indicating NIS servers
-available to the client. Servers should be listed in order of
-preference.
-.PP
- \fBoption\fR \fBntp-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBnetbios-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.PP
-The NetBIOS name server (NBNS) option specifies a list of RFC
-1001/1002 NBNS name servers listed in order of preference.
-.PP
- \fBoption\fR \fBnetbios-dd-server\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.PP
-The NetBIOS datagram distribution server (NBDD) option specifies a
-list of RFC 1001/1002 NBDD servers listed in order of preference.
-.PP
- \fBoption\fR \fBnetbios-node-type\fR \fIuint8\fR\fB;\fR
-.PP
-The NetBIOS node type option allows NetBIOS over TCP/IP clients which
-are configurable to be configured as described in RFC 1001/1002. The
-value is specified as a single octet which identifies the client type.
-A value of 1 corresponds to a NetBIOS B-node; a value of 2 corresponds
-to a P-node; a value of 4 corresponds to an M-node; a value of 8
-corresponds to an H-node.
-.PP
- \fBoption\fR \fBnetbios-scope\fR \fIstring\fR\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBfont-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.PP
-This option specifies a list of X Window System Font servers available
-to the client. Servers should be listed in order of preference.
-.PP
- \fBoption\fR \fBx-display-manager\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR
-.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.
-.PP
- \fBoption\fR \fBdhcp-client-identifier\fR \fIdata-string\fR\fB;\fR
-.PP
-This option can be used to specify the a DHCP client identifier in a
-host declaration, so that dhcpd can find the host record by matching
-against the client identifier.
-.SH SEE ALSO
-dhcpd.conf(5), dhcpd.leases(5),
-draft-ietf-dhc-options-1533update-04.txt, draft-ietf-dhc-dhcp-07.txt.
-.SH AUTHOR
-.B dhcpd(8)
-was written by Ted Lemon <mellon@vix.com>
-under a contract with Vixie Labs. Funding
-for this project was provided by the Internet Software Corporation.
-Information about the Internet Software Consortium can be found at
-.B http://www.isc.org/isc.
diff --git a/server/dhcpd.conf.cat5 b/server/dhcpd.conf.cat5
deleted file mode 100644
index ea02aab4..00000000
--- a/server/dhcpd.conf.cat5
+++ /dev/null
@@ -1,1188 +0,0 @@
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
-NNAAMMEE
- dhcpd.conf - dhcpd configuration file
-
-DDEESSCCRRIIPPTTIIOONN
- The dhcpd.conf file contains configuration information for
- _d_h_c_p_d_, the Internet Software Consortium DHCP Server.
-
- The dhcpd.conf file is a free-form ASCII text file. It
- is parsed by the recursive-descent parser built into
- dhcpd. 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.
-
- The file essentially consists of a list of statements.
- Statements fall into two broad categories - parameters and
- declarations.
-
- Parameter statements either say how to do something (e.g.,
- how long a lease to offer), whether to do something (e.g.,
- should dhcpd provide addresses to unknown clients), or
- what parameters to provide to the client (e.g., use gate-
- way 220.177.244.7).
-
- Declarations are used to describe the topology of the net-
- work, to describe clients on the network, to provide
- addresses that can be assigned to clients, or to apply a
- group of parameters to a group of declarations. In any
- group of parameters and declarations, all parameters must
- be specified before any declarations which depend on those
- parameters may be specified.
-
- Declarations about network topology include the _s_e_r_v_e_r_-
- _i_d_e_n_t_i_f_i_e_r, the _s_h_a_r_e_d_-_n_e_t_w_o_r_k and the _s_u_b_n_e_t declara-
- tions. If clients on a subnet are to be assigned
- addresses dynamically, a _r_a_n_g_e declaration must appear
- within the _s_u_b_n_e_t declaration. For clients with stati-
- cally assigned addresses, or for installations where only
- known clients will be served, each such client must have a
- _h_o_s_t declaration. If parameters are to be applied to a
- group of declarations which are not related strictly on a
- per-subnet basis, the _g_r_o_u_p declaration can be used.
-
- Each dhcpd.conf file must have one (and only one) _s_e_r_v_e_r_-
- _i_d_e_n_t_i_f_i_e_r declaration, which tells dhcpd the identifier
- to use when issuing leases. For every subnet which will
- be served, and for every subnet to which the dhcp server
- is connected, there must be one _s_u_b_n_e_t declaration, which
- tells dhcpd how to recognize that an address is on that
- subnet. A _s_u_b_n_e_t declaration is required for each subnet
- even if no addresses will be dynamically allocated on that
- subnet.
-
-
-
-
- 1
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- Some installations have physical networks on which more
- than one IP subnet operates. For example, if there is a
- site-wide requirement that 8-bit subnet masks be used, but
- a department with a single physical ethernet network
- expands to the point where it has more than 254 nodes, it
- may be necessary to run two 8-bit subnets on the same eth-
- ernet until such time as a new physical network can be
- added. In this case, the _s_u_b_n_e_t declarations for these
- two networks may be enclosed in a _s_h_a_r_e_d_-_n_e_t_w_o_r_k declara-
- tion.
-
- Some sites may have departments which have clients on more
- than one subnet, but it may be desirable to offer those
- clients a uniform set of parameters which are different
- than what would be offered to clients from other depart-
- ments on the same subnet. For clients which will be
- declared explicitly with _h_o_s_t declarations, these declara-
- tions can be enclosed in a _g_r_o_u_p declaration along with
- the parameters which are common to that department. For
- clients whose addresses will be dynamically assigned,
- there is currently no way to group parameter assignments
- other than by network topology.
-
- When a client is to be booted, its boot parameters are
- determined by first consulting that client's _h_o_s_t declara-
- tion (if any), then consulting the _g_r_o_u_p declaration (if
- any) which enclosed that _h_o_s_t declaration, then consulting
- the _s_u_b_n_e_t declaration for the subnet on which the client
- is booting, then consulting the _s_h_a_r_e_d_-_n_e_t_w_o_r_k declaration
- (if any) containing that subnet, and finally consulting
- the top-level parameters which may be specified outside of
- any declaration.
-
- When dhcpd tries to find a _h_o_s_t declaration for a client,
- it first looks for a _h_o_s_t declaration which has a _f_i_x_e_d_-
- _a_d_d_r_e_s_s parameter which matches the subnet or shared net-
- work on which the client is booting. If it doesn't find
- any such entry, it then tries to find an entry which has
- no _f_i_x_e_d_-_a_d_d_r_e_s_s parameter. If no such entry is found,
- then dhcpd acts as if there is no entry in the dhcpd.conf
- file for that client, even if there is an entry for that
- client on a different subnet or shared network.
-
-EEXXAAMMPPLLEESS
- A typical dhcpd.conf file will look something like this:
-
- server-identifier dhcps.isc.org;
- _g_l_o_b_a_l _p_a_r_a_m_e_t_e_r_s_._._.
-
- shared-network ISC-BIGGIE {
- _s_h_a_r_e_d_-_n_e_t_w_o_r_k_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s_._._.
- subnet 204.254.239.0 netmask 255.255.255.224 {
- _s_u_b_n_e_t_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s_._._.
- range 204.254.239.10 204.254.239.30;
-
-
-
- 2
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- }
- subnet 204.254.239.32 netmask 255.255.255.224 {
- _s_u_b_n_e_t_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s_._._.
- range 204.254.239.42 204.254.239.62;
- }
- }
-
- subnet 204.254.239.64 netmask 255.255.255.224 {
- _s_u_b_n_e_t_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s_._._.
- range 204.254.239.74 204.254.239.94;
- }
-
- group {
- _g_r_o_u_p_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s_._._.
- host zappo.test.isc.org {
- _h_o_s_t_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s_._._.
- }
- host beppo.test.isc.org {
- _h_o_s_t_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s_._._.
- }
- host harpo.test.isc.org {
- _h_o_s_t_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s_._._.
- }
- }
-
- Figure 1
-
-
- Notice that after the server-identifier declaration,
- there's a place for global parameters. These might be
- things like the organization's domain name, the addresses
- of the name servers (if they are common to the entire
- organization), and so on. So, for example:
-
- option domain-name "isc.org";
- option name-servers ns1.isc.org, ns2.isc.org;
-
- Figure 2
-
- As you can see in Figure 2, it's legal to specify host
- addresses in parameters as domain names rather than as
- numeric IP addresses. If a given hostname resolves to
- more than one IP address (for example, if that host has
- two ethernet interfaces), both addresses are supplied to
- the client.
-
- In Figure 1, you can see that both the shared-network
- statement and the subnet statements can have parameters.
- Let us say that the shared network _I_S_C_-_B_I_G_G_I_E supports an
- entire department - perhaps the accounting department.
- If accounting has its own domain, then a shared-network-
- specific parameter might be:
-
- option domain-name "accounting.isc.org";
-
-
-
- 3
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- All subnet declarations appearing in the shared-network
- declaration would then have the domain-name option set to
- "accounting.isc.org" instead of just "isc.org".
-
- The most obvious reason for having subnet-specific parame-
- ters as shown in Figure 1 is that each subnet, of neces-
- sity, has its own router. So for the first subnet, for
- example, there should be something like:
-
- option routers 204.254.239.1;
-
- Note that the address here is specified numerically.
- This is not required - if you have a different domain name
- for each interface on your router, it's perfectly legiti-
- mate to use the domain name for that interface instead of
- the numeric address. However, in many cases there may be
- only one domain name for all of a router's IP addresses,
- and it would not be appropriate to use that name here.
-
- In Figure 1 there is also a _g_r_o_u_p statement, which pro-
- vides common parameters for a set of three hosts - zappo,
- beppo and harpo. As you can see, these hosts are all in
- the test.isc.org domain, so it might make sense for a
- group-specific parameter to override the domain name sup-
- plied to these hosts:
-
- option domain-name "test.isc.org";
-
- Also, given the domain they're in, these are probably test
- machines. If we wanted to test the DHCP leasing mecha-
- nism, we might set the lease timeout somewhat shorter than
- the default:
-
- max-lease-time 120;
- default-lease-time 120;
-
- You may have noticed that while some parameters start with
- the _o_p_t_i_o_n keyword, some do not. Parameters starting
- with the _o_p_t_i_o_n keyword correspond to actual DHCP options,
- while parameters that do not start with the option keyword
- either control the behaviour of the DHCP server (e.g., how
- long a lease dhcpd will give out), or specify client
- parameters that are not optional in the DHCP protocol (for
- example, server-name and filename).
-
- In Figure 1, each host had _h_o_s_t_-_s_p_e_c_i_f_i_c _p_a_r_a_m_e_t_e_r_s.
- These could include such things as the _h_o_s_t_n_a_m_e option,
- the name of a file to upload (the _f_i_l_e_n_a_m_e _p_a_r_a_m_e_t_e_r_) _a_n_d
- _t_h_e _a_d_d_r_e_s_s _o_f _t_h_e _s_e_r_v_e_r _f_r_o_m _w_h_i_c_h _t_o _u_p_l_o_a_d _t_h_e _f_i_l_e
- _(_t_h_e _n_e_x_t_-_s_e_r_v_e_r parameter). In general, any parameter
- can appear anywhere that parameters are allowed, and will
- be applied according to the scope in which the parameter
- appears.
-
-
-
-
- 4
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- Imagine that you have a site with a lot of NCD X-
- Terminals. These terminals come in a variety of models,
- and you want to specify the boot files for each models.
- One way to do this would be to have host declarations for
- each server and group them by model:
-
- group {
- filename "Xncd19r";
- next-server ncd-booter;
-
- host ncd1 { hardware ethernet 0:c0:c3:49:2b:57; }
- host ncd4 { hardware ethernet 0:c0:c3:80:fc:32; }
- host ncd8 { hardware ethernet 0:c0:c3:22:46:81; }
- }
-
- group {
- filename "Xncd19c";
- next-server ncd-booter;
-
- host ncd2 { hardware ethernet 0:c0:c3:88:2d:81; }
- host ncd3 { hardware ethernet 0:c0:c3:00:14:11; }
- }
-
- group {
- filename "XncdHMX";
- next-server ncd-booter;
-
- host ncd1 { hardware ethernet 0:c0:c3:11:90:23; }
- host ncd4 { hardware ethernet 0:c0:c3:91:a7:8; }
- host ncd8 { hardware ethernet 0:c0:c3:cc:a:8f; }
- }
-
-RREEFFEERREENNCCEE:: DDEECCLLAARRAATTIIOONNSS
- TThhee _s_e_r_v_e_r_-_i_d_e_n_t_i_f_i_e_r ssttaatteemmeenntt
-
- sseerrvveerr--iiddeennttiiffiieerr _h_o_s_t_n_a_m_e;;
-
- The server-identifier declaration must be used exactly
- once in each dhcpd.conf file to tell dhcpd what IP address
- to use as its server identifier, as required by the DHCP
- protocol. On a machine with a single interface, the
- server identifier should be the primary address of that
- interface. On machines with multiple interfaces, the
- address of one such interface must be chosen. Any
- address may be chosen, as long as it is the address of one
- of the interfaces of that machine.
-
- TThhee _s_h_a_r_e_d_-_n_e_t_w_o_r_k ssttaatteemmeenntt
-
- sshhaarreedd--nneettwwoorrkk _n_a_m_e {{
- [ _p_a_r_a_m_e_t_e_r_s ]
- [ _d_e_c_l_a_r_a_t_i_o_n_s ]
- }}
-
-
-
-
- 5
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- The _s_h_a_r_e_d_-_n_e_t_w_o_r_k statement is used to inform the DHCP
- server that some IP subnets actually share the same physi-
- cal network. Any subnets in a shared network should be
- declared within a _s_h_a_r_e_d_-_n_e_t_w_o_r_k statement. Parameters
- specified in the _s_h_a_r_e_d_-_n_e_t_w_o_r_k statement will be used
- when booting clients on those subnets unless parameters
- provided at the subnet or host level override them. If
- any subnet in a shared network has addresses available for
- dynamic allocation, those addresses are collected into a
- common pool for that shared network and assigned to
- clients as needed. There is no way to distinguish on
- which subnet of a shared network a client should boot.
-
- _N_a_m_e should be the name of the shared network. This name
- is used when printing debugging messages, so it should be
- descriptive for the shared network. The name may have
- the syntax of a valid domain name (although it will never
- be used as such), or it may be any arbitrary name,
- enclosed in quotes.
-
- TThhee _s_u_b_n_e_t ssttaatteemmeenntt
-
- ssuubbnneett _s_u_b_n_e_t_-_n_u_m_b_e_r nneettmmaasskk _n_e_t_m_a_s_k {{
- [ _p_a_r_a_m_e_t_e_r_s ]
- [ _d_e_c_l_a_r_a_t_i_o_n_s ]
- }}
-
- The _s_u_b_n_e_t statement is used to provide dhcpd with enough
- information to tell whether or not an IP address is on
- that subnet. It may also be used to provide subnet-
- specific parameters and to specify what addresses may be
- dynamically allocated to clients booting on that subnet.
- Such addresses are specified using the _r_a_n_g_e declaration.
-
- The _s_u_b_n_e_t_-_n_u_m_b_e_r should be an IP address or domain name
- which resolves to the subnet number of the subnet being
- described. The _n_e_t_m_a_s_k should be an IP address or domain
- name which resolves to the subnet mask of the subnet being
- described. The subnet number, together with the netmask,
- are sufficient to determine whether any given IP address
- is on the specified subnet.
-
- Although a netmask must be given with every subnet decla-
- ration, it is recommended that if there is any variance in
- subnet masks at a site, a subnet-mask option statement be
- used in each subnet declaration to set the desired subnet
- mask, since any subnet-mask option statement will override
- the subnet mask declared in the subnet statement.
-
- TThhee _r_a_n_g_e ssttaatteemmeenntt
-
- rraannggee [ ddyynnaammiicc--bboooottpp ] _l_o_w_-_a_d_d_r_e_s_s [ _h_i_g_h_-_a_d_d_r_e_s_s];;
-
- For any subnet on which addresses will be assigned
-
-
-
- 6
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- dynamically, there must be at least one _r_a_n_g_e statement.
- The range statement gives the lowest and highest IP
- addresses in a range. All IP addresses in the range
- should be in the subnet in which the _r_a_n_g_e statement is
- declared. The _d_y_n_a_m_i_c_-_b_o_o_t_p flag may be specified if
- addresses in the specified range may be dynamically
- assigned to BOOTP clients as well as DHCP clients. When
- specifying a single address, _h_i_g_h_-_a_d_d_r_e_s_s can be omitted.
-
- TThhee _h_o_s_t ssttaatteemmeenntt
-
- hhoosstt _h_o_s_t_n_a_m_e {
- [ _p_a_r_a_m_e_t_e_r_s ]
- [ _d_e_c_l_a_r_a_t_i_o_n_s ]
- }}
-
- There must be at least one hhoosstt statement for every BOOTP
- client that is to be served. hhoosstt statements may also be
- specified for DHCP clients, although this is not required
- unless booting is only enabled for known hosts.
-
- If it is desirable to be able to boot a DHCP or BOOTP
- client on more than one subnet with fixed addresses, more
- than one address may be specified in the _f_i_x_e_d_-_a_d_d_r_e_s_s
- parameter, or more than one hhoosstt statement may be speci-
- fied.
-
- If client-specific boot parameters must change based on
- the network to which the client is attached, then multiple
- hhoosstt statements should be used.
-
- If a client is to be booted using a fixed address if it's
- possible, but should be allocated a dynamic address other-
- wise, then a hhoosstt statement must be specified without a
- ffiixxeedd--aaddddrreessss clause. _h_o_s_t_n_a_m_e should be a name identify-
- ing the host. If a _h_o_s_t_n_a_m_e option is not specified for
- the host, _h_o_s_t_n_a_m_e is used.
-
- _H_o_s_t declarations are matched to actual DHCP or BOOTP
- clients by matching the dhcp-client-identifier option
- specified in the _h_o_s_t declaration to the one supplied by
- the client, or, if the _h_o_s_t declaration or the client does
- not provide a dhcp-client-identifier option, by matching
- the _h_a_r_d_w_a_r_e parameter in the _h_o_s_t declaration to the net-
- work hardware address supplied by the client. BOOTP
- clients do not normally provide a _d_h_c_p_-_c_l_i_e_n_t_-_i_d_e_n_t_i_f_i_e_r,
- so the hardware address must be used for all clients that
- may boot using the BOOTP protocol.
-
- TThhee _g_r_o_u_p ssttaatteemmeenntt
-
- ggrroouupp {
- [ _p_a_r_a_m_e_t_e_r_s ]
- [ _d_e_c_l_a_r_a_t_i_o_n_s ]
-
-
-
- 7
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- }}
-
- The group statement is used simply to apply one or more
- parameters to a group of declarations. It can be used to
- group hosts, shared networks, subnets, or even other
- groups.
-
-RREEFFEERREENNCCEE:: PPAARRAAMMEETTEERRSS
- TThhee _d_e_f_a_u_l_t_-_l_e_a_s_e_-_t_i_m_e ssttaatteemmeenntt
-
- ddeeffaauulltt--lleeaassee--ttiimmee _t_i_m_e;;
-
- _T_i_m_e should be the length in seconds that will be assigned
- to a lease if the client requesting the lease does not ask
- for a specific expiration time.
-
- TThhee _m_a_x_-_l_e_a_s_e_-_t_i_m_e ssttaatteemmeenntt
-
- mmaaxx--lleeaassee--ttiimmee _t_i_m_e;;
-
- _T_i_m_e should be the maximum length in seconds that will be
- assigned to a lease if the client requesting the lease
- asks for a specific expiration time.
-
- TThhee _h_a_r_d_w_a_r_e ssttaatteemmeenntt
-
- hhaarrddwwaarree _h_a_r_d_w_a_r_e_-_t_y_p_e _h_a_r_d_w_a_r_e_-_a_d_d_r_e_s_s;;
-
- In order for a BOOTP client to be recognized, its network
- hardware address must be declared using a _h_a_r_d_w_a_r_e clause
- in the _h_o_s_t statement. _h_a_r_d_w_a_r_e_-_t_y_p_e must be the name of
- a physical hardware interface type. Currently, only the
- eetthheerrnneett type is recognized, although support for ttookkeenn--
- rriinngg and ffddddii hardware types would also be desirable. The
- _h_a_r_d_w_a_r_e_-_a_d_d_r_e_s_s should be a set of hexadecimal octets
- (numbers from 0 through ff) seperated by colons. The
- _h_a_r_d_w_a_r_e_f_R _s_t_a_t_e_m_e_n_t _m_a_y _a_l_s_o _b_e _u_s_e_d _f_o_r _D_H_C_P _c_l_i_e_n_t_s_.
-
- TThhee _f_i_l_e_n_a_m_e ssttaatteemmeenntt
-
- ffiilleennaammee ""_f_i_l_e_n_a_m_e"";;
-
- The _f_i_l_e_n_a_m_e statement can be used to specify the name of
- the initial boot file which is to be loaded by a client.
- The _f_i_l_e_n_a_m_e should be a filename recognizable to whatever
- file transfer protocol the client can be expected to use
- to load the file.
-
- TThhee _s_e_r_v_e_r_-_n_a_m_e ssttaatteemmeenntt
-
- sseerrvveerr--nnaammee ""_n_a_m_e"";;
-
- The _s_e_r_v_e_r_-_n_a_m_e statement can be used to inform the client
- of the name of the server from which it is booting. _N_a_m_e
-
-
-
- 8
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- should be the name that will be provided to the client.
-
- TThhee _n_e_x_t_-_s_e_r_v_e_r ssttaatteemmeenntt
-
- nneexxtt--sseerrvveerr _s_e_r_v_e_r_-_n_a_m_e;;
-
- The _n_e_x_t_-_s_e_r_v_e_r statement is used to specify the host
- address of the server from which the initial boot file
- (specified in the _f_i_l_e_n_a_m_e statement) is to be loaded.
- _S_e_r_v_e_r_-_n_a_m_e should be a numeric IP address or a domain
- name. If no _n_e_x_t_-_s_e_r_v_e_r parameter applies to a given
- client, the address specified in the _s_e_r_v_e_r_-_i_d_e_n_t_i_f_i_e_r
- statement is used.
-
- TThhee _f_i_x_e_d_-_a_d_d_r_e_s_s ssttaatteemmeenntt
-
- ffiixxeedd--aaddddrreessss _a_d_d_r_e_s_s [,, _a_d_d_r_e_s_s ... ];;
-
- The _f_i_x_e_d_-_a_d_d_r_e_s_s statement is used to assign one or more
- fixed IP addresses to a client. It should only appear in
- a _h_o_s_t declaration. If more than one address is supplied,
- then when the client boots, it will be assigned the
- address which corresponds to the network on which it is
- booting. If none of the addresses in the _f_i_x_e_d_-_a_d_d_r_e_s_s
- statement are on the network on which the client is boot-
- ing, that client will not match the _h_o_s_t declaration con-
- taining that _f_i_x_e_d_-_a_d_d_r_e_s_s statement. Each _a_d_d_r_e_s_s should
- be either an IP address or a domain name which resolves to
- one or more IP addresses.
-
- TThhee _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_c_u_t_o_f_f ssttaatteemmeenntt
-
- ddyynnaammiicc--bboooottpp--lleeaassee--ccuuttooffff _d_a_t_e;;
-
- The _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_c_u_t_o_f_f statement sets the ending
- time for all leases assigned dynamically to BOOTP clients.
- Because BOOTP clients do not have any way of renewing
- leases, and don't know that their leases could expire, by
- default dhcpd assignes infinite leases to all BOOTP
- clients. However, it may make sense in some situations to
- set a cutoff date for all BOOTP leases - for example, the
- end of a school term, or the time at night when a facility
- is closed and all machines are required to be powered off.
-
- _D_a_t_e should be the date on which all assigned BOOTP leases
- will end. The date is specified in the form:
-
- W YYYY/MM/DD HH:MM:SS
-
- W is the day of the week expressed as a number from zero
- (Sunday) to six (Saturday). YYYY is the year, including
- the century. MM is the month expressed as a number from 1
- to 12. DD is the day of the month, counting from 1. HH
- is the hour, from zero to 23. MM is the minute and SS is
-
-
-
- 9
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- the second. The time is always in Greenwich Mean Time
- (GMT), not local time.
-
- TThhee _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_l_e_n_g_t_h ssttaatteemmeenntt
-
- ddyynnaammiicc--bboooottpp--lleeaassee--lleennggtthh _l_e_n_g_t_h;;
-
- The _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_l_e_n_g_t_h statement is used to set
- the length of leases dynamically assigned to BOOTP
- clients. At some sites, it may be possible to assume
- that a lease is no longer in use if its holder has not
- used BOOTP or DHCP to get its address within a certain
- time period. The period is specified in _l_e_n_g_t_h as a num-
- ber of seconds. If a client reboots using BOOTP during
- the timeout period, the lease duration is reset to _l_e_n_g_t_h,
- so a BOOTP client that boots frequently enough will never
- lose its lease. Needless to say, this parameter should be
- adjusted with extreme caution.
-
- TThhee _b_o_o_t_-_u_n_k_n_o_w_n_-_c_l_i_e_n_t_s ssttaatteemmeenntt
-
- bboooott--uunnkknnoowwnn--cclliieennttss _f_l_a_g;;
-
- The _b_o_o_t_-_u_n_k_n_o_w_n_-_c_l_i_e_n_t_s statement is used to tell dhcpd
- whether or not to dynamically assign addresses to unknown
- clients. If _f_l_a_g is true (the default), then addresses
- are dynamically assigned to unknown clients when avail-
- able. If _f_l_a_g is false, then addresses are provided only
- to clients which match at least one host declaration.
-
- TThhee _g_e_t_-_l_e_a_s_e_-_h_o_s_t_n_a_m_e_s ssttaatteemmeenntt
-
- ggeett--lleeaassee--hhoossttnnaammeess _f_l_a_g;;
-
- The _g_e_t_-_l_e_a_s_e_-_h_o_s_t_n_a_m_e_s statement is used to tell dhcpd
- whether or not to look up the domain name corresponding to
- the IP address of each address in the lease pool and use
- that address for the DHCP _h_o_s_t_n_a_m_e option. If _f_l_a_g is
- true, then this lookup is done for all addresses in the
- current scope. By default, or if _f_l_a_g is false, no
- lookups are done.
-
- TThhee _u_s_e_-_h_o_s_t_-_d_e_c_l_-_n_a_m_e_s ssttaatteemmeenntt
-
- uussee--hhoosstt--ddeeccll--nnaammeess _f_l_a_g;;
-
- If the _u_s_e_-_h_o_s_t_-_d_e_c_l_-_n_a_m_e_s parameter is true in a given
- scope, then for every host declaration within that scope,
- the name provided for the host declaration will be sup-
- plied to the client as its hostname. So, for example,
-
- group {
- use-host-decl-names on;
-
-
-
-
- 10
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- host joe {
- hardware ethernet 08:00:2b:4c:29:32;
- fixed-address joe.fugue.com;
- }
- }
-
- is equivalent to
-
- host joe {
- hardware ethernet 08:00:2b:4c:29:32;
- fixed-address joe.fugue.com;
- option host-name "joe";
- }
-
- An _o_p_t_i_o_n _h_o_s_t_-_n_a_m_e statement within a host declaration
- will override the use of the name in the host declaration.
-
-RREEFFEERREENNCCEE:: OOPPTTIIOONN SSTTAATTEEMMEENNTTSS
- DHCP _o_p_t_i_o_n statements always start with the _o_p_t_i_o_n key-
- word, 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.
-
- Option data comes in a variety of formats, as defined
- below:
-
- The iipp--aaddddrreessss 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.
-
- The iinntt3322 data type specifies a signed 32-bit integer.
- The uuiinntt3322 data type specifies an unsigned 32-bit integer.
- The iinntt1166 and uuiinntt1166 data types specify signed and
- unsigned 16-bit integers. The iinntt88 and uuiinntt88 data types
- specify signed and unsigned 8-bit integers. Unsigned
- 8-bit integers are also sometimes referred to as octets.
-
- The ssttrriinngg data type specifies an NVT ASCII string, which
- must be enclosed in double quotes - for example, to spec-
- ify a domain-name option, the syntax would be
-
- option domain-name "isc.org";
-
- The ffllaagg data type specifies a boolean value. Booleans
- can be either true or false (or on or off, if that makes
- more sense to you).
-
- The ddaattaa--ssttrriinngg data type specifies either an NVT ASCII
- string enclosed in double quotes, or a series of octets
- specified in hexadecimal, seperated by colons. For
-
-
-
- 11
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- example:
-
- option client-identifier "CLIENT-FOO";
- or
- option client-identifier 43:4c:49:45:54:2d:46:4f:4f;
-
- The documentation for the various options mentioned below
- is taken from the latest IETF draft document on DHCP
- options. Options which are not listed by name may be
- defined by the name option-_n_n_n, where _n_n_n _i_s _t_h_e _d_e_c_i_m_a_l
- _n_u_m_b_e_r _o_f _t_h_e _o_p_t_i_o_n _c_o_d_e_. _T_h_e_s_e _o_p_t_i_o_n_s _m_a_y _b_e _f_o_l_l_o_w_e_d
- _e_i_t_h_e_r _b_y _a _s_t_r_i_n_g_, _e_n_c_l_o_s_e_d _i_n _q_u_o_t_e_s_, _o_r _b_y _a _s_e_r_i_e_s _o_f
- _o_c_t_e_t_s_, _e_x_p_r_e_s_s_e_d _a_s _t_w_o_-_d_i_g_i_t _h_e_x_a_d_e_c_i_m_a_l _n_u_m_b_e_r_s _s_e_p_e_r_-
- _a_t_e_d _b_y _c_o_l_o_n_s_. _F_o_r _e_x_a_m_p_l_e_:
-
- option option-133 "my-option-133-text";
- option option-129 1:54:c9:2b:47;
-
- Because dhcpd does not know the format of these undefined
- option codes, no checking is done to ensure the correct-
- ness of the entered data.
-
- The standard options are:
-
- ooppttiioonn ssuubbnneett--mmaasskk _i_p_-_a_d_d_r_e_s_s;;
-
- The subnet mask option specifies the client's subnet mask
- as per RFC 950. If no subnet mask option is provided any-
- where 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, _a_n_y subnet-mask
- option declaration that is in scope for the address being
- assigned will override the subnet mask specified in the
- subnet declaration.
-
- ooppttiioonn ttiimmee--ooffffsseett _i_n_t_3_2;;
-
- The time-offset option specifies the offset of the
- client's subnet in seconds from Coordinated Universal Time
- (UTC).
-
- ooppttiioonn rroouutteerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ... ];;
-
- The routers option specifies a list of IP addresses for
- routers on the client's subnet. Routers should be listed
- in order of preference.
-
- ooppttiioonn ttiimmee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s _[_, _i_p_-_a_d_d_r_e_s_s ... ];;
-
- The time-server option specifies a list of RFC 868 time
- servers available to the client. Servers should be listed
- in order of preference.
-
- ooppttiioonn nnaammee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ... ];
-
-
-
- 12
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- The name-servers option specifies a list of IEN 116 name
- servers available to the client. Servers should be listed
- in order of preference.
-
- ooppttiioonn ddoommaaiinn--nnaammee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ...
- ];;
-
- 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 prefer-
- ence.
-
- ooppttiioonn lloogg--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ... ];;
-
- 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.
-
- ooppttiioonn ccooookkiiee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ... ];;
-
- The cookie server option specifies a list of RFC 865
- cookie servers available to the client. Servers should be
- listed in order of preference.
-
- ooppttiioonn llpprr--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ... ];;
-
- 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.
-
- ooppttiioonn iimmpprreessss--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ... ];;
-
- The impress-server option specifies a list of Imagen
- Impress servers available to the client. Servers should
- be listed in order of preference.
-
- ooppttiioonn rreessoouurrccee--llooccaattiioonn--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s
- ... ];;
-
- This option specifies a list of RFC 887 Resource Location
- servers available to the client. Servers should be listed
- in order of preference.
-
- ooppttiioonn hhoosstt--nnaammee _s_t_r_i_n_g;;
-
- 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 restric-
- tions.
-
- ooppttiioonn bboooott--ssiizzee _u_i_n_t_1_6;;
-
- This option specifies the length in 512-octet blocks of
-
-
-
- 13
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- the default boot image for the client.
-
- ooppttiioonn mmeerriitt--dduummpp _s_t_r_i_n_g;;
-
- 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 charac-
- ter set.
-
- ooppttiioonn ddoommaaiinn--nnaammee _s_t_r_i_n_g;;
-
- This option specifies the domain name that client should
- use when resolving hostnames via the Domain Name System.
-
- ooppttiioonn sswwaapp--sseerrvveerr _i_p_-_a_d_d_r_e_s_s;;
-
- This specifies the IP address of the client's swap server.
-
- ooppttiioonn rroooott--ppaatthh _s_t_r_i_n_g;;
-
- 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 charac-
- ter set.
-
- ooppttiioonn iipp--ffoorrwwaarrddiinngg _f_l_a_g;;
-
- This option specifies whether the client should configure
- its IP layer for packet forwarding. A value of 0 means
- disable IP forwarding, and a value of 1 means enable IP
- forwarding.
-
- ooppttiioonn nnoonn--llooccaall--ssoouurrccee--rroouuttiinngg _f_l_a_g;;
-
- 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 dis-
- cussion of this topic). A value of 0 means disallow for-
- warding of such datagrams, and a value of 1 means allow
- forwarding.
-
- ooppttiioonn ppoolliiccyy--ffiilltteerr _i_p_-_a_d_d_r_e_s_s _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s
- _i_p_-_a_d_d_r_e_s_s ... ];;
-
- 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.
-
- Any source routed datagram whose next-hop address does not
- match one of the filters should be discarded by the
- client.
-
-
-
-
- 14
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- See STD 3 (RFC1122) for further information.
-
- ooppttiioonn mmaaxx--ddggrraamm--rreeaasssseemmbbllyy _u_i_n_t_1_6;;
-
- This option specifies the maximum size datagram that the
- client should be prepared to reassemble. The minimum
- value legal value is 576.
-
- ooppttiioonn ddeeffaauulltt--iipp--ttttll _u_i_n_t_8_;
-
- This option specifies the default time-to-live that the
- client should use on outgoing datagrams.
-
- ooppttiioonn ppaatthh--mmttuu--aaggiinngg--ttiimmeeoouutt _u_i_n_t_3_2;;
-
- This option specifies the timeout (in seconds) to use when
- aging Path MTU values discovered by the mechanism defined
- in RFC 1191.
-
- ooppttiioonn ppaatthh--mmttuu--ppllaatteeaauu--ttaabbllee _u_i_n_t_1_6 [,, _u_i_n_t_1_6 ... ];;
-
- 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.
-
- ooppttiioonn iinntteerrffaaccee--mmttuu _u_i_n_t_1_6;;
-
- This option specifies the MTU to use on this interface.
- The minimum legal value for the MTU is 68.
-
- ooppttiioonn aallll--ssuubbnneettss--llooccaall _f_l_a_g;;
-
- 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 1
- indicates that all subnets share the same MTU. A value of
- 0 means that the client should assume that some subnets of
- the directly connected network may have smaller MTUs.
-
- ooppttiioonn bbrrooaaddccaasstt--aaddddrreessss _i_p_-_a_d_d_r_e_s_s;;
-
- 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).
-
- ooppttiioonn ppeerrffoorrmm--mmaasskk--ddiissccoovveerryy _f_l_a_g;;
-
- This option specifies whether or not the client should
- perform subnet mask discovery using ICMP. A value of 0
- indicates that the client should not perform mask discov-
- ery. A value of 1 means that the client should perform
-
-
-
- 15
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- mask discovery.
-
- ooppttiioonn mmaasskk--ssuupppplliieerr _f_l_a_g;;
-
- This option specifies whether or not the client should
- respond to subnet mask requests using ICMP. A value of 0
- indicates that the client should not respond. A value of
- 1 means that the client should respond.
-
- ooppttiioonn rroouutteerr--ddiissccoovveerryy _f_l_a_g;;
-
- This option specifies whether or not the client should
- solicit routers using the Router Discovery mechanism
- defined in RFC 1256. A value of 0 indicates that the
- client should not perform router discovery. A value of 1
- means that the client should perform router discovery.
-
- ooppttiioonn rroouutteerr--ssoolliicciittaattiioonn--aaddddrreessss _i_p_-_a_d_d_r_e_s_s;;
-
- This option specifies the address to which the client
- should transmit router solicitation requests.
-
- ooppttiioonn ssttaattiicc--rroouutteess _i_p_-_a_d_d_r_e_s_s _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s
- _i_p_-_a_d_d_r_e_s_s ... ];;
-
- 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.
-
- 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.
-
- The default route (0.0.0.0) is an illegal destination for
- a static route. To specify the default route, use the
- rroouutteerrss option.
-
- ooppttiioonn ttrraaiilleerr--eennccaappssuullaattiioonn _f_l_a_g;;
-
- This option specifies whether or not the client should
- negotiate the use of trailers (RFC 893 [14]) when using
- the ARP protocol. A value of 0 indicates that the client
- should not attempt to use trailers. A value of 1 means
- that the client should attempt to use trailers.
-
- ooppttiioonn aarrpp--ccaacchhee--ttiimmeeoouutt _u_i_n_t_3_2;;
-
- This option specifies the timeout in seconds for ARP cache
- entries.
-
- ooppttiioonn iieeeeee880022--33--eennccaappssuullaattiioonn _f_l_a_g;;
-
- This option specifies whether or not the client should use
-
-
-
- 16
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- Ethernet Version 2 (RFC 894) or IEEE 802.3 (RFC 1042)
- encapsulation if the interface is an Ethernet. A value of
- 0 indicates that the client should use RFC 894 encapsula-
- tion. A value of 1 means that the client should use RFC
- 1042 encapsulation.
-
- ooppttiioonn ddeeffaauulltt--ttccpp--ttttll _u_i_n_t_8;;
-
- This option specifies the default TTL that the client
- should use when sending TCP segments. The minimum value
- is 1.
-
- ooppttiioonn ttccpp--kkeeeeppaalliivvee--iinntteerrvvaall _u_i_n_t_3_2;;
-
- 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 connec-
- tions unless specifically requested by an application.
-
- ooppttiioonn ttccpp--kkeeeeppaalliivvee--ggaarrbbaaggee _f_l_a_g;;
-
- This option specifies the whether or not the client should
- send TCP keepalive messages with a octet of garbage for
- compatibility with older implementations. A value of 0
- indicates that a garbage octet should not be sent. A value
- of 1 indicates that a garbage octet should be sent.
-
- ooppttiioonn nniiss--ddoommaaiinn _s_t_r_i_n_g;;
-
- This option specifies the name of the client's NIS (Sun
- Network Information Services) domain. The domain is for-
- matted as a character string consisting of characters from
- the NVT ASCII character set.
-
- ooppttiioonn nniiss--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ... ];;
-
- This option specifies a list of IP addresses indicating
- NIS servers available to the client. Servers should be
- listed in order of preference.
-
- ooppttiioonn nnttpp--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ... ];;
-
- 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.
-
- ooppttiioonn nneettbbiiooss--nnaammee--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ...
- ];;
-
- The NetBIOS name server (NBNS) option specifies a list of
- RFC 1001/1002 NBNS name servers listed in order of prefer-
- ence.
-
-
-
- 17
-
-
-
-
-
-dhcpd.conf(5) dhcpd.conf(5)
-
-
- ooppttiioonn nneettbbiiooss--dddd--sseerrvveerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ... ];;
-
- The NetBIOS datagram distribution server (NBDD) option
- specifies a list of RFC 1001/1002 NBDD servers listed in
- order of preference.
-
- ooppttiioonn nneettbbiiooss--nnooddee--ttyyppee _u_i_n_t_8;;
-
- The NetBIOS node type option allows NetBIOS over TCP/IP
- clients which are configurable to be configured as
- described in RFC 1001/1002. The value is specified as a
- single octet which identifies the client type. A value of
- 1 corresponds to a NetBIOS B-node; a value of 2 corre-
- sponds to a P-node; a value of 4 corresponds to an M-node;
- a value of 8 corresponds to an H-node.
-
- ooppttiioonn nneettbbiiooss--ssccooppee _s_t_r_i_n_g;;
-
- 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 charac-
- ter-set restrictions.
-
- ooppttiioonn ffoonntt--sseerrvveerrss _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ... ];;
-
- This option specifies a list of X Window System Font
- servers available to the client. Servers should be listed
- in order of preference.
-
- ooppttiioonn xx--ddiissppllaayy--mmaannaaggeerr _i_p_-_a_d_d_r_e_s_s [,, _i_p_-_a_d_d_r_e_s_s ... ];;
-
- 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 pref-
- erence.
-
- ooppttiioonn ddhhccpp--cclliieenntt--iiddeennttiiffiieerr _d_a_t_a_-_s_t_r_i_n_g;;
-
- This option can be used to specify the a DHCP client iden-
- tifier in a host declaration, so that dhcpd can find the
- host record by matching against the client identifier.
-
-SSEEEE AALLSSOO
- dhcpd.conf(5), dhcpd.leases(5), draft-ietf-dhc-
- options-1533update-04.txt, draft-ietf-dhc-dhcp-07.txt.
-
-AAUUTTHHOORR
- ddhhccppdd((88)) was written by Ted Lemon <mellon@vix.com> under a
- contract with Vixie Labs. Funding for this project was
- provided by the Internet Software Corporation. Informa-
- tion about the Internet Software Consortium can be found
- at hhttttpp::////wwwwww..iisscc..oorrgg//iisscc..
-
-
-
-
-
- 18
-
-