From 773a3f13fa84e2ac117a495c98747db4b65a0ee1 Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Oct 23 2007 19:04:57 +0000 Subject: - Upgrade to ISC dhcp-3.1.0 - Remove unnecessary /usr/include/dhcp4client/isc_dhcp headers - Make sure restorecon is run on /var/lib/dhcpd/dhcpd.leases (#251688) - Install dhcp.schema to /etc/openldap/dhcp.schema (#330471) --- diff --git a/.cvsignore b/.cvsignore index c2ae9d1..38577ea 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1 @@ -dhcp-3.0.6.tar.gz +dhcp-3.1.0.tar.gz diff --git a/Makefile.dist b/Makefile.dist index c2c70dd..4d713a6 100644 --- a/Makefile.dist +++ b/Makefile.dist @@ -43,6 +43,13 @@ MINIRES_SRCS = minires_ns_date.c minires_ns_name.c minires_ns_parse.c \ minires_res_mkupdate.c minires_res_query.c minires_res_send.c \ minires_res_sendsigned.c minires_res_update.c +# ISC dhcp headers we need to copy to /usr/include/dhcp4client +DHCP_HEADERS = dhcpd.h cdefs.h osdep.h arpa/nameser.h minires/minires.h \ + site.h cf/linux.h dhcp.h statement.h tree.h inet.h dhctoken.h \ + omapip/omapip_p.h failover.h ctrace.h minires/resolv.h \ + minires/res_update.h omapip/convert.h omapip/hash.h \ + omapip/trace.h + HDRS = dhcp4client.h libdhcp_control.h SRCS = $(COMMON_SRCS) $(CLIENT_SRCS) OBJS = $(SRCS:.c=.o) @@ -59,11 +66,9 @@ install: all install -p -m 0644 -D libdhcp4client.a $(DESTDIR)$(LIBDIR)/libdhcp4client.a install -p -m 0644 -D dhcp4client.h $(DESTDIR)$(INCDIR)/dhcp4client/dhcp4client.h install -p -m 0644 -D libdhcp_control.h $(DESTDIR)$(INCDIR)/dhcp4client/libdhcp_control.h - ( cd $(TOP)/includes ; \ - find . -name "*.h" -type f | while read h ; do \ - install -p -m 0644 -D $$h $(DESTDIR)$(INCDIR)/dhcp4client/isc_dhcp/$$h ; \ - done ; \ - ) + for hdr in $(DHCP_HEADERS) ; do \ + install -p -m 0644 -D $(TOP)/includes/$${hdr} $(DESTDIR)$(INCDIR)/dhcp4client/$${hdr} ; \ + done depend: $(MKDEP) $(INCLUDES) $(PREDEFINES) $(SRCS) diff --git a/dhcp-3.0.5-dhclient-anycast.patch b/dhcp-3.0.5-dhclient-anycast.patch deleted file mode 100644 index 764a98f..0000000 --- a/dhcp-3.0.5-dhclient-anycast.patch +++ /dev/null @@ -1,76 +0,0 @@ ---- dhcp-3.0.5/client/clparse.c.anycast 2007-06-18 10:53:24.000000000 -0400 -+++ dhcp-3.0.5/client/clparse.c 2007-06-18 10:53:24.000000000 -0400 -@@ -402,6 +402,17 @@ void parse_client_statement (cfile, ip, - } - return; - -+ case ANYCAST_MAC: -+ token = next_token (&val, (unsigned *)0, cfile); -+ if (ip) { -+ parse_hardware_param (cfile, &ip -> anycast_mac_addr); -+ } else { -+ parse_warn (cfile, "anycast mac address parameter %s", -+ "not allowed here."); -+ skip_to_semi (cfile); -+ } -+ return; -+ - case REQUEST: - token = next_token (&val, (unsigned *)0, cfile); - if (config -> requested_options == default_requested_options) ---- dhcp-3.0.5/common/conflex.c.anycast 2007-06-18 10:53:24.000000000 -0400 -+++ dhcp-3.0.5/common/conflex.c 2007-06-18 10:53:24.000000000 -0400 -@@ -549,6 +549,8 @@ static enum dhcp_token intern (atom, dfv - } - if (!strcasecmp (atom + 1, "nd")) - return AND; -+ if (!strcasecmp (atom + 1, "nycast-mac")) -+ return ANYCAST_MAC; - if (!strcasecmp (atom + 1, "ppend")) - return APPEND; - if (!strcasecmp (atom + 1, "llow")) ---- dhcp-3.0.5/common/lpf.c.anycast 2007-06-18 10:53:24.000000000 -0400 -+++ dhcp-3.0.5/common/lpf.c 2007-06-18 10:53:48.000000000 -0400 -@@ -332,6 +332,9 @@ ssize_t send_packet (interface, packet, - return send_fallback (interface, packet, raw, - len, from, to, hto); - -+ if (hto == NULL && interface->anycast_mac_addr.hlen) -+ hto = &interface->anycast_mac_addr; -+ - /* Assemble the headers... */ - assemble_hw_header (interface, (unsigned char *)hh, &hbufp, hto); - fudge = hbufp % 4; /* IP header must be word-aligned. */ ---- dhcp-3.0.5/includes/dhctoken.h.anycast 2007-06-18 10:53:24.000000000 -0400 -+++ dhcp-3.0.5/includes/dhctoken.h 2007-06-18 10:53:24.000000000 -0400 -@@ -310,7 +310,8 @@ enum dhcp_token { - DO_FORWARD_UPDATE = 614, - KNOWN_CLIENTS = 615, - ATSFP = 616, -- BOOTP_BROADCAST_ALWAYS = 617 -+ BOOTP_BROADCAST_ALWAYS = 617, -+ ANYCAST_MAC = 618 - }; - - #define is_identifier(x) ((x) >= FIRST_TOKEN && \ ---- dhcp-3.0.5/includes/site.h.anycast 2007-06-18 10:53:24.000000000 -0400 -+++ dhcp-3.0.5/includes/site.h 2007-06-18 10:53:24.000000000 -0400 -@@ -178,6 +178,8 @@ - - #define TRACING - -+#define USE_LPF -+ - /* Define this if you want to read your config from LDAP. Read README.ldap - about how to set this up */ - ---- dhcp-3.0.5/includes/dhcpd.h.anycast 2007-06-18 10:53:24.000000000 -0400 -+++ dhcp-3.0.5/includes/dhcpd.h 2007-06-18 10:53:24.000000000 -0400 -@@ -845,6 +845,7 @@ struct interface_info { - int dlpi_sap_length; - struct hardware dlpi_broadcast_addr; - # endif /* DLPI_SEND || DLPI_RECEIVE */ -+ struct hardware anycast_mac_addr; - }; - - struct hardware_link { diff --git a/dhcp-3.0.5-ldap-configuration.patch b/dhcp-3.0.5-ldap-configuration.patch deleted file mode 100644 index 09028d7..0000000 --- a/dhcp-3.0.5-ldap-configuration.patch +++ /dev/null @@ -1,1489 +0,0 @@ ---- dhcp-3.0.5/common/conflex.c.ldap 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/common/conflex.c 2007-03-29 15:11:19.000000000 -0400 -@@ -47,6 +47,7 @@ - static enum dhcp_token read_number PROTO ((int, struct parse *)); - static enum dhcp_token read_num_or_name PROTO ((int, struct parse *)); - static enum dhcp_token intern PROTO ((char *, enum dhcp_token)); -+static int read_function PROTO ((struct parse *)); - - isc_result_t new_parse (cfile, file, inbuf, buflen, name, eolp) - struct parse **cfile; -@@ -74,6 +75,10 @@ - tmp -> file = file; - tmp -> eol_token = eolp; - -+ if (file != -1) { -+ tmp -> read_function = read_function;; -+ } -+ - tmp -> bufix = 0; - tmp -> buflen = buflen; - if (inbuf) { -@@ -113,22 +118,11 @@ - int c; - - if (cfile -> bufix == cfile -> buflen) { -- if (cfile -> file != -1) { -- cfile -> buflen = -- read (cfile -> file, -- cfile -> inbuf, cfile -> bufsiz); -- if (cfile -> buflen == 0) { -- c = EOF; -- cfile -> bufix = 0; -- } else if (cfile -> buflen < 0) { -- c = EOF; -- cfile -> bufix = cfile -> buflen = 0; -- } else { -- c = cfile -> inbuf [0]; -- cfile -> bufix = 1; -- } -- } else -+ if (cfile -> read_function) { -+ c = cfile -> read_function (cfile); -+ } else { - c = EOF; -+ } - } else { - c = cfile -> inbuf [cfile -> bufix]; - cfile -> bufix++; -@@ -1128,3 +1122,25 @@ - } - return dfv; - } -+ -+ -+static int -+read_function (struct parse * cfile) -+{ -+ int c; -+ -+ cfile -> buflen = read (cfile -> file, cfile -> inbuf, cfile -> bufsiz); -+ if (cfile -> buflen == 0) { -+ c = EOF; -+ cfile -> bufix = 0; -+ } else if (cfile -> buflen < 0) { -+ c = EOF; -+ cfile -> bufix = cfile -> buflen = 0; -+ } else { -+ c = cfile -> inbuf [0]; -+ cfile -> bufix = 1; -+ } -+ -+ return c; -+} -+ ---- dhcp-3.0.5/common/print.c.ldap 2007-03-29 15:10:26.000000000 -0400 -+++ dhcp-3.0.5/common/print.c 2007-03-29 15:11:19.000000000 -0400 -@@ -166,9 +166,9 @@ - } - - char *print_hw_addr (htype, hlen, data) -- int htype; -- int hlen; -- unsigned char *data; -+ const int htype; -+ const int hlen; -+ const unsigned char *data; - { - static char habuf [49]; - char *s; ---- dhcp-3.0.5/includes/dhcpd.h.ldap 2007-03-29 15:10:26.000000000 -0400 -+++ dhcp-3.0.5/includes/dhcpd.h 2007-03-29 15:11:19.000000000 -0400 -@@ -79,6 +79,11 @@ - #include - #include - -+#if defined(LDAP_CONFIGURATION) -+# include -+# include /* for uname() */ -+#endif -+ - #if !defined (OPTION_HASH_SIZE) - # define OPTION_HASH_SIZE 17 - # define OPTION_HASH_PTWO 32 /* Next power of two above option hash. */ -@@ -139,6 +144,8 @@ - char *inbuf; - unsigned bufix, buflen; - unsigned bufsiz; -+ -+ int (*read_function) (struct parse *); - }; - - /* Variable-length array of data. */ -@@ -244,6 +251,27 @@ - u_int8_t hbuf [17]; - }; - -+#if defined(LDAP_CONFIGURATION) -+# define LDAP_BUFFER_SIZE 8192 -+# define LDAP_METHOD_STATIC 0 -+# define LDAP_METHOD_DYNAMIC 1 -+ -+/* This is a tree of the current configuration we are building from LDAP */ -+ -+struct ldap_config_stack { -+ LDAPMessage * res; /* Pointer returned from ldap_search */ -+ LDAPMessage * ldent; /* Current item in LDAP that we're processing -+ in res */ -+ int close_brace; /* Put a closing } after we're through with -+ this item */ -+ int processed; /* We set this flag if this base item has been -+ processed. After this base item is processed, -+ we can start processing the children */ -+ struct ldap_config_stack *children; -+ struct ldap_config_stack *next; -+}; -+#endif -+ - typedef enum { - server_startup = 0, - server_running = 1, -@@ -426,6 +454,15 @@ - # define DEFAULT_PING_TIMEOUT 1 - #endif - -+#if defined(LDAP_CONFIGURATION) -+# define SV_LDAP_SERVER 47 -+# define SV_LDAP_PORT 48 -+# define SV_LDAP_USERNAME 49 -+# define SV_LDAP_PASSWORD 50 -+# define SV_LDAP_BASE_DN 51 -+# define SV_LDAP_METHOD 52 -+#endif -+ - #if !defined (DEFAULT_DEFAULT_LEASE_TIME) - # define DEFAULT_DEFAULT_LEASE_TIME 43200 - #endif -@@ -1531,7 +1568,7 @@ - char *quotify_string (const char *, const char *, int); - char *quotify_buf (const unsigned char *, unsigned, const char *, int); - char *print_base64 (const unsigned char *, unsigned, const char *, int); --char *print_hw_addr PROTO ((int, int, unsigned char *)); -+char *print_hw_addr PROTO ((const int, const int, const unsigned char *)); - void print_lease PROTO ((struct lease *)); - void dump_raw PROTO ((const unsigned char *, unsigned)); - void dump_packet_option (struct option_cache *, struct packet *, -@@ -2639,3 +2676,14 @@ - #endif /* FAILOVER_PROTOCOL */ - - const char *binding_state_print (enum failover_state); -+ -+/* ldap.c */ -+#if defined(LDAP_CONFIGURATION) -+extern struct enumeration ldap_methods; -+isc_result_t ldap_read_config (void); -+int find_haddr_in_ldap (struct host_decl **, int, unsigned, -+ const unsigned char *, const char *, int); -+int find_subclass_in_ldap (struct class *, struct class **, -+ struct data_string *); -+#endif -+ ---- dhcp-3.0.5/includes/site.h.ldap 2002-03-12 13:33:39.000000000 -0500 -+++ dhcp-3.0.5/includes/site.h 2007-03-29 15:11:19.000000000 -0400 -@@ -177,3 +177,13 @@ - traces. */ - - #define TRACING -+ -+/* Define this if you want to read your config from LDAP. Read README.ldap -+ about how to set this up */ -+ -+#define LDAP_CONFIGURATION -+ -+#define _PATH_DHCPD_DB "/var/lib/dhcpd/dhcpd.leases" -+#define _PATH_DHCLIENT_DB "/var/lib/dhclient/dhclient.leases" -+#define _PATH_DHCPD_DB "/var/lib/dhcpd/dhcpd.leases" -+#define _PATH_DHCLIENT_DB "/var/lib/dhclient/dhclient.leases" ---- dhcp-3.0.5/server/Makefile.dist.ldap 2004-06-10 13:59:50.000000000 -0400 -+++ dhcp-3.0.5/server/Makefile.dist 2007-03-29 15:11:19.000000000 -0400 -@@ -25,9 +25,9 @@ - CATMANPAGES = dhcpd.cat8 dhcpd.conf.cat5 dhcpd.leases.cat5 - SEDMANPAGES = dhcpd.man8 dhcpd.conf.man5 dhcpd.leases.man5 - SRCS = dhcpd.c dhcp.c bootp.c confpars.c db.c class.c failover.c \ -- omapi.c mdb.c stables.c salloc.c ddns.c -+ omapi.c mdb.c stables.c salloc.c ddns.c ldap.c - OBJS = dhcpd.o dhcp.o bootp.o confpars.o db.o class.o failover.o \ -- omapi.o mdb.o stables.o salloc.o ddns.o -+ omapi.o mdb.o stables.o salloc.o ddns.o ldap.o - PROG = dhcpd - MAN = dhcpd.8 dhcpd.conf.5 dhcpd.leases.5 - -@@ -103,6 +103,6 @@ - -e "s#RUNDIR#$(VARRUN)#g" < dhcpd.leases.5 >dhcpd.leases.man5 - - dhcpd: $(OBJS) $(COBJ) $(DHCPLIB) -- $(CC) $(LFLAGS) -o dhcpd $(OBJS) $(DHCPLIB) $(LIBS) -+ $(CC) $(LFLAGS) -o dhcpd $(OBJS) $(DHCPLIB) $(LIBS) -lldap - - # Dependencies (semi-automatically-generated) ---- dhcp-3.0.5/server/class.c.ldap 2004-06-10 13:59:51.000000000 -0400 -+++ dhcp-3.0.5/server/class.c 2007-03-29 15:11:19.000000000 -0400 -@@ -90,6 +90,7 @@ - int matched = 0; - int status; - int ignorep; -+ int classfound; - - for (class = collection -> classes; class; class = class -> nic) { - #if defined (DEBUG_CLASS_MATCHING) -@@ -135,9 +136,19 @@ - class -> submatch, MDL)); - if (status && data.len) { - nc = (struct class *)0; -- if (class_hash_lookup (&nc, class -> hash, -- (const char *)data.data, -- data.len, MDL)) { -+ classfound = class_hash_lookup (&nc, -+ class -> hash, -+ (const char *)data.data, -+ data.len, MDL); -+ -+#ifdef LDAP_CONFIGURATION -+ if (!classfound && -+ find_subclass_in_ldap (class, -+ &nc, &data)) -+ classfound = 1; -+#endif -+ -+ if (classfound) { - #if defined (DEBUG_CLASS_MATCHING) - log_info ("matches subclass %s.", - print_hex_1 (data.len, ---- dhcp-3.0.5/server/confpars.c.ldap 2007-03-29 15:10:26.000000000 -0400 -+++ dhcp-3.0.5/server/confpars.c 2007-03-29 15:11:19.000000000 -0400 -@@ -63,7 +63,17 @@ - - isc_result_t readconf () - { -- return read_conf_file (path_dhcpd_conf, root_group, ROOT_GROUP, 0); -+ isc_result_t res; -+ -+ res = read_conf_file (path_dhcpd_conf, root_group, ROOT_GROUP, 0); -+#if defined(LDAP_CONFIGURATION) -+ if (res != ISC_R_SUCCESS) -+ return (res); -+ -+ return ldap_read_config (); -+#else -+ return (res); -+#endif - } - - isc_result_t read_conf_file (const char *filename, struct group *group, ---- dhcp-3.0.5/server/dhcpd.c.ldap 2007-03-29 15:10:26.000000000 -0400 -+++ dhcp-3.0.5/server/dhcpd.c 2007-03-29 15:11:19.000000000 -0400 -@@ -433,6 +433,9 @@ - /* Add the ddns update style enumeration prior to parsing. */ - add_enumeration (&ddns_styles); - add_enumeration (&syslog_enum); -+#if defined (LDAP_CONFIGURATION) -+ add_enumeration (&ldap_methods); -+#endif - - if (!group_allocate (&root_group, MDL)) - log_fatal ("Can't allocate root group!"); ---- /dev/null 2007-03-29 11:34:09.579686084 -0400 -+++ dhcp-3.0.5/server/ldap.c 2007-03-29 15:11:19.000000000 -0400 -@@ -0,0 +1,1142 @@ -+/* ldap.c -+ -+ Routines for reading the configuration from LDAP */ -+ -+/* -+ * Copyright (c) 1996-2001 Ntelos, Inc. -+ * 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 LDAP module was written by Brian Masney . It's -+ * development was sponsored by Ntelos, Inc. (www.ntelos.com). -+ */ -+ -+#include "dhcpd.h" -+ -+#if defined(LDAP_CONFIGURATION) -+ -+static LDAP * ld = NULL; -+static char *ldap_server = NULL, -+ *ldap_username = NULL, -+ *ldap_password = NULL, -+ *ldap_base_dn = NULL; -+static int ldap_method = LDAP_METHOD_DYNAMIC, -+ disable_ldap = 0; -+static struct ldap_config_stack *ldap_stack = NULL; -+ -+ -+static void -+ldap_parse_class (struct ldap_config_stack *item, struct parse *cfile) -+{ -+ struct berval **temp; -+ -+ if ((temp = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || -+ temp[0]->bv_val == NULL) -+ { -+ if (temp != NULL) -+ ldap_value_free_len (temp); -+ -+ return; -+ } -+ -+ strncat (cfile->inbuf, "class \"", LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, temp[0]->bv_val, LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, "\" {\n", LDAP_BUFFER_SIZE); -+ -+ item->close_brace = 1; -+ ldap_value_free_len (temp); -+} -+ -+ -+static void -+ldap_parse_subclass (struct ldap_config_stack *item, struct parse *cfile) -+{ -+ struct berval **temp, **classdata; -+ -+ if ((temp = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || -+ temp[0]->bv_val == NULL) -+ { -+ if (temp != NULL) -+ ldap_value_free_len (temp); -+ -+ return; -+ } -+ -+ -+ if ((classdata = ldap_get_values_len (ld, item->ldent, -+ "dhcpClassData")) == NULL || -+ classdata[0]->bv_val == NULL) -+ { -+ if (classdata != NULL) -+ ldap_value_free_len (classdata); -+ ldap_value_free_len (temp); -+ -+ return; -+ } -+ -+ strncat (cfile->inbuf, "subclass ", LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, (*classdata)->bv_val, LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, (*temp)->bv_val, LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE); -+ -+ item->close_brace = 1; -+ ldap_value_free_len (temp); -+ ldap_value_free_len (classdata); -+} -+ -+ -+static void -+ldap_parse_host (struct ldap_config_stack *item, struct parse *cfile) -+{ -+ struct berval **temp, **hwaddr; -+ -+ -+ if ((temp = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || -+ temp[0]->bv_val == NULL) -+ { -+ if (temp != NULL) -+ ldap_value_free_len (temp); -+ -+ return; -+ } -+ -+ if ((hwaddr = ldap_get_values_len (ld, item->ldent, -+ "dhcpHWAddress")) == NULL || -+ hwaddr[0]->bv_val == NULL) -+ { -+ if (hwaddr != NULL) -+ ldap_value_free_len (hwaddr); -+ ldap_value_free_len (temp); -+ -+ return; -+ } -+ -+ strncat (cfile->inbuf, "host ", LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, (*temp)->bv_val, LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, " {\nhardware ", LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, (*hwaddr)->bv_val, LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); -+ -+ item->close_brace = 1; -+ ldap_value_free_len (temp); -+ ldap_value_free_len (hwaddr); -+} -+ -+ -+static void -+ldap_parse_shared_network (struct ldap_config_stack *item, struct parse *cfile) -+{ -+ struct berval **temp; -+ -+ -+ if ((temp = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || -+ temp[0]->bv_val == NULL) -+ { -+ if (temp != NULL) -+ ldap_value_free_len (temp); -+ -+ return; -+ } -+ -+ strncat (cfile->inbuf, "shared-network ", LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, (*temp)->bv_val, LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE); -+ -+ item->close_brace = 1; -+ ldap_value_free_len (temp); -+} -+ -+ -+static void -+parse_netmask (int netmask, char *netmaskbuf) -+{ -+ unsigned long nm; -+ int i; -+ -+ nm = 0; -+ for (i=1; i <= netmask; i++) -+ { -+ nm |= 1 << (32 - i); -+ } -+ -+ sprintf (netmaskbuf, "%d.%d.%d.%d", (int) (nm >> 24) & 0xff, -+ (int) (nm >> 16) & 0xff, -+ (int) (nm >> 8) & 0xff, -+ (int) nm & 0xff); -+} -+ -+static void -+ldap_parse_subnet (struct ldap_config_stack *item, struct parse *cfile) -+{ -+ struct berval **temp, **netmask; -+ char netmaskbuf[16]; -+ int i; -+ -+ if ((temp = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || -+ temp[0]->bv_val == NULL) -+ { -+ if (temp != NULL) -+ ldap_value_free_len (temp); -+ -+ return; -+ } -+ -+ if ((netmask = ldap_get_values_len (ld, item->ldent, -+ "dhcpNetmask")) == NULL || -+ netmask[0]->bv_val == NULL) -+ { -+ if (netmask != NULL) -+ ldap_value_free_len (netmask); -+ ldap_value_free_len (temp); -+ -+ return; -+ } -+ -+ strncat (cfile->inbuf, "subnet ", LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, temp[0]->bv_val, LDAP_BUFFER_SIZE); -+ -+ strncat (cfile->inbuf, " netmask ", LDAP_BUFFER_SIZE); -+ parse_netmask (strtol (netmask[0]->bv_val, NULL, 10), netmaskbuf); -+ strncat (cfile->inbuf, netmaskbuf, LDAP_BUFFER_SIZE); -+ -+ strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE); -+ -+ ldap_value_free_len (temp); -+ ldap_value_free_len (netmask); -+ -+ if ((temp = ldap_get_values_len (ld, item->ldent, "dhcpRange")) != NULL) -+ { -+ strncat (cfile->inbuf, "range", LDAP_BUFFER_SIZE); -+ for (i=0; temp[i] != NULL && temp[i]->bv_val != NULL; i++) -+ { -+ strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, temp[i]->bv_val, LDAP_BUFFER_SIZE); -+ } -+ strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); -+ ldap_value_free_len (temp); -+ } -+ -+ item->close_brace = 1; -+} -+ -+ -+static void -+ldap_parse_pool (struct ldap_config_stack *item, struct parse *cfile) -+{ -+ struct berval **temp; -+ int i; -+ -+ strncat (cfile->inbuf, "pool {\n", LDAP_BUFFER_SIZE); -+ -+ if ((temp = ldap_get_values_len (ld, item->ldent, "dhcpRange")) != NULL) -+ { -+ strncat (cfile->inbuf, "range", LDAP_BUFFER_SIZE); -+ for (i=0; temp[i] != NULL && temp[i]->bv_val != NULL; i++) -+ { -+ strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, temp[i]->bv_val, LDAP_BUFFER_SIZE); -+ } -+ strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); -+ ldap_value_free_len (temp); -+ } -+ -+ if ((temp = ldap_get_values_len (ld, item->ldent, "dhcpPermitList")) != NULL) -+ { -+ for (i=0; temp[i] != NULL && temp[i]->bv_val != NULL; i++) -+ { -+ strncat (cfile->inbuf, temp[i]->bv_val, LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); -+ } -+ ldap_value_free_len (temp); -+ } -+ -+ item->close_brace = 1; -+} -+ -+ -+static void -+ldap_parse_group (struct ldap_config_stack *item, struct parse *cfile) -+{ -+ strncat (cfile->inbuf, "group {\n", LDAP_BUFFER_SIZE); -+ item->close_brace = 1; -+} -+ -+ -+static void -+parse_external_dns (LDAPMessage * ent) -+{ -+ char *search[] = {"dhcpOptionsDN", "dhcpSharedNetworkDN", "dhcpSubnetDN", -+ "dhcpGroupDN", "dhcpHostDN", "dhcpClassesDN", -+ "dhcpPoolDN", NULL}; -+ LDAPMessage * newres, * newent; -+ struct ldap_config_stack *ns; -+ struct berval **temp; -+ int i, ret; -+ -+ for (i=0; search[i] != NULL; i++) -+ { -+ if ((ldap_method == LDAP_METHOD_DYNAMIC) && -+ (strcmp (search[i], "dhcpHostDN") == 0)) -+ continue; -+ -+ if ((temp = ldap_get_values_len (ld, ent, search[i])) == NULL) -+ continue; -+ -+ if ((ret = ldap_search_ext_s (ld, temp[0]->bv_val, LDAP_SCOPE_BASE, -+ "objectClass=*", NULL, 0, -+ NULL, NULL, NULL, 0, -+ &newres)) != LDAP_SUCCESS) -+ { -+ ldap_value_free_len (temp); -+ ldap_unbind_ext (ld, NULL, NULL); -+ ld = NULL; -+ return; -+ } -+ -+ ldap_value_free_len (temp); -+ -+ newent = ldap_first_entry (ld, newres); -+ if (newent == NULL) -+ { -+ ldap_msgfree (newres); -+ continue; -+ } -+ -+#if defined(DEBUG_LDAP) -+ log_info ("Adding LDAP entry '%s' as child", ldap_get_dn (ld, newent)); -+#endif -+ -+ ns = dmalloc (sizeof (*ns), MDL); -+ ns->res = newres; -+ ns->ldent = newent; -+ ns->close_brace = 0; -+ ns->processed = 0; -+ ns->children = NULL; -+ ns->next = ldap_stack->children; -+ ldap_stack->children = ns; -+ } -+} -+ -+ -+static void -+ldap_generate_config_string (struct ldap_config_stack *item, struct parse *cfile) -+{ -+ struct berval **objectClass, **temp; -+ int i, j, ignore, found; -+ -+ if ((objectClass = ldap_get_values_len (ld, item->ldent, -+ "objectClass")) == NULL) -+ return; -+ -+ ignore = 0; -+ found = 1; -+ for (i=0; objectClass[i] != NULL && objectClass[i]->bv_val != NULL; i++) -+ { -+ if (strcmp (objectClass[i]->bv_val, "dhcpSharedNetwork") == 0) -+ ldap_parse_shared_network (item, cfile); -+ else if (strcmp (objectClass[i]->bv_val, "dhcpClass") == 0) -+ ldap_parse_class (item, cfile); -+ else if (strcmp (objectClass[i]->bv_val, "dhcpSubnet") == 0) -+ ldap_parse_subnet (item, cfile); -+ else if (strcmp (objectClass[i]->bv_val, "dhcpPool") == 0) -+ ldap_parse_pool (item, cfile); -+ else if (strcmp (objectClass[i]->bv_val, "dhcpGroup") == 0) -+ ldap_parse_group (item, cfile); -+ else if (strcmp (objectClass[i]->bv_val, "dhcpHost") == 0) -+ { -+ if (ldap_method == LDAP_METHOD_STATIC) -+ ldap_parse_host (item, cfile); -+ else -+ { -+ ignore = 1; -+ break; -+ } -+ } -+ else if (strcmp (objectClass[i]->bv_val, "dhcpSubClass") == 0) -+ { -+ if (ldap_method == LDAP_METHOD_STATIC) -+ ldap_parse_subclass (item, cfile); -+ else -+ { -+ ignore = 1; -+ break; -+ } -+ } -+ else -+ found = 0; -+ -+ if (found && cfile->inbuf[0] == '\0') -+ { -+ ignore = 1; -+ break; -+ } -+ } -+ -+ ldap_value_free_len (objectClass); -+ -+ if (ignore) -+ return; -+ -+ if ((temp = ldap_get_values_len (ld, item->ldent, "dhcpOption")) != NULL) -+ { -+ for (j=0; temp[j] != NULL && temp[j]->bv_val != NULL; j++) -+ { -+ strncat (cfile->inbuf, "option ", LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, temp[j]->bv_val, LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); -+ } -+ ldap_value_free_len (temp); -+ } -+ -+ if ((temp = ldap_get_values_len (ld, item->ldent, "dhcpStatements")) != NULL) -+ { -+ for (j=0; temp[j] != NULL && temp[j]->bv_val != NULL; j++) -+ { -+ strncat (cfile->inbuf, temp[j]->bv_val, LDAP_BUFFER_SIZE); -+ strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); -+ } -+ ldap_value_free_len (temp); -+ } -+ -+ parse_external_dns (item->ldent); -+} -+ -+ -+static void -+free_stack_entry (struct ldap_config_stack *item) -+{ -+ ldap_msgfree (item->res); -+ dfree (item, MDL); -+} -+ -+ -+static void -+next_ldap_entry (struct parse *cfile) -+{ -+ struct ldap_config_stack *temp_stack; -+ -+ if (ldap_stack->processed && ldap_stack->children != NULL) -+ { -+ temp_stack = ldap_stack->children; -+ if (temp_stack->close_brace) -+ strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE); -+ -+ ldap_stack->children = ldap_stack->children->next; -+ free_stack_entry (temp_stack); -+ -+ if (ldap_stack->processed && ldap_stack->children != NULL) -+ return; -+ } -+ -+ if (ldap_stack->close_brace) -+ { -+ strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE); -+ ldap_stack->close_brace = 0; -+ } -+ -+ while (ldap_stack != NULL && ldap_stack->children == NULL && -+ (ldap_stack->ldent = ldap_next_entry (ld, ldap_stack->ldent)) == NULL) -+ { -+ if (ldap_stack->close_brace) -+ { -+ strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE); -+ ldap_stack->close_brace = 0; -+ } -+ -+ temp_stack = ldap_stack; -+ ldap_stack = ldap_stack->next; -+ free_stack_entry (temp_stack); -+ } -+ -+ if (ldap_stack != NULL && ldap_stack->children == NULL && -+ ldap_stack->close_brace) -+ { -+ strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE); -+ ldap_stack->close_brace = 0; -+ } -+} -+ -+ -+static void -+add_to_config_stack (LDAPMessage * res, LDAPMessage * ent) -+{ -+ struct ldap_config_stack *ns; -+ -+ ns = dmalloc (sizeof (*ns), MDL); -+ ns->res = res; -+ ns->ldent = ent; -+ ns->close_brace = 0; -+ ns->processed = 0; -+ ns->children = NULL; -+ ns->next = ldap_stack; -+ ldap_stack = ns; -+} -+ -+ -+static void -+ldap_start (void) -+{ -+ struct option_state *options; -+ struct option_cache *oc; -+ struct data_string db; -+ int ret; -+ -+ if (ld != NULL) -+ return; -+ -+ if (ldap_server == NULL) -+ { -+ options = NULL; -+ option_state_allocate (&options, MDL); -+ -+ execute_statements_in_scope ((struct binding_value **) NULL, -+ (struct packet *) NULL, (struct lease *) NULL, -+ (struct client_state *) NULL, (struct option_state *) NULL, -+ options, &global_scope, root_group, (struct group *) NULL); -+ -+ memset (&db, 0, sizeof (db)); -+ oc = lookup_option (&server_universe, options, SV_LDAP_SERVER); -+ if (oc && -+ evaluate_option_cache (&db, (struct packet*) NULL, -+ (struct lease *) NULL, (struct client_state *) NULL, -+ options, (struct option_state *) NULL, &global_scope, oc, MDL)) -+ { -+ ldap_server = dmalloc (db.len + 1, MDL); -+ if (!ldap_server) -+ log_fatal ("no memory for ldap server"); -+ memcpy (ldap_server, db.data, db.len); -+ ldap_server[db.len] = 0; -+ data_string_forget (&db, MDL); -+ } -+ -+ oc = lookup_option (&server_universe, options, SV_LDAP_USERNAME); -+ if (oc && -+ evaluate_option_cache (&db, (struct packet*) NULL, -+ (struct lease *) NULL, (struct client_state *) NULL, -+ options, (struct option_state *) NULL, &global_scope, oc, MDL)) -+ { -+ ldap_username = dmalloc (db.len + 1, MDL); -+ if (!ldap_username) -+ log_fatal ("no memory for ldap username"); -+ memcpy (ldap_username, db.data, db.len); -+ ldap_username[db.len] = 0; -+ data_string_forget (&db, MDL); -+ } -+ -+ oc = lookup_option (&server_universe, options, SV_LDAP_PASSWORD); -+ if (oc && -+ evaluate_option_cache (&db, (struct packet*) NULL, -+ (struct lease *) NULL, (struct client_state *) NULL, -+ options, (struct option_state *) NULL, &global_scope, oc, MDL)) -+ { -+ ldap_password = dmalloc (db.len + 1, MDL); -+ if (!ldap_password) -+ log_fatal ("no memory for ldap password"); -+ memcpy (ldap_password, db.data, db.len); -+ ldap_password[db.len] = 0; -+ data_string_forget (&db, MDL); -+ } -+ -+ oc = lookup_option (&server_universe, options, SV_LDAP_BASE_DN); -+ if (oc && -+ evaluate_option_cache (&db, (struct packet*) NULL, -+ (struct lease *) NULL, (struct client_state *) NULL, -+ options, (struct option_state *) NULL, &global_scope, oc, MDL)) -+ { -+ ldap_base_dn = dmalloc (db.len + 1, MDL); -+ if (!ldap_base_dn) -+ log_fatal ("no memory for ldap password"); -+ memcpy (ldap_base_dn, db.data, db.len); -+ ldap_base_dn[db.len] = 0; -+ data_string_forget (&db, MDL); -+ } -+ -+ oc = lookup_option (&server_universe, options, SV_LDAP_METHOD); -+ if (oc && -+ evaluate_option_cache (&db, (struct packet*) NULL, -+ (struct lease *) NULL, (struct client_state *) NULL, -+ options, (struct option_state *) NULL, &global_scope, oc, MDL)) -+ { -+ -+ if (db.len == 1) -+ ldap_method = db.data [0]; -+ else -+ log_fatal ("invalid dns update type"); -+ data_string_forget (&db, MDL); -+ } -+ -+ option_state_dereference (&options, MDL); -+ } -+ -+ if (ldap_server == NULL || ldap_username == NULL || ldap_password == NULL || -+ ldap_base_dn == NULL) -+ { -+ log_info ("Not searching LDAP since ldap-server, ldap-username, ldap-password and ldap-base-dn were not specified in the config file"); -+ disable_ldap = 1; -+ return; -+ } -+ -+#if defined (DEBUG_LDAP) -+ log_info ("Connecting to LDAP server ldap://%s", ldap_server); -+#endif -+ -+ char *tmpserver = NULL; -+ if ((tmpserver = malloc(strlen(ldap_server) + 8)) == NULL) -+ { -+ log_error ("Cannot init tmpldapserver string to ldap://%s", ldap_server); -+ disable_ldap = 1; -+ return; -+ } -+ -+ if (sprintf(tmpserver, "ldap://%s", ldap_server) == -1) -+ { -+ log_error ("Cannot init tmpldapserver via sprintf()"); -+ disable_ldap = 1; -+ return; -+ } -+ -+ ldap_initialize (&ld, tmpserver); -+ if (ld == NULL) -+ { -+ log_error ("Cannot init ldap session to %s", ldap_server); -+ disable_ldap = 1; -+ return; -+ } -+ -+ free (tmpserver); -+ -+ struct berval cred; -+ cred.bv_val = strdup(ldap_password); -+ cred.bv_len = strlen(ldap_password); -+ ret = ldap_sasl_bind_s (ld, ldap_username, LDAP_SASL_SIMPLE, -+ &cred, NULL,NULL, NULL); -+ if (ret != LDAP_SUCCESS) -+ { -+ log_error ("Error: Cannot log into ldap server %s: %s", ldap_server, -+ ldap_err2string (ret)); -+ disable_ldap = 1; -+ ldap_unbind_ext (ld, NULL, NULL); -+ ld = NULL; -+ return; -+ } -+ -+#if defined (DEBUG_LDAP) -+ log_info ("Successfully logged into LDAP server %s", ldap_server); -+#endif -+} -+ -+ -+static int -+ldap_read_function (struct parse *cfile) -+{ -+ char *dn, eofstring[2] = {EOF, '\0'}; -+ struct ldap_config_stack *curentry; -+ LDAPMessage * ent, * res; -+ int ret; -+ -+ cfile->inbuf[0] = '\0'; -+ cfile->buflen = 0; -+ while (1) -+ { -+ if (ldap_stack == NULL) -+ { -+ strncat (cfile->inbuf, eofstring, LDAP_BUFFER_SIZE); -+ cfile->buflen = strlen (cfile->inbuf); -+ cfile->bufix = 1; -+ return (cfile->inbuf[0]); -+ } -+ -+ if (ldap_stack->processed && ldap_stack->children != NULL) -+ curentry = ldap_stack->children; -+ else -+ curentry = ldap_stack; -+ -+ dn = ldap_get_dn (ld, curentry->ldent); -+#if defined(DEBUG_LDAP) -+ log_info ("Found LDAP entry '%s'", dn); -+#endif -+ -+ ldap_generate_config_string (curentry, cfile); -+ if (strlen (cfile->inbuf) == 0) -+ { -+#if defined(DEBUG_LDAP) -+ log_info ("Skipping LDAP entry '%s'", dn); -+#endif -+ ldap_memfree (dn); -+ dn = NULL; -+ next_ldap_entry (cfile); -+ continue; -+ } -+ -+ curentry->processed = 1; -+ break; -+ } -+ -+ if (ld == NULL) -+ ldap_start (); -+ -+ if (ld == NULL) -+ { -+ strncat (cfile->inbuf, eofstring, LDAP_BUFFER_SIZE); -+ cfile->buflen = strlen (cfile->inbuf); -+ cfile->bufix = 1; -+ return (cfile->inbuf[0]); -+ } -+ -+ if ((ret = ldap_search_ext_s (ld, dn, LDAP_SCOPE_ONELEVEL, "objectClass=*", -+ NULL, 0, NULL, NULL, NULL, 0, -+ &res)) != LDAP_SUCCESS) -+ { -+ ldap_unbind_ext (ld, NULL, NULL); -+ ld = NULL; -+ -+ strncat (cfile->inbuf, eofstring, LDAP_BUFFER_SIZE); -+ cfile->buflen = strlen (cfile->inbuf); -+ cfile->bufix = 1; -+ return (cfile->inbuf[0]); -+ } -+ -+ ldap_memfree (dn); -+ -+ ent = ldap_first_entry (ld, res); -+ if (ent != NULL) -+ add_to_config_stack (res, ent); -+ else -+ { -+ ldap_msgfree (res); -+ next_ldap_entry (cfile); -+ } -+ -+#if defined (DEBUG_LDAP) -+ log_info ("Sending config line '%s'", cfile->inbuf); -+#endif -+ -+ cfile->buflen = strlen (cfile->inbuf); -+ cfile->bufix = 1; -+ return (cfile->inbuf[0]); -+} -+ -+ -+static char * -+ldap_get_host_name (LDAPMessage * ent) -+{ -+ struct berval **name; -+ char *ret; -+ -+ ret = NULL; -+ if ((name = ldap_get_values_len (ld, ent, "cn")) == NULL || name[0] == NULL) -+ { -+ if (name != NULL) -+ ldap_value_free_len (name); -+ -+#if defined (DEBUG_LDAP) -+ log_info ("Cannot get cn attribute for LDAP entry %s", -+ ldap_get_dn (ld, ent)); -+#endif -+ return (NULL); -+ } -+ -+ ret = dmalloc (strlen (name[0]->bv_val) + 1, MDL); -+ strcpy (ret, name[0]->bv_val); -+ ldap_value_free_len (name); -+ -+ return (ret); -+} -+ -+ -+isc_result_t -+ldap_read_config (void) -+{ -+ struct berval **temp; -+ char *buffer, dn[256]; -+ LDAPMessage * ldres, * ent; -+ struct parse *cfile; -+ struct utsname unme; -+ isc_result_t res; -+ int ret; -+ -+ -+ buffer = dmalloc (LDAP_BUFFER_SIZE, MDL); -+ cfile = (struct parse *) NULL; -+ res = new_parse (&cfile, -1, buffer, LDAP_BUFFER_SIZE, "LDAP", 0); -+ if (res != ISC_R_SUCCESS) -+ return (res); -+ -+ cfile->bufix = cfile->buflen = 0; -+ cfile->read_function = ldap_read_function; -+ -+ if (ld == NULL) -+ ldap_start (); -+ if (ld == NULL) -+ return (ldap_server == NULL ? ISC_R_SUCCESS : ISC_R_FAILURE); -+ -+ uname (&unme); -+ snprintf (dn, sizeof (dn), "(&(objectClass=dhcpServer)(cn=%s))", -+ unme.nodename); -+ -+ if ((ret = ldap_search_ext_s (ld, ldap_base_dn, LDAP_SCOPE_SUBTREE, dn, NULL, -+ 0, NULL, NULL, NULL, 0, &ldres)) != LDAP_SUCCESS) -+ { -+ ldap_unbind_ext (ld, NULL, NULL); -+ ld = NULL; -+ log_error ("Cannot search LDAP for %s: %s", dn, ldap_err2string (ret)); -+ return (ISC_R_FAILURE); -+ } -+ -+ if ((ent = ldap_first_entry (ld, ldres)) == NULL) -+ { -+ ldap_unbind_ext (ld, NULL, NULL); -+ ld = NULL; -+ log_error ("Error: Cannot find LDAP entry matching %s", dn); -+ return (ISC_R_FAILURE); -+ } -+ -+#if defined(DEBUG_LDAP) -+ buffer = ldap_get_dn (ld, ent); -+ log_info ("Found LDAP entry '%s'", buffer); -+ ldap_memfree (buffer); -+#endif -+ -+ if ((temp = ldap_get_values_len (ld, ent, "dhcpServiceDN")) == NULL || -+ temp[0]->bv_val == NULL) -+ { -+ if (temp != NULL) -+ ldap_value_free_len (temp); -+ -+ ldap_unbind_ext (ld, NULL, NULL); -+ ld = NULL; -+ log_error ("Error: Cannot find LDAP entry matching %s", dn); -+ return (ISC_R_FAILURE); -+ } -+ -+ ldap_msgfree (ldres); -+ -+ if ((ret = ldap_search_ext_s (ld, temp[0]->bv_val, LDAP_SCOPE_BASE, -+ "objectClass=*", NULL, 0, -+ NULL, NULL, NULL, 0, &ldres)) != LDAP_SUCCESS) -+ { -+ ldap_value_free_len (temp); -+ ldap_unbind_ext (ld, NULL, NULL); -+ ld = NULL; -+ log_error ("Cannot search LDAP for %s: %s", temp[0]->bv_val, -+ ldap_err2string (ret)); -+ return (ISC_R_FAILURE); -+ } -+ -+ if ((ent = ldap_first_entry (ld, ldres)) == NULL) -+ { -+ ldap_value_free_len (temp); -+ ldap_unbind_ext (ld, NULL, NULL); -+ ld = NULL; -+ log_error ("Error: Cannot find LDAP entry matching %s", temp[0]->bv_val); -+ return (ISC_R_FAILURE); -+ } -+ -+ ldap_value_free_len (temp); -+ -+ add_to_config_stack (ldres, ent); -+ -+ res = conf_file_subparse (cfile, root_group, ROOT_GROUP); -+ end_parse (&cfile); -+ -+ return (res); -+} -+ -+ -+/* This function will parse the dhcpOption and dhcpStatements field in the LDAP -+ entry if it exists. Right now, type will be either HOST_DECL or CLASS_DECL. -+ If we are parsing a HOST_DECL, this always returns 0. If we are parsing a -+ CLASS_DECL, this will return what the current lease limit is in LDAP. If -+ there is no lease limit specified, we return 0 */ -+ -+static int -+ldap_parse_options (LDAPMessage * ent, struct group *group, -+ int type, struct host_decl *host, -+ struct class **class) -+{ -+ struct berval **temp; -+ char option_buffer[8192]; -+ int i, declaration, lease_limit; -+ enum dhcp_token token; -+ struct parse *cfile; -+ isc_result_t res; -+ const char *val; -+ -+ lease_limit = 0; -+ *option_buffer = '\0'; -+ if ((temp = ldap_get_values_len (ld, ent, "dhcpStatements")) != NULL) -+ { -+ for (i=0; temp[i] != NULL && temp[i]->bv_val != NULL; i++) -+ { -+ if (strncasecmp ("lease limit ", temp[i]->bv_val, 12) == 0) -+ { -+ lease_limit = strtol ((temp[i]->bv_val) + 12, NULL, 10); -+ continue; -+ } -+ -+ strncat (option_buffer, temp[i]->bv_val, sizeof (option_buffer) - strlen (option_buffer) - 1); -+ strncat (option_buffer, ";\n", sizeof (option_buffer) - strlen (option_buffer) - 1); -+ } -+ ldap_value_free_len (temp); -+ } -+ -+ if ((temp = ldap_get_values_len (ld, ent, "dhcpOption")) != NULL) -+ { -+ for (i=0; temp[i] != NULL && temp[i]->bv_val != NULL; i++) -+ { -+ strncat (option_buffer, "option ", sizeof (option_buffer) - strlen (option_buffer) - 1); -+ strncat (option_buffer, temp[i]->bv_val, sizeof (option_buffer) - strlen (option_buffer) - 1); -+ strncat (option_buffer, ";\n", sizeof (option_buffer) - strlen (option_buffer) - 1); -+ } -+ ldap_value_free_len (temp); -+ } -+ -+ if (*option_buffer == '\0') -+ return (lease_limit); -+ -+ cfile = (struct parse *) NULL; -+ res = new_parse (&cfile, -1, option_buffer, strlen (option_buffer), -+ type == HOST_DECL ? "LDAP-HOST" : "LDAP-SUBCLASS", 0); -+ if (res != ISC_R_SUCCESS) -+ return (lease_limit); -+ -+#if defined (DEBUG_LDAP) -+ log_info ("Sending the following options: '%s'", option_buffer); -+#endif -+ -+ declaration = 0; -+ do { -+ token = peek_token (&val, NULL, cfile); -+ if (token == END_OF_FILE) -+ break; -+ declaration = parse_statement (cfile, group, type, host, declaration); -+ } while (1); -+ -+ end_parse (&cfile); -+ -+ return (lease_limit); -+} -+ -+ -+ -+int -+find_haddr_in_ldap (struct host_decl **hp, int htype, unsigned hlen, -+ const unsigned char *haddr, const char *file, int line) -+{ -+ char buf[60], *type_str; -+ LDAPMessage * res, *ent; -+ struct host_decl * host; -+ isc_result_t status; -+ int ret; -+ -+ if (disable_ldap || ldap_method == LDAP_METHOD_STATIC) -+ return (0); -+ -+ if (ld == NULL) -+ ldap_start (); -+ if (ld == NULL) -+ return (0); -+ -+ switch (htype) -+ { -+ case HTYPE_ETHER: -+ type_str = "ethernet"; -+ break; -+ case HTYPE_IEEE802: -+ type_str = "token-ring"; -+ break; -+ case HTYPE_FDDI: -+ type_str = "fddi"; -+ break; -+ default: -+ log_info ("Ignoring unknown type %d", htype); -+ return (0); -+ } -+ -+ snprintf (buf, sizeof (buf), "dhcpHWAddress=%s %s", type_str, -+ print_hw_addr (htype, hlen, haddr)); -+#if defined (DEBUG_LDAP) -+ log_info ("Searching for %s in LDAP tree %s", buf, ldap_base_dn); -+#endif -+ -+ if ((ret = ldap_search_ext_s (ld, ldap_base_dn, LDAP_SCOPE_SUBTREE, -+ buf, NULL, 0, NULL, NULL, NULL, 0, -+ &res)) != LDAP_SUCCESS) -+ { -+ if (ret != LDAP_NO_SUCH_OBJECT) -+ { -+ log_error ("Cannot search for %s in LDAP tree %s: %s", buf, -+ ldap_base_dn, ldap_err2string (ret)); -+ ldap_unbind_ext (ld, NULL, NULL); -+ ld = NULL; -+ } -+#if defined (DEBUG_LDAP) -+ else -+ log_info ("ldap_search_ext_s returned %s when searching for %s in %s", -+ ldap_err2string (ret), buf, ldap_base_dn); -+#endif -+ -+ return (0); -+ } -+ -+ if ((ent = ldap_first_entry (ld, res)) != NULL) -+ { -+#if defined (DEBUG_LDAP) -+ log_info ("Found LDAP entry %s", ldap_get_dn (ld, ent)); -+#endif -+ -+ host = (struct host_decl *)0; -+ status = host_allocate (&host, MDL); -+ if (status != ISC_R_SUCCESS) -+ { -+ log_fatal ("can't allocate host decl struct: %s", -+ isc_result_totext (status)); -+ return (0); -+ } -+ -+ host->name = ldap_get_host_name (ent); -+ if (host->name == NULL) -+ { -+ host_dereference (&host, MDL); -+ ldap_msgfree (res); -+ return (0); -+ } -+ -+ if (!clone_group (&host->group, root_group, MDL)) -+ { -+ log_fatal ("can't clone group for host %s", host->name); -+ host_dereference (&host, MDL); -+ return (0); -+ } -+ -+ ldap_parse_options (ent, host->group, HOST_DECL, host, NULL); -+ -+ *hp = host; -+ ldap_msgfree (res); -+ return (1); -+ } -+ -+ -+ ldap_msgfree (res); -+ return (0); -+} -+ -+ -+int -+find_subclass_in_ldap (struct class *class, struct class **newclass, -+ struct data_string *data) -+{ -+ LDAPMessage * res, * ent; -+ int ret, lease_limit; -+ isc_result_t status; -+ char buf[1024]; -+ -+ if (disable_ldap || ldap_method == LDAP_METHOD_STATIC) -+ return (0); -+ -+ if (ld == NULL) -+ ldap_start (); -+ if (ld == NULL) -+ return (0); -+ -+ snprintf (buf, sizeof (buf), "(&(objectClass=dhcpSubClass)(cn=%s)(dhcpClassData=%s))", print_hex_1 (data->len, data->data, 60), print_hex_2 (strlen (class->name), (const u_int8_t *) class->name, 60)); -+#if defined (DEBUG_LDAP) -+ log_info ("Searching LDAP for %s", buf); -+#endif -+ -+ if ((ret = ldap_search_ext_s (ld, ldap_base_dn, LDAP_SCOPE_SUBTREE, -+ buf, NULL, 0, NULL, NULL, NULL, 0, -+ &res)) != LDAP_SUCCESS) -+ { -+ if (ret != LDAP_NO_SUCH_OBJECT) -+ { -+ log_error ("Cannot search for %s in LDAP tree %s: %s", buf, -+ ldap_base_dn, ldap_err2string (ret)); -+ ldap_unbind_ext (ld, NULL, NULL); -+ ld = NULL; -+ } -+#if defined (DEBUG_LDAP) -+ else -+ log_info ("ldap_search_ext_s returned %s when searching for %s in %s", -+ ldap_err2string (ret), buf, ldap_base_dn); -+#endif -+ -+ return (0); -+ } -+ -+ if ((ent = ldap_first_entry (ld, res)) != NULL) -+ { -+#if defined (DEBUG_LDAP) -+ log_info ("Found LDAP entry %s", ldap_get_dn (ld, ent)); -+#endif -+ -+ status = class_allocate (newclass, MDL); -+ if (status != ISC_R_SUCCESS) -+ { -+ log_error ("Cannot allocate memory for a new class"); -+ return (0); -+ } -+ -+ group_reference (&(*newclass)->group, class->group, MDL); -+ class_reference (&(*newclass)->superclass, class, MDL); -+ lease_limit = ldap_parse_options (ent, (*newclass)->group, -+ CLASS_DECL, NULL, newclass); -+ if (lease_limit == 0) -+ (*newclass)->lease_limit = class->lease_limit; -+ else -+ class->lease_limit = lease_limit; -+ -+ if ((*newclass)->lease_limit) -+ { -+ (*newclass)->billed_leases = -+ dmalloc ((*newclass)->lease_limit * sizeof (struct lease *), MDL); -+ if (!(*newclass)->billed_leases) -+ { -+ log_error ("no memory for billing"); -+ class_dereference (newclass, MDL); -+ return (0); -+ } -+ memset ((*newclass)->billed_leases, 0, -+ ((*newclass)->lease_limit * sizeof (*newclass)->billed_leases)); -+ } -+ -+ data_string_copy (&(*newclass)->hash_string, data, MDL); -+ -+ ldap_msgfree (res); -+ return (1); -+ } -+ -+ -+ ldap_msgfree (res); -+ return (0); -+} -+ -+#endif -+ ---- dhcp-3.0.5/server/mdb.c.ldap 2007-03-29 15:10:26.000000000 -0400 -+++ dhcp-3.0.5/server/mdb.c 2007-03-29 15:11:19.000000000 -0400 -@@ -373,6 +373,12 @@ - const char *file, int line) - { - struct hardware h; -+ int ret; -+ -+#if defined(LDAP_CONFIGURATION) -+ if ((ret = find_haddr_in_ldap (hp, htype, hlen, haddr, file, line))) -+ return ret; -+#endif - - h.hlen = hlen + 1; - h.hbuf [0] = htype; ---- dhcp-3.0.5/server/stables.c.ldap 2004-06-10 13:59:58.000000000 -0400 -+++ dhcp-3.0.5/server/stables.c 2007-03-29 15:11:19.000000000 -0400 -@@ -483,12 +483,21 @@ - { "log-facility", "Nsyslog-facilities.", &server_universe, 44 }, - { "do-forward-updates", "f", &server_universe, 45 }, - { "ping-timeout", "T", &server_universe, 46 }, -+#if defined(LDAP_CONFIGURATION) -+ { "ldap-server", "t", &server_universe, 47 }, -+ { "ldap-port", "d", &server_universe, 48 }, -+ { "ldap-username", "t", &server_universe, 49 }, -+ { "ldap-password", "t", &server_universe, 50 }, -+ { "ldap-base-dn", "t", &server_universe, 51 }, -+ { "ldap-method", "Nldap-methods.", &server_universe, 52 }, -+#else - { "unknown-47", "X", &server_universe, 47 }, - { "unknown-48", "X", &server_universe, 48 }, - { "unknown-49", "X", &server_universe, 49 }, - { "unknown-50", "X", &server_universe, 50 }, - { "unknown-51", "X", &server_universe, 51 }, - { "unknown-52", "X", &server_universe, 52 }, -+#endif - { "unknown-53", "X", &server_universe, 53 }, - { "unknown-54", "X", &server_universe, 54 }, - { "unknown-55", "X", &server_universe, 55 }, -@@ -694,6 +703,20 @@ - { "option-end", "e", &server_universe, 255 }, - }; - -+#if defined(LDAP_CONFIGURATION) -+struct enumeration_value ldap_values [] = { -+ { "static", LDAP_METHOD_STATIC }, -+ { "dynamic", LDAP_METHOD_DYNAMIC }, -+ { (char *) 0, 0 } -+}; -+ -+struct enumeration ldap_methods = { -+ (struct enumeration *)0, -+ "ldap-methods", -+ ldap_values -+}; -+#endif -+ - struct enumeration_value ddns_styles_values [] = { - { "none", 0 }, - { "ad-hoc", 1 }, diff --git a/dhcp-3.0.5-warnings.patch b/dhcp-3.0.5-warnings.patch deleted file mode 100644 index b556879..0000000 --- a/dhcp-3.0.5-warnings.patch +++ /dev/null @@ -1,2165 +0,0 @@ ---- dhcp-3.0.5/client/dhclient.c.warnings 2006-08-22 11:13:57.000000000 -0400 -+++ dhcp-3.0.5/client/dhclient.c 2007-03-29 14:23:54.000000000 -0400 -@@ -95,7 +95,6 @@ - omapi_object_t *listener; - isc_result_t result; - int persist = 0; -- int omapi_port; - int no_dhclient_conf = 0; - int no_dhclient_db = 0; - int no_dhclient_pid = 0; -@@ -634,7 +633,6 @@ - picked = lp; - picked -> next = (struct client_lease *)0; - } else { -- freeit: - destroy_client_lease (lp); - } - } -@@ -693,7 +691,6 @@ - struct client_lease *lease; - struct option_cache *oc; - struct data_string ds; -- int i; - - /* If we're not receptive to an offer right now, or if the offer - has an unrecognizable transaction id, then just drop it. */ -@@ -845,8 +842,6 @@ - void bind_lease (client) - struct client_state *client; - { -- struct interface_info *ip = client -> interface; -- - /* Remember the medium. */ - client -> new -> medium = client -> medium; - -@@ -911,7 +906,6 @@ - void *cpp; - { - struct client_state *client = cpp; -- int i; - struct option_cache *oc; - struct data_string ds; - -@@ -954,7 +948,6 @@ - void *cpp; - { - struct client_state *client = cpp; -- int i; - - /* Cancel all timeouts. */ - cancel_timeout (state_selecting, client); -@@ -1067,8 +1060,6 @@ - int i; - int stop_selecting; - const char *name = packet -> packet_type ? "DHCPOFFER" : "BOOTREPLY"; -- struct iaddrlist *ap; -- struct option_cache *oc; - char obuf [1024]; - - #ifdef DEBUG_PACKET -@@ -1886,7 +1877,6 @@ - struct client_lease *lease; - { - unsigned char discover = DHCPDISCOVER; -- int i; - struct option_state *options = (struct option_state *)0; - - memset (&client -> packet, 0, sizeof (client -> packet)); -@@ -1950,9 +1940,6 @@ - struct client_lease *lease; - { - unsigned char request = DHCPREQUEST; -- int i, j; -- unsigned char *tmp, *digest; -- unsigned char *old_digest_loc; - struct option_cache *oc; - - memset (&client -> packet, 0, sizeof (client -> packet)); -@@ -2040,7 +2027,6 @@ - struct client_lease *lease; - { - unsigned char decline = DHCPDECLINE; -- int i; - struct option_cache *oc; - - struct option_state *options = (struct option_state *)0; -@@ -2096,7 +2082,6 @@ - struct client_lease *lease; - { - unsigned char request = DHCPRELEASE; -- int i; - struct option_cache *oc; - - struct option_state *options = (struct option_state *)0; -@@ -2153,8 +2138,6 @@ - void destroy_client_lease (lease) - struct client_lease *lease; - { -- int i; -- - if (lease -> server_name) - dfree (lease -> server_name, MDL); - if (lease -> filename) -@@ -2217,8 +2200,6 @@ - { - const char *name, *dot; - struct data_string ds; -- int status; -- struct client_state *client; - - memset (&ds, 0, sizeof ds); - -@@ -2249,9 +2230,7 @@ - int i; - struct tm *t; - static int leases_written; -- struct option_cache *oc; - struct data_string ds; -- pair *hash; - int errors = 0; - char *s; - -@@ -2487,8 +2466,6 @@ - int i; - struct data_string data; - struct option_cache *oc; -- pair *hash; -- char *s, *t; - struct envadd_state es; - - es.client = client; -@@ -2565,11 +2542,9 @@ - int script_go (client) - struct client_state *client; - { -- int rval; - char *scriptName; - char *argv [2]; - char **envp; -- char *epp [3]; - char reason [] = "REASON=NBI"; - static char client_path [] = CLIENT_PATH; - int i; -@@ -2645,7 +2620,7 @@ - { - char spbuf [1024]; - char *s; -- unsigned len, i; -+ unsigned len; - struct string_list *val; - va_list list; - -@@ -3071,8 +3046,7 @@ - - isc_result_t client_dns_update (struct client_state *client, int addp, int ttl) - { -- struct data_string ddns_fqdn, ddns_fwd_name, -- ddns_dhcid, client_identifier; -+ struct data_string ddns_fwd_name, ddns_dhcid, client_identifier; - struct option_cache *oc; - int ignorep; - int result; ---- dhcp-3.0.5/client/clparse.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/client/clparse.c 2007-03-29 14:24:47.000000000 -0400 -@@ -39,8 +39,6 @@ - - #include "dhcpd.h" - --static TIME parsed_time; -- - struct client_config top_level_config; - - u_int32_t default_requested_options [] = { -@@ -62,7 +60,6 @@ - isc_result_t read_client_conf () - { - struct client_config *config; -- struct client_state *state; - struct interface_info *ip; - isc_result_t status; - -@@ -240,11 +237,9 @@ - int token; - const char *val; - struct option *option; -- struct executable_statement *stmt, **p; -- enum statement_op op; -+ struct executable_statement *stmt; - int lose; - char *name; -- struct data_string key_id; - enum policy policy; - int known; - int tmp, i; -@@ -967,11 +962,9 @@ - { - int token; - const char *val; -- char *t, *n; - struct interface_info *ip; - struct option_cache *oc; - struct client_state *client = (struct client_state *)0; -- struct data_string key_id; - - switch (next_token (&val, (unsigned *)0, cfile)) { - case KEY: -@@ -1162,12 +1155,6 @@ - struct parse *cfile; - int flag; - { -- enum dhcp_token token; -- const char *val; -- unsigned char rf = flag; -- struct expression *data = (struct expression *)0; -- int status; -- - parse_warn (cfile, "allow/deny/ignore not permitted here."); - skip_to_semi (cfile); - return 0; ---- dhcp-3.0.5/common/parse.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/common/parse.c 2007-03-29 13:45:34.000000000 -0400 -@@ -311,9 +311,6 @@ - struct parse *cfile; - struct iaddr *addr; - { -- const char *val; -- enum dhcp_token token; -- - addr -> len = 4; - if (parse_numeric_aggregate (cfile, addr -> iabuf, - &addr -> len, DOT, 10, 8)) -@@ -650,7 +647,6 @@ - TIME parse_date (cfile) - struct parse *cfile; - { -- struct tm tm; - int guess; - int tzoff, wday, year, mon, mday, hour, min, sec; - const char *val; -@@ -1022,7 +1018,6 @@ - char tokbuf [128]; - unsigned tokix = 0; - char type; -- int code; - int is_signed; - char *s; - int has_encapsulation = 0; -@@ -1511,7 +1506,6 @@ - { - enum dhcp_token token; - const char *val; -- struct executable_statement base; - struct class *cta; - struct option *option; - struct option_cache *cache; -@@ -1814,7 +1808,6 @@ - if (token != NAME && token != NUMBER_OR_NAME) { - parse_warn (cfile, - "%s can't be a variable name", val); -- badunset: - skip_to_semi (cfile); - *lose = 1; - return 0; -@@ -2789,16 +2782,12 @@ - enum dhcp_token token; - const char *val; - struct collection *col; -- struct option *option; - struct expression *nexp, **ep; - int known; - enum expr_op opcode; - const char *s; - char *cptr; -- struct executable_statement *stmt; -- int i; - unsigned long u; -- isc_result_t status, code; - unsigned len; - - token = peek_token (&val, (unsigned *)0, cfile); -@@ -3286,7 +3275,6 @@ - parse_warn - (cfile, - "expecting dns expression."); -- badnstrans: - expression_dereference (expr, MDL); - *lose = 1; - return 0; -@@ -4194,8 +4182,6 @@ - struct expression *expr = (struct expression *)0; - struct expression *tmp; - int lose; -- struct executable_statement *stmt; -- int ftt = 1; - - token = peek_token (&val, (unsigned *)0, cfile); - if (token == SEMI) { -@@ -4313,9 +4299,7 @@ - struct expression *t = (struct expression *)0; - unsigned char buf [4]; - unsigned len; -- unsigned char *ob; - struct iaddr addr; -- int num; - const char *f, *g; - struct enumeration_value *e; - -@@ -4556,8 +4540,6 @@ - /* 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; -@@ -4756,7 +4738,6 @@ - int token; - const char *val; - unsigned len; -- u_int8_t *s; - - token = peek_token (&val, (unsigned *)0, cfile); - if (token == NUMBER_OR_NAME || token == NUMBER) { -@@ -4823,9 +4804,10 @@ - if (lix < (sizeof lexbuf) - 1) - lexbuf [lix++] = ' '; - if (cfile -> token_line [i] == '\t') { -- for (lix; -- lix < (sizeof lexbuf) - 1 && (lix & 7); lix++) -+ while (lix < (sizeof lexbuf) - 1 && (lix & 7)) { - lexbuf [lix] = ' '; -+ lix++; -+ } - } - } - lexbuf [lix] = 0; -@@ -4838,14 +4820,20 @@ - #endif - - if (log_perror) { -- write (STDERR_FILENO, mbuf, strlen (mbuf)); -- write (STDERR_FILENO, "\n", 1); -- write (STDERR_FILENO, cfile -> token_line, -- strlen (cfile -> token_line)); -- write (STDERR_FILENO, "\n", 1); -+ if (write (STDERR_FILENO, mbuf, strlen (mbuf)) <= 0) -+ return -1; -+ if (write (STDERR_FILENO, "\n", 1) <= 0) -+ return -1; -+ if (write (STDERR_FILENO, cfile -> token_line, -+ strlen (cfile -> token_line)) <= 0) -+ return -1; -+ if (write (STDERR_FILENO, "\n", 1) <= 0) -+ return -1; - if (cfile -> lexchar < 81) -- write (STDERR_FILENO, lexbuf, lix); -- write (STDERR_FILENO, "^\n", 2); -+ if (write (STDERR_FILENO, lexbuf, lix) <= 0) -+ return -1; -+ if (write (STDERR_FILENO, "^\n", 2) <= 0) -+ return -1; - } - - cfile -> warnings_occurred = 1; ---- dhcp-3.0.5/common/icmp.c.warnings 2004-06-10 13:59:18.000000000 -0400 -+++ dhcp-3.0.5/common/icmp.c 2007-03-29 13:45:34.000000000 -0400 -@@ -61,11 +61,7 @@ - { - struct protoent *proto; - int protocol = 1; -- struct sockaddr_in from; -- int fd; - int state; -- struct icmp_state *new; -- omapi_object_t *h; - isc_result_t result; - - /* Only initialize icmp once. */ -@@ -284,7 +280,6 @@ - void trace_icmp_input_input (trace_type_t *ttype, unsigned length, char *buf) - { - struct iaddr *ia; -- unsigned len; - u_int8_t *icbuf; - ia = (struct iaddr *)buf; - ia->len = ntohl(ia->len); ---- dhcp-3.0.5/common/socket.c.warnings 2004-06-10 13:59:21.000000000 -0400 -+++ dhcp-3.0.5/common/socket.c 2007-03-29 13:45:34.000000000 -0400 -@@ -55,8 +55,6 @@ - # endif - #endif - --static int once = 0; -- - /* Reinitializes the specified interface after an address change. This - is not required for packet-filter APIs. */ - ---- dhcp-3.0.5/common/lpf.c.warnings 2004-11-24 12:39:15.000000000 -0500 -+++ dhcp-3.0.5/common/lpf.c 2007-03-29 13:45:34.000000000 -0400 -@@ -69,8 +69,6 @@ - struct interface_info *info; - { - int sock; -- char filename[50]; -- int b; - struct sockaddr sa; - - /* Make an LPF socket. */ -@@ -334,7 +332,6 @@ - struct sockaddr_in *from; - struct hardware *hfrom; - { -- int nread; - int length = 0; - int offset = 0; - unsigned char ibuf [1536]; ---- dhcp-3.0.5/common/memory.c.warnings 2004-06-10 13:59:19.000000000 -0400 -+++ dhcp-3.0.5/common/memory.c 2007-03-29 13:45:34.000000000 -0400 -@@ -84,8 +84,7 @@ - - isc_result_t supersede_group (struct group_object *group, int writep) - { -- struct group_object *t, *u; -- isc_result_t status; -+ struct group_object *t; - - /* Register the group in the group name hash table, - so we can look it up later. */ -@@ -142,7 +141,6 @@ - int clone_group (struct group **gp, struct group *group, - const char *file, int line) - { -- isc_result_t status; - struct group *g = (struct group *)0; - - /* Normally gp should contain the null pointer, but for convenience ---- dhcp-3.0.5/common/print.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/common/print.c 2007-03-29 13:45:34.000000000 -0400 -@@ -1043,7 +1043,6 @@ - const char *suffix, ...) - { - va_list list; -- char *buf; - unsigned len; - char *s, *t, *u; - -@@ -1081,7 +1080,6 @@ - struct data_string *data) - { - int i; -- char *buf; - char obuf [3]; - - /* See if this is just ASCII. */ ---- dhcp-3.0.5/common/options.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/common/options.c 2007-03-29 13:45:34.000000000 -0400 -@@ -43,16 +43,11 @@ - - struct option *vendor_cfg_option; - --static void do_option_set PROTO ((pair *, -- struct option_cache *, -- enum statement_op)); -- - /* Parse all available options out of the specified packet. */ - - int parse_options (packet) - struct packet *packet; - { -- int i; - struct option_cache *op = (struct option_cache *)0; - - /* Allocate a new option state. */ -@@ -112,8 +107,6 @@ - unsigned length; - struct universe *universe; - { -- unsigned char *t; -- const unsigned char *end = buffer + length; - unsigned len, offset; - int code; - struct option_cache *op = (struct option_cache *)0; -@@ -277,7 +270,6 @@ - const unsigned char *buffer, - unsigned length, struct universe *u) - { -- char *name; - struct buffer *bp = (struct buffer *)0; - - /* FQDN options have to be at least four bytes long. */ -@@ -466,9 +458,7 @@ - int priority_len; - unsigned char buffer [4096]; /* Really big buffer... */ - unsigned main_buffer_size, mb_max; -- unsigned mainbufix, bufix, agentix; -- int fileix; -- int snameix; -+ unsigned mainbufix, agentix; - unsigned option_size; - unsigned length; - int i; -@@ -476,7 +466,6 @@ - struct data_string ds; - pair pp, *hash; - int need_endopt = 0; -- int have_sso = 0; - int ocount = 0; - int ofbuf1=0, ofbuf2=0; - -@@ -814,7 +803,6 @@ - if (u -> options [code] && - ((u -> options [code] -> format [0] == 'E' && !oc) || - u -> options [code] -> format [0] == 'e')) { -- int uix; - static char *s, *t; - struct option_cache *tmp; - struct data_string name; -@@ -940,7 +928,6 @@ - toptstart = tix; - while (length) { - unsigned incr = length; -- int consumed = 0; - int *pix; - unsigned char *base; - -@@ -1053,7 +1040,6 @@ - const char *format; - { - const char *p; -- int retval = 0; - - p = format; - while (*p != '\0') { -@@ -2006,7 +1992,6 @@ - { - pair ocp; - int status; -- int i; - static struct option_cache *no_nwip; - struct data_string ds; - struct option_chain_head *head; -@@ -2020,7 +2005,6 @@ - - status = 0; - for (ocp = head -> first; ocp; ocp = ocp -> cdr) { -- struct option_cache *oc = (struct option_cache *)(ocp -> car); - if (store_option (result, universe, packet, - lease, client_state, in_options, - cfg_options, scope, -@@ -2206,7 +2190,6 @@ - { - struct universe *universe = find_option_universe (oc -> option, - vsname); -- int i; - - if (universe -> foreach) - (*universe -> foreach) (packet, lease, client_state, -@@ -2256,7 +2239,6 @@ - struct option_cache *oc; - { - pair *tail; -- pair np = (pair )0; - struct option_chain_head *head; - - if (universe -> index >= options -> universe_count) -@@ -2428,7 +2410,6 @@ - struct iaddr from; - struct hardware *hfrom; - { -- int i; - struct option_cache *op; - struct packet *decoded_packet; - #if defined (DEBUG_MEMORY_LEAKAGE) ---- dhcp-3.0.5/common/inet.c.warnings 2005-03-03 11:55:22.000000000 -0500 -+++ dhcp-3.0.5/common/inet.c 2007-03-29 13:45:34.000000000 -0400 -@@ -124,7 +124,7 @@ - struct iaddr subnet; - struct iaddr mask; - { -- int i, j, k; -+ int i; - struct iaddr rv; - - if (subnet.len > sizeof(subnet.iabuf)) ---- dhcp-3.0.5/common/tree.c.warnings 2006-07-17 11:34:44.000000000 -0400 -+++ dhcp-3.0.5/common/tree.c 2007-03-29 13:45:34.000000000 -0400 -@@ -249,8 +249,6 @@ - struct expression *expr; - int limit; - { -- struct expression *rv; -- - /* Allocate a node to enforce a limit on evaluation. */ - if (!expression_allocate (new, MDL)) - log_error ("no memory for limit expression"); -@@ -644,11 +642,10 @@ - struct binding_scope **scope; - struct expression *expr; - { -- ns_updrec *foo; - unsigned long ttl = 0; - char *tname; - struct data_string name, data; -- int r0, r1, r2, r3; -+ int r0, r1, r2; - - if (!result || *result) { - log_error ("evaluate_dns_expression called with non-null %s", -@@ -903,10 +900,7 @@ - struct binding_scope **scope; - struct expression *expr; - { -- struct data_string left, right; -- struct data_string rrtype, rrname, rrdata; -- unsigned long ttl; -- int srrtype, srrname, srrdata, sttl; -+ struct data_string left; - int bleft, bright; - int sleft, sright; - struct binding *binding; -@@ -1275,11 +1269,10 @@ - int line; - { - struct data_string data, other; -- unsigned long offset, len, i; -+ unsigned long offset, len; - int s0, s1, s2, s3; - int status; - struct binding *binding; -- char *s; - struct binding_value *bv; - - switch (expr -> op) { -@@ -1826,7 +1819,6 @@ - MDL); - - if (s0 && s1) { -- char *upper; - int i; - - /* The buffer must be a multiple of the number's -@@ -3127,8 +3119,6 @@ - int op_precedence (op1, op2) - enum expr_op op1, op2; - { -- int ov1, ov2; -- - return op_val (op1) - op_val (op2); - } - -@@ -3742,7 +3732,6 @@ - const char *file; - int line; - { -- int i; - struct binding_scope *binding_scope; - - if (!ptr || !*ptr) { ---- dhcp-3.0.5/common/alloc.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/common/alloc.c 2007-03-29 13:45:34.000000000 -0400 -@@ -48,7 +48,6 @@ - const char *file; - int line; - { -- int size; - struct option_chain_head *h; - - if (!ptr) { -@@ -109,7 +108,6 @@ - const char *file; - int line; - { -- int i; - struct option_chain_head *option_chain_head; - pair car, cdr; - -@@ -161,7 +159,6 @@ - const char *file; - int line; - { -- int size; - struct group *g; - - if (!ptr) { -@@ -222,7 +219,6 @@ - const char *file; - int line; - { -- int i; - struct group *group; - - if (!ptr || !*ptr) { -@@ -745,8 +741,6 @@ - const char *file; - int line; - { -- struct buffer *bp; -- - if (!ptr) { - log_error ("%s(%d): null pointer", file, line); - #if defined (POINTER_DEBUG) -@@ -834,8 +828,6 @@ - const char *file; - int line; - { -- struct dns_host_entry *bp; -- - if (!ptr || !*ptr) { - log_error ("%s(%d): null pointer", file, line); - #if defined (POINTER_DEBUG) -@@ -1037,7 +1029,6 @@ - const char *file; - int line; - { -- int size; - struct packet *p; - - if (!ptr) { -@@ -1157,7 +1148,6 @@ - const char *file; - int line; - { -- int size; - struct dns_zone *d; - - if (!ptr) { ---- dhcp-3.0.5/common/dns.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/common/dns.c 2007-03-29 13:45:34.000000000 -0400 -@@ -127,7 +127,6 @@ - isc_result_t find_tsig_key (ns_tsig_key **key, const char *zname, - struct dns_zone *zone) - { -- isc_result_t status; - ns_tsig_key *tkey; - - if (!zone) -@@ -201,7 +200,6 @@ - - isc_result_t dns_zone_lookup (struct dns_zone **zone, const char *name) - { -- struct dns_zone *tz = (struct dns_zone *)0; - int len; - char *tname = (char *)0; - isc_result_t status; -@@ -234,7 +232,6 @@ - const char *file; - int line; - { -- int i; - struct dns_zone *dns_zone; - - if (!ptr || !*ptr) { -@@ -397,9 +394,7 @@ - void cache_found_zone (ns_class class, - char *zname, struct in_addr *addrs, int naddrs) - { -- isc_result_t status = ISC_R_NOTFOUND; - struct dns_zone *zone = (struct dns_zone *)0; -- struct data_string nsaddrs; - int ix = strlen (zname); - - if (zname [ix - 1] == '.') ---- dhcp-3.0.5/common/resolv.c.warnings 2005-10-27 11:56:26.000000000 -0400 -+++ dhcp-3.0.5/common/resolv.c 2007-03-29 13:45:34.000000000 -0400 -@@ -50,10 +50,8 @@ - struct parse *cfile; - const char *val; - int token; -- int declaration = 0; - struct name_server *sp, *sl, *ns; - struct domain_search_list *dp, *dl, *nd; -- struct iaddr *iaddr; - - if ((file = open (path_resolv_conf, O_RDONLY)) < 0) { - log_error ("Can't open %s: %m", path_resolv_conf); -@@ -179,7 +177,6 @@ - - struct name_server *first_name_server () - { -- FILE *rc; - static TIME rcdate; - struct stat st; - -@@ -190,8 +187,6 @@ - return (struct name_server *)0; - } - if (st.st_mtime > rcdate) { -- char rcbuf [512]; -- char *s, *t, *u; - rcdate = cur_time + 1; - - read_resolv_conf (rcdate); ---- dhcp-3.0.5/common/execute.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/common/execute.c 2007-03-29 13:45:34.000000000 -0400 -@@ -54,8 +54,6 @@ - struct executable_statement *r, *e, *next; - int rc; - int status; -- unsigned long num; -- struct binding_scope *outer; - struct binding *binding; - struct data_string ds; - struct binding_scope *ns; -@@ -283,7 +281,6 @@ - binding -> next = (*scope) -> bindings; - (*scope) -> bindings = binding; - } else { -- badalloc: - dfree (binding, MDL); - binding = (struct binding *)0; - } -@@ -526,8 +523,6 @@ - const char *file; - int line; - { -- struct executable_statement *bp; -- - if (!ptr || !*ptr) { - log_error ("%s(%d): null pointer", file, line); - #if defined (POINTER_DEBUG) -@@ -650,8 +645,6 @@ - int indent; - { - struct executable_statement *r, *x; -- int result; -- int status; - const char *s, *t, *dot; - int col; - -@@ -906,10 +899,8 @@ - { - int status, sub; - struct executable_statement *s; -- unsigned long foo; - - if (is_data_expression (expr)) { -- struct executable_statement *e; - struct data_string cd, ds; - memset (&ds, 0, sizeof ds); - memset (&cd, 0, sizeof cd); -@@ -983,7 +974,6 @@ - { - struct executable_statement *foo; - int ok = 0; -- int result; - - for (foo = stmt; foo; foo = foo -> next) { - if ((*callback) (foo, vp, condp) != 0) ---- dhcp-3.0.5/common/discover.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/common/discover.c 2007-03-29 13:45:34.000000000 -0400 -@@ -124,16 +124,14 @@ - void discover_interfaces (state) - int state; - { -- struct interface_info *tmp, *ip; -+ struct interface_info *tmp; - struct interface_info *last, *next; - char buf [2048]; - struct ifconf ic; - struct ifreq ifr; - int i; - int sock; -- int address_count = 0; - struct subnet *subnet; -- struct shared_network *share; - struct sockaddr_in foo; - int ir; - struct ifreq *tif; -@@ -435,7 +433,6 @@ - for (tmp = interfaces; tmp; tmp = tmp -> next) { - struct ifreq ifr; - struct sockaddr sa; -- int b, sk; - - if (!tmp -> ifp) { - /* Make up an ifreq structure. */ -@@ -815,7 +812,6 @@ - { - struct interface_info *interface; - isc_result_t status; -- int foo; - - if (h -> type != dhcp_type_interface) - return ISC_R_INVALIDARG; -@@ -858,7 +854,6 @@ - const char *file, int line) - { - struct interface_info *interface; -- isc_result_t status; - - if (h -> type != dhcp_type_interface) - return ISC_R_INVALIDARG; -@@ -888,8 +883,6 @@ - const char *name, va_list ap) - { - struct interface_info *ip, *interface; -- struct client_config *config; -- struct client_state *client; - isc_result_t status; - - if (h -> type != dhcp_type_interface) ---- dhcp-3.0.5/common/comapi.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/common/comapi.c 2007-03-29 13:45:34.000000000 -0400 -@@ -143,7 +143,6 @@ - { - struct group_object *group; - isc_result_t status; -- int foo; - - if (h -> type != dhcp_type_group) - return ISC_R_INVALIDARG; -@@ -217,7 +216,6 @@ - { - struct group_object *group; - isc_result_t status; -- struct data_string ip_addrs; - - if (h -> type != dhcp_type_group) - return ISC_R_INVALIDARG; -@@ -240,7 +238,6 @@ - isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *file, int line) - { - struct group_object *group, *t; -- isc_result_t status; - - if (h -> type != dhcp_type_group) - return ISC_R_INVALIDARG; -@@ -271,7 +268,7 @@ - isc_result_t dhcp_group_signal_handler (omapi_object_t *h, - const char *name, va_list ap) - { -- struct group_object *group, *t; -+ struct group_object *group; - isc_result_t status; - int updatep = 0; - -@@ -453,7 +450,6 @@ - { - dhcp_control_object_t *control; - isc_result_t status; -- int foo; - unsigned long newstate; - - if (h -> type != dhcp_type_control) -@@ -488,7 +484,6 @@ - { - dhcp_control_object_t *control; - isc_result_t status; -- struct data_string ip_addrs; - - if (h -> type != dhcp_type_control) - return ISC_R_INVALIDARG; -@@ -511,9 +506,6 @@ - isc_result_t dhcp_control_destroy (omapi_object_t *h, - const char *file, int line) - { -- dhcp_control_object_t *control, *t; -- isc_result_t status; -- - if (h -> type != dhcp_type_control) - return ISC_R_INVALIDARG; - -@@ -524,9 +516,8 @@ - isc_result_t dhcp_control_signal_handler (omapi_object_t *h, - const char *name, va_list ap) - { -- dhcp_control_object_t *control, *t; -+ dhcp_control_object_t *control; - isc_result_t status; -- int updatep = 0; - - if (h -> type != dhcp_type_control) - return ISC_R_INVALIDARG; -@@ -580,7 +571,6 @@ - { - omapi_value_t *tv = (omapi_value_t *)0; - isc_result_t status; -- dhcp_control_object_t *control; - - /* First see if we were sent a handle. */ - if (ref) { -@@ -629,7 +619,6 @@ - { - struct subnet *subnet; - isc_result_t status; -- int foo; - - if (h -> type != dhcp_type_subnet) - return ISC_R_INVALIDARG; -@@ -675,7 +664,6 @@ - isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line) - { - struct subnet *subnet; -- isc_result_t status; - - if (h -> type != dhcp_type_subnet) - return ISC_R_INVALIDARG; -@@ -752,10 +740,6 @@ - omapi_object_t *id, - omapi_object_t *ref) - { -- omapi_value_t *tv = (omapi_value_t *)0; -- isc_result_t status; -- struct subnet *subnet; -- - /* Can't look up subnets yet. */ - - /* If we get to here without finding a subnet, no valid key was -@@ -784,7 +768,6 @@ - { - struct shared_network *shared_network; - isc_result_t status; -- int foo; - - if (h -> type != dhcp_type_shared_network) - return ISC_R_INVALIDARG; -@@ -832,7 +815,6 @@ - const char *file, int line) - { - struct shared_network *shared_network; -- isc_result_t status; - - if (h -> type != dhcp_type_shared_network) - return ISC_R_INVALIDARG; -@@ -922,10 +904,6 @@ - omapi_object_t *id, - omapi_object_t *ref) - { -- omapi_value_t *tv = (omapi_value_t *)0; -- isc_result_t status; -- struct shared_network *shared_network; -- - /* Can't look up shared_networks yet. */ - - /* If we get to here without finding a shared_network, no valid key was ---- dhcp-3.0.5/dhcpctl/dhcpctl.c.warnings 2004-06-10 13:59:24.000000000 -0400 -+++ dhcp-3.0.5/dhcpctl/dhcpctl.c 2007-03-29 14:25:41.000000000 -0400 -@@ -101,7 +101,6 @@ - dhcpctl_handle authinfo) - { - isc_result_t status; -- dhcpctl_status waitstatus; - - status = omapi_generic_new (connection, MDL); - if (status != ISC_R_SUCCESS) { -@@ -171,7 +170,6 @@ - { - isc_result_t status; - omapi_value_t *tv = (omapi_value_t *)0; -- omapi_data_string_t *value = (omapi_data_string_t *)0; - unsigned len; - int ip; - -@@ -263,7 +261,6 @@ - isc_result_t status; - omapi_typed_data_t *tv = (omapi_typed_data_t *)0; - omapi_data_string_t *name = (omapi_data_string_t *)0; -- int len; - - status = omapi_data_string_new (&name, strlen (value_name), MDL); - if (status != ISC_R_SUCCESS) -@@ -297,7 +294,6 @@ - isc_result_t status; - omapi_typed_data_t *tv = (omapi_typed_data_t *)0; - omapi_data_string_t *name = (omapi_data_string_t *)0; -- int len; - - status = omapi_data_string_new (&name, strlen (value_name), MDL); - if (status != ISC_R_SUCCESS) -@@ -386,7 +382,6 @@ - isc_result_t status; - omapi_typed_data_t *tv = (omapi_typed_data_t *)0; - omapi_data_string_t *name = (omapi_data_string_t *)0; -- int len; - - status = omapi_data_string_new (&name, strlen (value_name), MDL); - if (status != ISC_R_SUCCESS) -@@ -416,7 +411,6 @@ - isc_result_t status; - omapi_typed_data_t *tv = (omapi_typed_data_t *)0; - omapi_data_string_t *name = (omapi_data_string_t *)0; -- int len; - - status = omapi_data_string_new (&name, strlen (value_name), MDL); - if (status != ISC_R_SUCCESS) ---- dhcp-3.0.5/dhcpctl/callback.c.warnings 2004-06-10 13:59:23.000000000 -0400 -+++ dhcp-3.0.5/dhcpctl/callback.c 2007-03-29 14:25:57.000000000 -0400 -@@ -59,7 +59,6 @@ - { - dhcpctl_callback_object_t *callback; - omapi_object_t *inner; -- isc_result_t status; - - callback = dmalloc (sizeof *callback, MDL); - if (!callback) -@@ -162,8 +161,6 @@ - omapi_object_t *id, - omapi_object_t *p) - { -- int i; -- - if (p -> type != dhcpctl_callback_type) - return ISC_R_INVALIDARG; - ---- dhcp-3.0.5/dhcpctl/remote.c.warnings 2004-06-10 13:59:24.000000000 -0400 -+++ dhcp-3.0.5/dhcpctl/remote.c 2007-03-29 14:26:07.000000000 -0400 -@@ -354,8 +354,6 @@ - omapi_object_t *id, - omapi_object_t *p) - { -- int i; -- - if (p -> type != dhcpctl_remote_type) - return ISC_R_INVALIDARG; - ---- dhcp-3.0.5/dhcpctl/omshell.c.warnings 2005-10-27 11:56:26.000000000 -0400 -+++ dhcp-3.0.5/dhcpctl/omshell.c 2007-03-29 14:26:36.000000000 -0400 -@@ -82,11 +82,9 @@ - dhcpctl_handle connection; - dhcpctl_handle authenticator; - dhcpctl_handle oh; -- dhcpctl_data_string cid, ip_addr; -- dhcpctl_data_string result, groupname, identifier; - struct data_string secret; - const char *name = 0, *algorithm = "hmac-md5"; -- int i, j; -+ int i; - int port = 7911; - const char *server = "127.0.0.1"; - struct parse *cfile; -@@ -481,7 +479,6 @@ - val = buf; - do { - int intval = atoi (val); -- dotiszero: - if (intval > 255) { - parse_warn (cfile, - "dotted octet > 255: %s", ---- dhcp-3.0.5/dhcpctl/cltest.c.warnings 2004-06-10 13:59:23.000000000 -0400 -+++ dhcp-3.0.5/dhcpctl/cltest.c 2007-03-29 14:27:01.000000000 -0400 -@@ -60,9 +60,8 @@ - isc_result_t status, waitstatus; - dhcpctl_handle authenticator; - dhcpctl_handle connection; -- dhcpctl_handle host_handle, group_handle, interface_handle; -- dhcpctl_data_string cid; -- dhcpctl_data_string result, groupname, identifier; -+ dhcpctl_handle interface_handle; -+ dhcpctl_data_string result; - int i; - int mode = undefined; - const char *interface = 0; ---- dhcp-3.0.5/dst/dst_api.c.warnings 2001-02-22 02:22:08.000000000 -0500 -+++ dhcp-3.0.5/dst/dst_api.c 2007-03-29 13:45:34.000000000 -0400 -@@ -543,7 +543,8 @@ - return (NULL); - } - /* read in the key string */ -- fgets(enckey, sizeof(enckey), fp); -+ if (fgets(enckey, sizeof(enckey), fp) == NULL) -+ return NULL; - - /* If we aren't at end-of-file, something is wrong. */ - while ((c = getc(fp)) != EOF) ---- dhcp-3.0.5/dst/prandom.c.warnings 2001-02-22 02:22:09.000000000 -0500 -+++ dhcp-3.0.5/dst/prandom.c 2007-03-29 13:45:34.000000000 -0400 -@@ -335,7 +335,7 @@ - cnt += do_time(work); - } - while ((n = fread(buffer, sizeof(char), sizeof(buffer), pipe)) > 0) -- NULL; /* drain the pipe */ -+ continue; /* drain the pipe */ - pclose(pipe); - return (cnt); /* read how many bytes where read in */ - } ---- dhcp-3.0.5/minires/res_mkupdate.c.warnings 2004-06-10 13:59:43.000000000 -0400 -+++ dhcp-3.0.5/minires/res_mkupdate.c 2007-03-29 13:45:34.000000000 -0400 -@@ -108,7 +108,7 @@ - u_int16_t rtype, rclass; - u_int32_t n1, rttl; - u_char *dnptrs[20], **dpp, **lastdnptr; -- unsigned siglen, certlen; -+ unsigned certlen; - int keylen; - unsigned buflen = *blp; - u_char *buf = (unsigned char *)bp; ---- dhcp-3.0.5/minires/res_update.c.warnings 2004-06-10 13:59:44.000000000 -0400 -+++ dhcp-3.0.5/minires/res_update.c 2007-03-29 13:45:34.000000000 -0400 -@@ -88,7 +88,7 @@ - double answer[PACKETSZ / sizeof (double)]; - double packet[2*PACKETSZ / sizeof (double)]; - struct zonegrp *zptr, tgrp; -- int nzones = 0, nscount = 0; -+ int nscount = 0; - unsigned n; - unsigned rval; - struct sockaddr_in nsaddrs[MAXNS]; ---- dhcp-3.0.5/omapip/protocol.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/omapip/protocol.c 2007-03-29 13:46:36.000000000 -0400 -@@ -161,7 +161,6 @@ - omapi_remote_auth_t *ra; - omapi_value_t *signature; - isc_result_t status; -- u_int32_t foo; - unsigned auth_len; - - if (po -> type != omapi_type_protocol || -@@ -940,8 +939,6 @@ - omapi_object_t *id, - omapi_object_t *p) - { -- int i; -- - if (p -> type != omapi_type_protocol) - return ISC_R_INVALIDARG; - -@@ -1128,8 +1125,6 @@ - omapi_object_t *id, - omapi_object_t *p) - { -- int i; -- - if (p -> type != omapi_type_protocol_listener) - return ISC_R_INVALIDARG; - ---- dhcp-3.0.5/omapip/buffer.c.warnings 2005-10-06 15:05:46.000000000 -0400 -+++ dhcp-3.0.5/omapip/buffer.c 2007-03-29 13:46:54.000000000 -0400 -@@ -438,7 +438,6 @@ - int bytes_written; - unsigned first_byte; - omapi_buffer_t *buffer; -- unsigned char *bufp; - omapi_connection_object_t *c; - isc_result_t status; - -@@ -575,7 +574,6 @@ - u_int32_t value) - { - u_int32_t inbuf; -- isc_result_t status; - - inbuf = htonl (value); - -@@ -602,7 +600,6 @@ - u_int32_t value) - { - u_int16_t inbuf; -- isc_result_t status; - - inbuf = htons (value); - ---- dhcp-3.0.5/omapip/alloc.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/omapip/alloc.c 2007-03-29 13:47:04.000000000 -0400 -@@ -66,7 +66,6 @@ - { - unsigned char *foo; - unsigned len; -- int i; - VOIDPTR *bar; - #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \ - defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) ---- dhcp-3.0.5/omapip/connection.c.warnings 2004-11-24 12:39:17.000000000 -0500 -+++ dhcp-3.0.5/omapip/connection.c 2007-03-29 13:47:35.000000000 -0400 -@@ -111,10 +111,6 @@ - omapi_connection_object_t *obj; - int flag; - struct sockaddr_in local_sin; --#if defined (TRACING) -- trace_addr_t *addrs; -- u_int16_t naddrs; --#endif - - obj = (omapi_connection_object_t *)0; - status = omapi_connection_allocate (&obj, MDL); -@@ -1005,8 +1001,6 @@ - omapi_object_t *id, - omapi_object_t *m) - { -- int i; -- - if (m -> type != omapi_type_connection) - return ISC_R_INVALIDARG; - ---- dhcp-3.0.5/omapip/errwarn.c.warnings 2004-09-30 16:38:32.000000000 -0400 -+++ dhcp-3.0.5/omapip/errwarn.c 2007-03-29 13:50:21.000000000 -0400 -@@ -72,8 +72,10 @@ - - /* Also log it to stderr? */ - if (log_perror) { -- write (STDERR_FILENO, mbuf, strlen (mbuf)); -- write (STDERR_FILENO, "\n", 1); -+ if (write (STDERR_FILENO, mbuf, strlen (mbuf)) <= 0) -+ return; -+ if (write (STDERR_FILENO, "\n", 1) <= 0) -+ return; - } - - #if !defined (NOMINUM) -@@ -120,8 +122,10 @@ - #endif - - if (log_perror) { -- write (STDERR_FILENO, mbuf, strlen (mbuf)); -- write (STDERR_FILENO, "\n", 1); -+ if (write (STDERR_FILENO, mbuf, strlen (mbuf)) <= 0) -+ return 0; -+ if (write (STDERR_FILENO, "\n", 1) <= 0) -+ return 0; - } - - return 0; -@@ -147,8 +151,10 @@ - #endif - - if (log_perror) { -- write (STDERR_FILENO, mbuf, strlen (mbuf)); -- write (STDERR_FILENO, "\n", 1); -+ if (write (STDERR_FILENO, mbuf, strlen (mbuf)) <= 0) -+ return 0; -+ if (write (STDERR_FILENO, "\n", 1) <= 0) -+ return 0; - } - - return 0; -@@ -174,8 +180,10 @@ - #endif - - if (log_perror) { -- write (STDERR_FILENO, mbuf, strlen (mbuf)); -- write (STDERR_FILENO, "\n", 1); -+ if (write (STDERR_FILENO, mbuf, strlen (mbuf)) <= 0) -+ return 0; -+ if (write (STDERR_FILENO, "\n", 1) <= 0) -+ return 0; - } - - return 0; ---- dhcp-3.0.5/omapip/listener.c.warnings 2004-06-10 13:59:48.000000000 -0400 -+++ dhcp-3.0.5/omapip/listener.c 2007-03-29 13:50:51.000000000 -0400 -@@ -68,12 +68,9 @@ - omapi_addr_t *addr, - int max) - { -- struct hostent *he; -- int hix; - isc_result_t status; - omapi_listener_object_t *obj; - int i; -- struct in_addr ia; - - /* Get the handle. */ - obj = (omapi_listener_object_t *)0; -@@ -200,8 +197,6 @@ - SOCKLEN_T len; - omapi_connection_object_t *obj; - omapi_listener_object_t *listener; -- omapi_addr_t remote_addr; -- int i; - struct sockaddr_in addr; - int socket; - -@@ -223,7 +218,6 @@ - /* If we're recording a trace, remember the connection. */ - if (trace_record ()) { - trace_iov_t iov [3]; -- u_int32_t lsock; - iov [0].buf = (char *)&addr.sin_port; - iov [0].len = sizeof addr.sin_port; - iov [1].buf = (char *)&addr.sin_addr; -@@ -455,8 +449,6 @@ - omapi_object_t *id, - omapi_object_t *l) - { -- int i; -- - if (l -> type != omapi_type_listener) - return ISC_R_INVALIDARG; - ---- dhcp-3.0.5/omapip/generic.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/omapip/generic.c 2007-03-29 13:51:03.000000000 -0400 -@@ -292,7 +292,6 @@ - isc_result_t omapi_generic_clear_flags (omapi_object_t *o) - { - int i; -- isc_result_t status; - omapi_generic_object_t *g; - - if (o -> type != omapi_type_generic) ---- dhcp-3.0.5/omapip/support.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/omapip/support.c 2007-03-29 13:51:47.000000000 -0400 -@@ -53,7 +53,6 @@ - - omapi_object_type_t *omapi_object_types; - int omapi_object_type_count; --static int ot_max; - - #if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) - void omapi_type_relinquish () -@@ -298,7 +297,6 @@ - isc_result_t omapi_signal_in (omapi_object_t *handle, const char *name, ...) - { - va_list ap; -- omapi_object_t *outer; - isc_result_t status; - - if (!handle) -@@ -368,7 +366,6 @@ - const char *name, - omapi_typed_data_t *value) - { -- omapi_object_t *outer; - omapi_data_string_t *nds; - isc_result_t status; - -@@ -389,8 +386,6 @@ - isc_result_t status; - omapi_typed_data_t *tv = (omapi_typed_data_t *)0; - omapi_data_string_t *n = (omapi_data_string_t *)0; -- int len; -- int ip; - - status = omapi_data_string_new (&n, strlen (name), MDL); - if (status != ISC_R_SUCCESS) -@@ -415,8 +410,6 @@ - isc_result_t status; - omapi_typed_data_t *tv = (omapi_typed_data_t *)0; - omapi_data_string_t *n = (omapi_data_string_t *)0; -- int len; -- int ip; - - status = omapi_data_string_new (&n, strlen (name), MDL); - if (status != ISC_R_SUCCESS) -@@ -441,8 +434,6 @@ - isc_result_t status; - omapi_typed_data_t *tv = (omapi_typed_data_t *)0; - omapi_data_string_t *n = (omapi_data_string_t *)0; -- int len; -- int ip; - - status = omapi_data_string_new (&n, strlen (name), MDL); - if (status != ISC_R_SUCCESS) -@@ -467,8 +458,6 @@ - isc_result_t status; - omapi_typed_data_t *tv = (omapi_typed_data_t *)0; - omapi_data_string_t *n = (omapi_data_string_t *)0; -- int len; -- int ip; - - status = omapi_data_string_new (&n, strlen (name), MDL); - if (status != ISC_R_SUCCESS) ---- dhcp-3.0.5/omapip/handle.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/omapip/handle.c 2007-03-29 13:52:01.000000000 -0400 -@@ -76,7 +76,6 @@ - - isc_result_t omapi_object_handle (omapi_handle_t *h, omapi_object_t *o) - { -- int tabix; - isc_result_t status; - - if (o -> handle) { -@@ -285,7 +284,6 @@ - isc_result_t omapi_handle_td_lookup (omapi_object_t **obj, - omapi_typed_data_t *handle) - { -- isc_result_t status; - omapi_handle_t h; - - if (handle -> type == omapi_datatype_int) ---- dhcp-3.0.5/omapip/message.c.warnings 2004-11-24 12:39:17.000000000 -0500 -+++ dhcp-3.0.5/omapip/message.c 2007-03-29 13:52:15.000000000 -0400 -@@ -209,8 +209,6 @@ - isc_result_t omapi_message_destroy (omapi_object_t *h, - const char *file, int line) - { -- int i; -- - omapi_message_object_t *m; - if (h -> type != omapi_type_message) - return ISC_R_INVALIDARG; -@@ -261,8 +259,6 @@ - omapi_object_t *id, - omapi_object_t *m) - { -- int i; -- - if (m -> type != omapi_type_message) - return ISC_R_INVALIDARG; - ---- dhcp-3.0.5/omapip/convert.c.warnings 2004-11-24 12:39:17.000000000 -0500 -+++ dhcp-3.0.5/omapip/convert.c 2007-03-29 13:52:32.000000000 -0400 -@@ -165,7 +165,7 @@ - u_int32_t number; - static char h2a [] = "0123456789abcdef"; - int power = converted_length (inbuf, base, width); -- int i, j; -+ int i; - - if (base > 16) - return 0; ---- dhcp-3.0.5/omapip/hash.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/omapip/hash.c 2007-03-29 13:52:54.000000000 -0400 -@@ -81,8 +81,6 @@ - const char *file; - int line; - { -- int i; -- struct hash_bucket *hbc, *hbn = (struct hash_bucket *)0; - struct hash_table *ptr = *tp; - - #if defined (DEBUG_MEMORY_LEAKAGE) || \ -@@ -175,7 +173,6 @@ - const char *file; - int line; - { -- struct hash_bucket *hp; - #if defined (DEBUG_MALLOC_POOL) - for (hp = free_hash_buckets; hp; hp = hp -> next) { - if (hp == ptr) { ---- dhcp-3.0.5/omapip/array.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/omapip/array.c 2007-03-29 13:53:08.000000000 -0400 -@@ -46,7 +46,6 @@ - omapi_array_deref_t deref, - const char *file, int line) - { -- isc_result_t status; - omapi_array_t *aptr; - - if (!array || *array) -@@ -63,7 +62,6 @@ - isc_result_t omapi_array_free (omapi_array_t **array, - const char *file, int line) - { -- isc_result_t status; - omapi_array_t *aptr; - int i; - ---- dhcp-3.0.5/omapip/trace.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/omapip/trace.c 2007-03-29 13:53:31.000000000 -0400 -@@ -312,7 +312,7 @@ - void (*stop_tracing) (trace_type_t *), - const char *file, int line) - { -- trace_type_t *ttmp, *tptr; -+ trace_type_t *ttmp; - unsigned slen = strlen (name); - isc_result_t status; - -@@ -511,7 +511,6 @@ - trace_type_t *ttype; - unsigned paylen; - int status; -- int len; - fpos_t curpos; - - status = fgetpos (traceinfile, &curpos); -@@ -637,7 +636,6 @@ - unsigned bufmax = 0; - unsigned buflen = 0; - char *buf = (char *)0; -- isc_result_t status; - time_t result; - trace_type_t *ttp; - ---- dhcp-3.0.5/omapip/mrtrace.c.warnings 2004-09-30 16:23:07.000000000 -0400 -+++ dhcp-3.0.5/omapip/mrtrace.c 2007-03-29 13:53:49.000000000 -0400 -@@ -85,7 +85,6 @@ - unsigned buflen = 0; - char *buf = (char *)0; - isc_result_t status; -- u_int32_t id; - int i; - - if (trace_playback ()) { -@@ -412,7 +411,6 @@ - isc_result_t status; - - if (trace_playback ()) { -- int nscount; - status = trace_get_packet (&trace_mr_randomid, &buflen, &buf); - if (status != ISC_R_SUCCESS) { - log_error ("trace_mr_statp: no statp packet found."); ---- dhcp-3.0.5/relay/dhcrelay.c.warnings 2006-04-27 17:38:30.000000000 -0400 -+++ dhcp-3.0.5/relay/dhcrelay.c 2007-03-29 14:25:10.000000000 -0400 -@@ -734,7 +734,7 @@ - unsigned length; - struct in_addr giaddr; - { -- int is_dhcp = 0, agent_options_present = 0; -+ int is_dhcp = 0; - unsigned optlen; - u_int8_t *op, *nextop, *sp, *max, *end_pad = NULL; - ---- dhcp-3.0.5/server/dhcpd.c.warnings 2006-07-17 11:23:44.000000000 -0400 -+++ dhcp-3.0.5/server/dhcpd.c 2007-03-29 13:55:31.000000000 -0400 -@@ -215,9 +215,6 @@ - struct interface_info *ip; - struct parse *parse; - int lose; -- omapi_object_t *auth; -- struct tsig_key *key; -- omapi_typed_data_t *td; - int no_dhcpd_conf = 0; - int no_dhcpd_db = 0; - int no_dhcpd_pid = 0; -@@ -551,7 +548,8 @@ - if ((i = open (path_dhcpd_pid, - O_WRONLY | O_CREAT, 0644)) >= 0) { - sprintf (pbuf, "%d\n", (int)getpid ()); -- write (i, pbuf, strlen (pbuf)); -+ if (write (i, pbuf, strlen (pbuf)) <= 0) -+ exit(0); - close (i); - pidfilewritten = 1; - } -@@ -584,7 +582,8 @@ - if ((i = open (path_dhcpd_pid, - O_WRONLY | O_CREAT, 0644)) >= 0) { - sprintf (pbuf, "%d\n", (int)getpid ()); -- write (i, pbuf, strlen (pbuf)); -+ if (write (i, pbuf, strlen (pbuf)) <= 0) -+ exit(0); - close (i); - pidfilewritten = 1; - } -@@ -974,7 +973,6 @@ - necessary. */ - if (!ia) { - const char *fnn = "fallback-net"; -- char *s; - status = shared_network_allocate (&ip -> shared_network, MDL); - if (status != ISC_R_SUCCESS) - log_fatal ("No memory for shared subnet: %s", ---- dhcp-3.0.5/server/dhcp.c.warnings 2006-08-22 13:15:56.000000000 -0400 -+++ dhcp-3.0.5/server/dhcp.c 2007-03-29 13:57:38.000000000 -0400 -@@ -388,7 +388,6 @@ - int ours = 0; - struct option_cache *oc; - struct data_string data; -- int status; - char msgbuf [1024]; /* XXX */ - const char *s; - char smbuf [19]; -@@ -927,14 +926,13 @@ - char msgbuf [1024]; - struct data_string d1, prl; - struct option_cache *oc; -- struct expression *expr; - struct option_state *options = (struct option_state *)0; - struct dhcp_packet raw; - struct packet outgoing; - unsigned char dhcpack = DHCPACK; - struct subnet *subnet = (struct subnet *)0; - struct iaddr cip, gip; -- unsigned i, j; -+ unsigned i; - int nulltp; - struct sockaddr_in to; - struct in_addr from; -@@ -1308,7 +1306,6 @@ - unsigned i; - struct data_string data; - struct option_state *options = (struct option_state *)0; -- struct expression *expr; - struct option_cache *oc = (struct option_cache *)0; - struct iaddr myfrom; - -@@ -1514,15 +1511,11 @@ - TIME max_lease_time; - TIME default_lease_time; - struct option_cache *oc; -- struct expression *expr; -- int status; - isc_result_t result; -- int did_ping = 0; - TIME ping_timeout; - - unsigned i, j; -- int s1, s2; -- int val; -+ int s1; - int ignorep; - - /* If we're already acking this lease, don't do it again. */ -@@ -2742,12 +2735,9 @@ - struct in_addr from; - struct hardware hto; - int result; -- int i; - struct lease_state *state = lease -> state; - int nulltp, bootpp, unicastp = 1; -- struct option_tag *ot, *not; - struct data_string d1; -- struct option_cache *oc; - const char *s; - - if (!state) -@@ -2968,7 +2958,6 @@ - struct data_string d1; - int have_client_identifier = 0; - struct data_string client_identifier; -- int status; - struct hardware h; - - /* Quick check to see if the peer has leases. */ ---- dhcp-3.0.5/server/confpars.c.warnings 2006-07-20 12:02:52.000000000 -0400 -+++ dhcp-3.0.5/server/confpars.c 2007-03-29 14:01:32.000000000 -0400 -@@ -329,15 +329,12 @@ - enum dhcp_token token; - const char *val; - struct shared_network *share; -- char *t, *n; -- struct expression *expr; -- struct data_string data; -+ char *n; - struct hardware hardware; - struct executable_statement *et, *ep; - struct option *option; - struct option_cache *cache; - int lose; -- struct data_string key_id; - int known; - isc_result_t status; - -@@ -927,7 +924,6 @@ - "load balance settings."); - if (token != NUMBER) { - parse_warn (cfile, "expecting number"); -- badsplit: - skip_to_rbrace (cfile, 1); - dhcp_failover_state_dereference (&peer, MDL); - return; -@@ -1531,8 +1527,6 @@ - - /* See if there's already a pool into which we can merge this one. */ - for (pp = pool -> shared_network -> pools; pp; pp = pp -> next) { -- struct lease *l; -- - if (pp -> group -> statements != pool -> group -> statements) - continue; - #if defined (FAILOVER_PROTOCOL) -@@ -1843,7 +1837,6 @@ - char *name; - const char *tname; - struct executable_statement *stmt = (struct executable_statement *)0; -- struct expression *expr; - int new = 1; - isc_result_t status = ISC_R_FAILURE; - -@@ -2252,7 +2245,6 @@ - unsigned char addr [4]; - unsigned len = sizeof addr; - int declaration = 0; -- struct interface_info *ip; - isc_result_t status; - - subnet = (struct subnet *)0; -@@ -2546,8 +2538,6 @@ - char tbuf [32]; - struct lease *lease; - struct executable_statement *on; -- struct expression *exp; -- struct data_string ds; - int lose; - TIME t; - char *s; -@@ -2973,7 +2963,6 @@ - - token = peek_token (&val, (unsigned *)0, cfile); - if (token == STRING) { -- unsigned char *tuid; - token = next_token (&val, &buflen, cfile); - binding -> value -> type = binding_data; - binding -> value -> value.data.len = buflen; -@@ -3130,7 +3119,6 @@ - int dynamic = 0; - struct subnet *subnet; - struct shared_network *share; -- struct pool *p; - struct pool *pool; - isc_result_t status; - ---- dhcp-3.0.5/server/db.c.warnings 2006-07-19 12:45:30.000000000 -0400 -+++ dhcp-3.0.5/server/db.c 2007-03-29 14:02:00.000000000 -0400 -@@ -56,7 +56,6 @@ - struct tm *t; - char tbuf [64]; - int errors = 0; -- int i; - struct binding *b; - char *s; - -@@ -199,7 +198,6 @@ - } - } - if (lease -> uid_len) { -- int i; - s = quotify_buf (lease -> uid, lease -> uid_len, MDL); - if (s) { - fprintf (db_file, "\n uid \"%s\";", s); -@@ -467,7 +465,6 @@ - struct group_object *group; - { - int errors = 0; -- int i; - - /* If the lease file is corrupt, don't try to write any more leases - until we've written a good lease file. */ -@@ -625,8 +622,6 @@ - { - struct collection *lp; - struct class *cp; -- struct hash_bucket *bp; -- int i; - - for (lp = collections; lp; lp = lp -> next) { - for (cp = lp -> classes; cp; cp = cp -> nic) { ---- dhcp-3.0.5/server/failover.c.warnings 2006-09-22 12:29:44.000000000 -0400 -+++ dhcp-3.0.5/server/failover.c 2007-03-29 14:19:10.000000000 -0400 -@@ -57,7 +57,6 @@ - { - dhcp_failover_state_t *state; - isc_result_t status; -- dhcp_failover_listener_t *l; - - for (state = failover_states; state; state = state -> next) { - dhcp_failover_state_transition (state, "startup"); -@@ -174,7 +173,6 @@ - { - isc_result_t status; - dhcp_failover_link_t *obj; -- omapi_value_t *value = (omapi_value_t *)0; - dhcp_failover_state_t *state; - omapi_object_t *o; - int i; -@@ -276,8 +274,6 @@ - isc_result_t status; - dhcp_failover_link_t *link; - omapi_object_t *c; -- u_int16_t nlen; -- u_int32_t vlen; - dhcp_failover_state_t *s, *state = (dhcp_failover_state_t *)0; - - if (h -> type != dhcp_type_failover_link) { -@@ -591,7 +587,6 @@ - unsigned op_size; - unsigned op_count; - int i; -- isc_result_t status; - - if (link -> imsg_count + 2 > link -> imsg_len) { - log_error ("FAILOVER: message overflow at option code."); -@@ -1121,8 +1116,6 @@ - omapi_object_t *id, - omapi_object_t *p) - { -- int i; -- - if (p -> type != dhcp_type_failover_listener) - return ISC_R_INVALIDARG; - -@@ -1182,11 +1175,8 @@ - const char *name, va_list ap) - { - isc_result_t status; -- omapi_connection_object_t *c; -- omapi_protocol_object_t *obj; - dhcp_failover_state_t *state; - dhcp_failover_link_t *link; -- char *peer_name; - - if (!o || o -> type != dhcp_type_failover_state) - return ISC_R_INVALIDARG; -@@ -1831,7 +1821,6 @@ - enum failover_state previous_state = state -> partner.state; - enum failover_state new_state; - int startupp; -- isc_result_t status; - - new_state = msg -> server_state; - startupp = (msg -> server_flags & FTF_STARTUP) ? 1 : 0; -@@ -2185,7 +2174,6 @@ - struct lease *next = (struct lease *)0; - struct shared_network *s; - struct pool *p; -- int polarity; - binding_state_t peer_lease_state; - binding_state_t my_lease_state; - struct lease **lq; -@@ -2328,7 +2316,6 @@ - - int dhcp_failover_state_pool_check (dhcp_failover_state_t *state) - { -- struct lease *lp; - struct shared_network *s; - struct pool *p; - -@@ -2647,7 +2634,7 @@ - - void dhcp_failover_keepalive (void *vs) - { -- dhcp_failover_state_t *state = vs; -+ return; - } - - void dhcp_failover_reconnect (void *vs) -@@ -2681,8 +2668,6 @@ - void dhcp_failover_startup_timeout (void *vs) - { - dhcp_failover_state_t *state = vs; -- isc_result_t status; -- - #if defined (DEBUG_FAILOVER_TIMING) - log_info ("dhcp_failover_startup_timeout"); - #endif -@@ -2693,7 +2678,6 @@ - void dhcp_failover_link_startup_timeout (void *vl) - { - dhcp_failover_link_t *link = vl; -- isc_result_t status; - omapi_object_t *p; - - for (p = (omapi_object_t *)link; p -> inner; p = p -> inner) -@@ -3172,7 +3156,6 @@ - int dhcp_failover_state_match (dhcp_failover_state_t *state, - u_int8_t *addr, unsigned addrlen) - { -- struct option_cache *oc; - struct data_string ds; - int i; - -@@ -3709,7 +3692,6 @@ - omapi_object_t *connection, - int msg_type, ...) - { -- unsigned count = 0; - unsigned size = 0; - int bad_option = 0; - int opix = 0; -@@ -3822,7 +3804,6 @@ - { - dhcp_failover_state_t *state = vstate; - dhcp_failover_link_t *link; -- isc_result_t status; - - #if defined (DEBUG_FAILOVER_TIMING) - log_info ("dhcp_failover_timeout"); -@@ -3942,7 +3923,6 @@ - dhcp_failover_link_t *link; - dhcp_failover_state_t *state; - isc_result_t status; -- char hba [32]; - #if defined (DEBUG_FAILOVER_MESSAGES) - char obuf [64]; - unsigned obufix = 0; ---- dhcp-3.0.5/server/omapi.c.warnings 2006-02-22 17:43:27.000000000 -0500 -+++ dhcp-3.0.5/server/omapi.c 2007-03-29 14:20:32.000000000 -0400 -@@ -208,7 +208,6 @@ - { - struct lease *lease; - isc_result_t status; -- int foo; - - if (h -> type != dhcp_type_lease) - return ISC_R_INVALIDARG; -@@ -378,7 +377,6 @@ - isc_result_t dhcp_lease_destroy (omapi_object_t *h, const char *file, int line) - { - struct lease *lease; -- isc_result_t status; - - if (h -> type != dhcp_type_lease) - return ISC_R_INVALIDARG; -@@ -455,7 +453,6 @@ - { - struct lease *lease; - isc_result_t status; -- int updatep = 0; - - if (h -> type != dhcp_type_lease) - return ISC_R_INVALIDARG; -@@ -876,9 +873,8 @@ - omapi_data_string_t *name, - omapi_typed_data_t *value) - { -- struct host_decl *host, *hp; -+ struct host_decl *host; - isc_result_t status; -- int foo; - - if (h -> type != dhcp_type_host) - return ISC_R_INVALIDARG; -@@ -1137,7 +1133,6 @@ - isc_result_t dhcp_host_destroy (omapi_object_t *h, const char *file, int line) - { - struct host_decl *host; -- isc_result_t status; - - if (h -> type != dhcp_type_host) - return ISC_R_INVALIDARG; -@@ -1558,7 +1553,6 @@ - { - struct pool *pool; - isc_result_t status; -- int foo; - - if (h -> type != dhcp_type_pool) - return ISC_R_INVALIDARG; -@@ -1604,8 +1598,6 @@ - isc_result_t dhcp_pool_destroy (omapi_object_t *h, const char *file, int line) - { - struct pool *pool; -- isc_result_t status; -- struct permit *pc, *pn; - - if (h -> type != dhcp_type_pool) - return ISC_R_INVALIDARG; -@@ -1702,10 +1694,6 @@ - isc_result_t dhcp_pool_lookup (omapi_object_t **lp, - omapi_object_t *id, omapi_object_t *ref) - { -- omapi_value_t *tv = (omapi_value_t *)0; -- isc_result_t status; -- struct pool *pool; -- - /* Can't look up pools yet. */ - - /* If we get to here without finding a pool, no valid key was -@@ -1734,7 +1722,6 @@ - { - struct class *class; - isc_result_t status; -- int foo; - - if (h -> type != dhcp_type_class) - return ISC_R_INVALIDARG; -@@ -1780,8 +1767,6 @@ - isc_result_t dhcp_class_destroy (omapi_object_t *h, const char *file, int line) - { - struct class *class; -- isc_result_t status; -- int i; - - if (h -> type != dhcp_type_class && h -> type != dhcp_type_subclass) - return ISC_R_INVALIDARG; -@@ -1881,10 +1866,6 @@ - isc_result_t dhcp_class_lookup (omapi_object_t **lp, - omapi_object_t *id, omapi_object_t *ref) - { -- omapi_value_t *tv = (omapi_value_t *)0; -- isc_result_t status; -- struct class *class; -- - /* Can't look up classs yet. */ - - /* If we get to here without finding a class, no valid key was -@@ -1913,7 +1894,6 @@ - { - struct subclass *subclass; - isc_result_t status; -- int foo; - - if (h -> type != dhcp_type_subclass) - return ISC_R_INVALIDARG; -@@ -2008,10 +1988,6 @@ - isc_result_t dhcp_subclass_lookup (omapi_object_t **lp, - omapi_object_t *id, omapi_object_t *ref) - { -- omapi_value_t *tv = (omapi_value_t *)0; -- isc_result_t status; -- struct subclass *subclass; -- - /* Can't look up subclasss yet. */ - - /* If we get to here without finding a subclass, no valid key was ---- dhcp-3.0.5/server/mdb.c.warnings 2006-07-18 14:16:25.000000000 -0400 -+++ dhcp-3.0.5/server/mdb.c 2007-03-29 14:21:32.000000000 -0400 -@@ -238,7 +238,6 @@ - struct host_decl *hp = (struct host_decl *)0; - struct host_decl *np = (struct host_decl *)0; - struct host_decl *foo; -- struct executable_statement *esp; - int hw_head = 0, uid_head = 1; - - /* Don't need to do it twice. */ -@@ -373,7 +372,6 @@ - const unsigned char *haddr, unsigned hlen, - const char *file, int line) - { -- struct host_decl *foo; - struct hardware h; - - h.hlen = hlen + 1; -@@ -403,7 +401,6 @@ - struct iaddr *addr, struct shared_network *share) - { - int i; -- struct subnet *subnet; - struct iaddr ip_address; - struct host_decl *hp; - struct data_string fixed_addr; -@@ -453,12 +450,11 @@ - struct pool *pool; - struct lease **lpchain; - { -- struct lease *address_range, *lp, *plp; -+ struct lease *address_range; - struct iaddr net; - unsigned min, max, i; - char lowbuf [16], highbuf [16], netbuf [16]; - struct shared_network *share = subnet -> shared_network; -- isc_result_t status; - struct lease *lt = (struct lease *)0; - - /* All subnets should have attached shared network structures. */ -@@ -745,7 +741,6 @@ - struct lease *lease; - { - struct lease *comp = (struct lease *)0; -- isc_result_t status; - - if (find_lease_by_ip_addr (&comp, lease -> ip_addr, MDL)) { - if (!comp -> pool) { -@@ -795,7 +790,6 @@ - int enter_uid = 0; - int enter_hwaddr = 0; - struct lease *lp, **lq, *prev; -- TIME lp_next_state; - - #if defined (FAILOVER_PROTOCOL) - /* We must commit leases before sending updates regarding them -@@ -1475,7 +1469,6 @@ - void *vpool; - { - struct pool *pool; -- struct lease *lt = (struct lease *)0; - struct lease *next = (struct lease *)0; - struct lease *lease = (struct lease *)0; - struct lease **lptr [5]; -@@ -2013,7 +2006,6 @@ - { - struct shared_network *s; - struct pool *p; -- struct hash_bucket *hb; - int i; - struct lease *l; - struct lease **lptr [5]; ---- dhcp-3.0.5/server/ddns.c.warnings 2005-03-03 11:55:24.000000000 -0500 -+++ dhcp-3.0.5/server/ddns.c 2007-03-29 14:21:51.000000000 -0400 -@@ -224,7 +224,6 @@ - struct data_string ddns_fwd_name; - struct data_string ddns_rev_name; - struct data_string ddns_dhcid; -- unsigned len; - struct data_string d1; - struct option_cache *oc; - int s1, s2; -@@ -659,7 +658,6 @@ - struct data_string ddns_rev_name; - struct data_string ddns_dhcid; - isc_result_t rcode; -- struct binding *binding; - int result = 0; - int client_updated = 0; - diff --git a/dhcp-3.0.6-dhclient-usage.patch b/dhcp-3.0.6-dhclient-usage.patch deleted file mode 100644 index 48c44db..0000000 --- a/dhcp-3.0.6-dhclient-usage.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff -up dhcp-3.0.6/client/dhclient.c.usage dhcp-3.0.6/client/dhclient.c ---- dhcp-3.0.6/client/dhclient.c.usage 2007-08-15 11:48:12.000000000 -0400 -+++ dhcp-3.0.6/client/dhclient.c 2007-08-15 11:50:22.000000000 -0400 -@@ -808,16 +808,25 @@ int main (argc, argv, envp) - - static void usage () - { -- log_info ("%s %s", message, DHCP_VERSION); -- log_info (copyright); -- log_info (arr); -- log_info (url); -- -- log_error ("Usage: dhclient [-1dqr] [-nw] [-p ] %s", -- "[-s server]"); -- log_error (" [-cf config-file] [-lf lease-file]%s", -- "[-pf pid-file] [-e VAR=val]"); -- log_fatal (" [-sf script-file] [interface]"); -+ printf ("%s %s\n", message, DHCP_VERSION); -+ printf (copyright); -+ printf ("\n"); -+ printf (arr); -+ printf ("\n"); -+ printf (url); -+ printf ("\n"); -+ -+ printf ("Usage: dhclient [-1dqr] [-nw] [-p ] %s", -+ "[-s server]"); -+ printf (" [-cf config-file] [-lf lease-file]%s", -+ "[-pf pid-file] [-e VAR=val]"); -+ printf (" [ -I ] [-B]\n"); -+ printf (" [ -H | -F ] [ -T ]\n"); -+ printf (" [ -V ]\n"); -+ printf (" [ -R ]\n"); -+ printf (" [-sf script-file] [interface]\n"); -+ -+ exit (EXIT_FAILURE); - } - - isc_result_t find_class (struct class **c, diff --git a/dhcp-3.0.6-libdhcp4client.patch b/dhcp-3.0.6-libdhcp4client.patch deleted file mode 100644 index 37310cd..0000000 --- a/dhcp-3.0.6-libdhcp4client.patch +++ /dev/null @@ -1,1093 +0,0 @@ -diff -up dhcp-3.0.6/client/dhclient.c.libdhcp4client dhcp-3.0.6/client/dhclient.c ---- dhcp-3.0.6/client/dhclient.c.libdhcp4client 2007-08-15 16:24:55.000000000 -0400 -+++ dhcp-3.0.6/client/dhclient.c 2007-08-15 16:26:24.000000000 -0400 -@@ -82,16 +82,52 @@ int quiet=0; - int nowait=0; - int bootp_broadcast_always = 0; - -+#ifdef LIBDHCP -+FILE *leaseFile = NULL; -+#endif -+ - extern u_int32_t default_requested_options[]; - - static void usage PROTO ((void)); - - void do_release(struct client_state *); - -+#ifdef LIBDHCP -+#include "libdhcp_control.h" -+LIBDHCP_Control *libdhcp_control; -+static void libdhcp_dispatch(void) -+{ -+ struct timeval tv = { 0, 0 }, *tvp; -+ isc_result_t status; -+ -+ /* Wait for a packet, or a timeout, or libdhcp being finished */ -+ do { -+ tvp = process_outstanding_timeouts(&tv); -+ status = omapi_one_dispatch(0, tvp); -+ -+ if (libdhcp_control && ((status == ISC_R_TIMEDOUT) || (libdhcp_control->timeout && (time(NULL) >= (libdhcp_control->timeout + libdhcp_control->now))))) { -+ if (libdhcp_control->callback) -+ libdhcp_control->callback(libdhcp_control, DHC_TIMEDOUT, NULL); -+ -+ break; -+ } -+ } while ((status != ISC_R_TIMEDOUT) && ((!libdhcp_control) || (!(libdhcp_control->finished)))); -+} -+ -+extern void omapi_free_all_pointers(void); -+ -+__attribute__ ((visibility ("default"))) -+int dhcpv4_client (libdhcp_ctl, argc, argv, envp) -+ LIBDHCP_Control *libdhcp_ctl; -+#else - int main (argc, argv, envp) -+#endif - int argc; - char **argv, **envp; - { -+#ifdef LIBDHCP -+ libdhcp_control = libdhcp_ctl; -+#endif - int i; - struct servent *ent; - struct interface_info *ip; -@@ -119,6 +155,7 @@ int main (argc, argv, envp) - char *arg_conf = NULL; - int arg_conf_len = 0; - -+#ifndef LIBDHCP - /* Make sure we have stdin, stdout and stderr. */ - i = open ("/dev/null", O_RDWR); - if (i == 0) -@@ -139,6 +176,7 @@ int main (argc, argv, envp) - #if !(defined (DEBUG) || defined (SYSLOG_4_2) || defined (__CYGWIN32__)) - setlogmask (LOG_UPTO (LOG_INFO)); - #endif -+#endif - - /* Set up the OMAPI. */ - status = omapi_init (); -@@ -431,8 +469,12 @@ int main (argc, argv, envp) - } - } - -+#ifdef LIBDHCP -+ if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_PID_FILE)) -+#endif - write_client_pid_file(); - -+#ifndef LIBDHCP - if (!quiet) { - log_info ("%s %s", message, DHCP_VERSION); - log_info (copyright); -@@ -441,6 +483,7 @@ int main (argc, argv, envp) - log_info ("%s", ""); - } else - log_perror = 0; -+#endif - - /* If we're given a relay agent address to insert, for testing - purposes, figure out what it is. */ -@@ -672,11 +715,17 @@ int main (argc, argv, envp) - arg_conf_len = 0; - } - -+#ifdef LIBDHCP -+ if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_LEASE_DATABASE)) { -+#endif - /* Parse the lease database. */ - read_client_leases (); - - /* Rewrite the lease database... */ - rewrite_client_leases (); -+#ifdef LIBDHCP -+ } -+#endif - - /* XXX */ - /* config_counter(&snd_counter, &rcv_counter); */ -@@ -695,7 +744,7 @@ int main (argc, argv, envp) - if (!persist) { - /* Nothing more to do. */ - log_info ("No broadcast interfaces found - exiting."); -- exit (0); -+ return (0); - } - } else if (!release_mode) { - /* Call the script with the list of interfaces. */ -@@ -789,6 +838,7 @@ int main (argc, argv, envp) - dmalloc_outstanding = 0; - #endif - -+#ifndef LIBDHCP - /* If we're not supposed to wait before getting the address, - don't. */ - if (nowait) -@@ -801,6 +851,126 @@ int main (argc, argv, envp) - - /* Start dispatching packets and timeouts... */ - dispatch (); -+#else -+ if (libdhcp_control) { -+ if (libdhcp_control->timeout) -+ libdhcp_control->now = time(NULL); -+ else -+ libdhcp_control->now = 0; -+ } -+ -+ libdhcp_dispatch(); -+ -+ /* libdhcp is finished with us. */ -+ -+ /* close all file descriptors: */ -+ for (ip = interfaces; ip; ip = ip->next) { -+ shutdown(ip->wfdesc, SHUT_RDWR); -+ close(ip->wfdesc); -+ -+ if (ip->rfdesc != ip->wfdesc) -+ close(ip->rfdesc); -+ } -+ -+ if (fallback_interface != 0) { -+ ip = fallback_interface; -+ shutdown(ip->wfdesc, SHUT_RDWR); -+ close(ip->wfdesc); -+ -+ if (ip->rfdesc != ip->wfdesc) -+ close(ip->rfdesc); -+ } -+ -+ if (leaseFile) -+ fclose (leaseFile); -+ -+ closelog(); -+ -+ char *current_pid_file = _PATH_DHCLIENT_PID; -+ -+ /* Free ALL allocated memory: */ -+ omapi_free_all_pointers(); -+ -+ /* Re-Initialize globals: */ -+ client_env = 0; -+ client_env_count = 0; -+ default_lease_time = 43200; -+ -+ dhcp_max_agent_option_packet_length = 0; -+ iaddr_any.len = 4; -+ memset(&(iaddr_any.iabuf[0]), '\0', 4); -+ iaddr_broadcast.len = 4; -+ memset(&(iaddr_broadcast.iabuf[0]), 0xff, 4); -+ interfaces_requested = 0; -+ leaseFile = 0; -+ -+ libdhcp_control = 0; -+ -+ local_port = 0; -+ no_daemon = 0; -+ nowait = 0; -+ onetry = 0; -+ quiet = 0; -+ max_lease_time = 86400; -+ path_dhclient_conf = _PATH_DHCLIENT_CONF; -+ path_dhclient_db = _PATH_DHCLIENT_DB; -+ path_dhclient_pid = _PATH_DHCLIENT_PID; -+ strcpy(&(path_dhclient_script_array[0]), _PATH_DHCLIENT_SCRIPT); -+ path_dhclient_script = path_dhclient_script_array; -+ remote_port = 0; -+ resolver_inited = 0; -+ log_perror = 1; -+ global_scope = NULL; -+ root_group = NULL; -+ group_name_hash = NULL; -+ interfaces = NULL; -+ dummy_interfaces = NULL; -+ fallback_interface = NULL; -+ extern int have_setup_fallback; -+ have_setup_fallback = 0; -+ quiet_interface_discovery = 1; -+#ifndef LIBDHCP -+ timeouts = NULL; -+#endif -+ dhcp_type_interface = NULL; -+ interface_vector = NULL; -+ interface_count = 0; -+ interface_max = 0; -+ name_servers = 0; -+ domains = 0; -+ dhcp_type_interface = NULL; -+ dhcp_type_group = NULL; -+ dhcp_type_shared_network = NULL; -+ dhcp_type_control = NULL; -+ memset(&dhcp_universe, '\0', sizeof(struct universe)); -+ memset(&nwip_universe, '\0', sizeof(struct universe)); -+ memset(&fqdn_universe, '\0', sizeof(struct universe)); -+ universe_hash = 0; -+ universes = 0; -+ universe_count = 0; -+ universe_max = 0; -+ config_universe = 0; -+ extern struct hash_bucket *free_hash_buckets; -+ free_hash_buckets = NULL; -+ extern struct dhcp_packet *dhcp_free_list; -+ dhcp_free_list = NULL; -+ extern struct packet *packet_free_list; -+ packet_free_list = NULL; -+ extern struct binding_value *free_binding_values; -+ free_binding_values = NULL; -+ extern struct expression *free_expressions; -+ free_expressions = NULL; -+ extern struct option_cache *free_option_caches; -+ free_option_caches = NULL; -+ extern struct packet *free_packets; -+ free_packets = NULL; -+ extern pair free_pairs; -+ free_pairs = NULL; -+ extern omapi_io_object_t omapi_io_states; -+ memset(&omapi_io_states, '\0', sizeof(omapi_io_states)); -+ dhcp_control_object = NULL; -+ unlink(current_pid_file); -+#endif - - /*NOTREACHED*/ - return 0; -@@ -1191,7 +1361,20 @@ void dhcpack (packet) - if (client -> new -> rebind < cur_time) - client -> new -> rebind = TIME_MAX; - -+#ifdef LIBDHCP -+ /* We need the server's siaddr for the 'bootServer' -+ * pump option -+ */ -+ u_int32_t set_siaddr = 0; -+ set_siaddr = client->packet.siaddr.s_addr; -+ client->packet.siaddr.s_addr = packet->raw->siaddr.s_addr; -+#endif -+ - bind_lease (client); -+ -+#ifdef LIBDHCP -+ client->packet.siaddr.s_addr = set_siaddr; -+#endif - } - - void bind_lease (client) -@@ -1227,6 +1410,9 @@ void bind_lease (client) - return; - } - -+#ifdef LIBDHCP -+ if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_LEASE_DATABASE)) -+#endif - /* Write out the new lease. */ - write_client_lease (client, client -> new, 0, 0); - -@@ -1327,11 +1513,13 @@ int commit_leases () - return 0; - } - -+#ifndef LIBDHCP - int write_lease (lease) - struct lease *lease; - { - return 0; - } -+#endif - - int write_host (host) - struct host_decl *host; -@@ -1902,6 +2090,10 @@ void state_panic (cpp) - tell the shell script that we failed to allocate an address, - and try again later. */ - if (onetry) { -+#ifdef LIBDHCP -+ script_init (client, "FAIL", (struct string_list *)0); -+ return; -+#endif - if (!quiet) - log_info ("Unable to obtain a lease on first try.%s", - " Exiting."); -@@ -2506,7 +2698,9 @@ void destroy_client_lease (lease) - free_client_lease (lease, MDL); - } - -+#ifndef LIBDHCP - FILE *leaseFile; -+#endif - - void rewrite_client_leases () - { -@@ -2902,6 +3096,54 @@ void script_write_params (client, prefix - int script_go (client) - struct client_state *client; - { -+#ifdef LIBDHCP -+ struct string_list *sp; -+ -+ if (libdhcp_control && libdhcp_control->callback) { -+ int dhcmsg; -+ char *reason=""; -+ -+ for (sp = client->env; sp; sp = sp->next) -+ if (strncmp(sp->string, "reason=", 7) == 0) { -+ reason = sp->string + 7; -+ break; -+ } -+ -+ if (strcmp(reason,"NBI") == 0) -+ dhcmsg = DHC4_NBI; -+ else if (strcmp(reason,"PREINIT") == 0) -+ dhcmsg = DHC4_PREINIT; -+ else if (strcmp(reason,"BOUND") == 0) -+ dhcmsg = DHC4_BOUND; -+ else if (strcmp(reason,"RENEW") == 0) -+ dhcmsg = DHC4_RENEW; -+ else if (strcmp(reason,"REBOOT") == 0) -+ dhcmsg = DHC4_REBOOT; -+ else if (strcmp(reason,"REBIND") == 0) -+ dhcmsg = DHC4_REBIND; -+ else if (strcmp(reason,"STOP") == 0) -+ dhcmsg = DHC4_STOP; -+ else if (strcmp(reason,"MEDIUM") == 0) -+ dhcmsg = DHC4_MEDIUM; -+ else if (strcmp(reason,"TIMEOUT") == 0) -+ dhcmsg = DHC4_TIMEOUT; -+ else if (strcmp(reason,"FAIL") == 0) -+ dhcmsg = DHC4_FAIL; -+ else if (strcmp(reason,"EXPIRE") == 0) -+ dhcmsg = DHC4_EXPIRE; -+ else if (strcmp(reason,"RELEASE") == 0) -+ dhcmsg = DHC4_RELEASE; -+ else -+ dhcmsg = DHC4_NBI; -+ -+ (*libdhcp_control->callback) (libdhcp_control, dhcmsg, client); -+ -+ if (libdhcp_control->decline) -+ return 1; -+ } -+ -+ return 0; -+#else - char *scriptName; - char *argv [2]; - char **envp; -@@ -2978,6 +3220,7 @@ int script_go (client) - GET_TIME (&cur_time); - return (WIFEXITED (wstatus) ? - WEXITSTATUS (wstatus) : -WTERMSIG (wstatus)); -+#endif - } - - void client_envadd (struct client_state *client, -@@ -3061,6 +3304,9 @@ void go_daemon () - - /* Don't become a daemon if the user requested otherwise. */ - if (no_daemon) { -+#ifdef LIBDHCP -+ if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_PID_FILE )) -+#endif - write_client_pid_file (); - return; - } -@@ -3070,6 +3316,10 @@ void go_daemon () - return; - state = 1; - -+#ifdef LIBDHCP -+ return; -+#endif -+ - /* Stop logging to stderr... */ - log_perror = 0; - -diff -up dhcp-3.0.6/omapip/alloc.c.libdhcp4client dhcp-3.0.6/omapip/alloc.c ---- dhcp-3.0.6/omapip/alloc.c.libdhcp4client 2007-08-15 16:24:55.000000000 -0400 -+++ dhcp-3.0.6/omapip/alloc.c 2007-08-15 16:24:55.000000000 -0400 -@@ -40,6 +40,33 @@ static char copyright[] = - - #include - -+#ifdef LIBDHCP -+/* OK, we need a quick and dirty way of freeing all memory used by libdhcp. -+ All pointers will be stored in a glibc tree on alloc, and removed on free. -+ This is not too expensive for light single-call library use. -+*/ -+#include -+extern void tdestroy (void *root, void (*free_node)(void *nodep)); -+static void *all_pointers=0L; -+static int ptr_comparator(const void *p1, const void *p2) { -+ return ((p1 == p2) ? 0 : ((p1 > p2) ? 1 : -1)); -+} -+ -+static void record_pointer(void *ptr) { -+ tsearch(ptr, &(all_pointers), ptr_comparator); -+} -+ -+static void forget_pointer(void *ptr) { -+ tdelete(ptr, &(all_pointers), ptr_comparator); -+} -+ -+void omapi_free_all_pointers(void) { -+ if (all_pointers != NULL) -+ tdestroy(all_pointers, free); -+ all_pointers = NULL; -+} -+#endif -+ - #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \ - defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) - struct dmalloc_preamble *dmalloc_list; -@@ -77,7 +104,9 @@ VOIDPTR dmalloc (size, file, line) - return (VOIDPTR)0; - - foo = malloc(len); -- -+#ifdef LIBDHCP -+ record_pointer(foo); -+#endif - if (!foo) - return (VOIDPTR)0; - bar = (VOIDPTR)(foo + DMDOFFSET); -@@ -199,6 +228,9 @@ void dfree (ptr, file, line) - 0, (unsigned char *)ptr + DMDOFFSET, 0, 1, RC_MALLOC); - #endif - free (ptr); -+#ifdef LIBDHCP -+ forget_pointer(ptr); -+#endif - } - - #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \ -diff -up dhcp-3.0.6/omapip/dispatch.c.libdhcp4client dhcp-3.0.6/omapip/dispatch.c ---- dhcp-3.0.6/omapip/dispatch.c.libdhcp4client 2004-11-24 12:39:17.000000000 -0500 -+++ dhcp-3.0.6/omapip/dispatch.c 2007-08-15 16:24:55.000000000 -0400 -@@ -34,7 +34,7 @@ - - #include - --static omapi_io_object_t omapi_io_states; -+omapi_io_object_t omapi_io_states; - TIME cur_time; - - OMAPI_OBJECT_ALLOC (omapi_io, -diff -up dhcp-3.0.6/omapip/errwarn.c.libdhcp4client dhcp-3.0.6/omapip/errwarn.c ---- dhcp-3.0.6/omapip/errwarn.c.libdhcp4client 2007-08-15 16:24:55.000000000 -0400 -+++ dhcp-3.0.6/omapip/errwarn.c 2007-08-15 16:24:55.000000000 -0400 -@@ -39,6 +39,11 @@ static char copyright[] = - #include - #include - -+#ifdef LIBDHCP -+#include -+extern LIBDHCP_Control *libdhcp_control; -+#endif -+ - #ifdef DEBUG - int log_perror = -1; - #else -@@ -48,7 +53,9 @@ int log_priority; - void (*log_cleanup) (void); - - #define CVT_BUF_MAX 1023 -+#ifndef LIBDHCP - static char mbuf [CVT_BUF_MAX + 1]; -+#endif - static char fbuf [CVT_BUF_MAX + 1]; - - /* Log an error message, then exit... */ -@@ -58,6 +65,16 @@ void log_fatal (const char * fmt, ... ) - va_list list; - - do_percentm (fbuf, fmt); -+ -+#ifdef LIBDHCP -+ if (libdhcp_control && (libdhcp_control->eh)) { -+ va_start (list, fmt); -+ libdhcp_control->eh(libdhcp_control, LOG_FATAL, fbuf, list); -+ va_end(list); -+ libdhcp_control->finished = 1; -+ return; -+ } -+#else - - /* %Audit% This is log output. %2004.06.17,Safe% - * If we truncate we hope the user can get a hint from the log. -@@ -93,6 +110,7 @@ void log_fatal (const char * fmt, ... ) - if (log_cleanup) - (*log_cleanup) (); - exit (1); -+#endif - } - - /* Log an error message... */ -@@ -103,6 +121,13 @@ int log_error (const char * fmt, ...) - - do_percentm (fbuf, fmt); - -+#ifdef LIBDHCP -+ if (libdhcp_control && libdhcp_control->eh) { -+ va_start (list, fmt); -+ libdhcp_control->eh(libdhcp_control, LOG_ERR, fbuf, list); -+ va_end(list); -+ } -+#else - /* %Audit% This is log output. %2004.06.17,Safe% - * If we truncate we hope the user can get a hint from the log. - */ -@@ -120,7 +145,7 @@ int log_error (const char * fmt, ...) - if (write (STDERR_FILENO, "\n", 1) <= 0) - return 0; - } -- -+#endif - return 0; - } - -@@ -132,6 +157,13 @@ int log_info (const char *fmt, ...) - - do_percentm (fbuf, fmt); - -+#ifdef LIBDHCP -+ if (libdhcp_control && libdhcp_control->eh) { -+ va_start (list, fmt); -+ libdhcp_control->eh(libdhcp_control, LOG_INFO, fbuf, list); -+ va_end(list); -+ } -+#else - /* %Audit% This is log output. %2004.06.17,Safe% - * If we truncate we hope the user can get a hint from the log. - */ -@@ -149,7 +181,7 @@ int log_info (const char *fmt, ...) - if (write (STDERR_FILENO, "\n", 1) <= 0) - return 0; - } -- -+#endif - return 0; - } - -@@ -160,7 +192,13 @@ int log_debug (const char *fmt, ...) - va_list list; - - do_percentm (fbuf, fmt); -- -+#ifdef LIBDHCP -+ if (libdhcp_control && libdhcp_control->eh) { -+ va_start (list, fmt); -+ libdhcp_control->eh(libdhcp_control, LOG_DEBUG, fbuf, list); -+ va_end(list); -+ } -+#else - /* %Audit% This is log output. %2004.06.17,Safe% - * If we truncate we hope the user can get a hint from the log. - */ -@@ -178,7 +216,7 @@ int log_debug (const char *fmt, ...) - if (write (STDERR_FILENO, "\n", 1) <= 0) - return 0; - } -- -+#endif - return 0; - } - -diff -up dhcp-3.0.6/includes/dhcpd.h.libdhcp4client dhcp-3.0.6/includes/dhcpd.h ---- dhcp-3.0.6/includes/dhcpd.h.libdhcp4client 2007-08-15 16:24:55.000000000 -0400 -+++ dhcp-3.0.6/includes/dhcpd.h 2007-08-15 16:24:55.000000000 -0400 -@@ -861,14 +861,6 @@ struct hardware_link { - - typedef void (*tvref_t)(void *, void *, const char *, int); - typedef void (*tvunref_t)(void *, const char *, int); --struct timeout { -- struct timeout *next; -- TIME when; -- void (*func) PROTO ((void *)); -- void *what; -- tvref_t ref; -- tvunref_t unref; --}; - - struct protocol { - struct protocol *next; -@@ -1795,7 +1787,6 @@ extern void (*bootp_packet_handler) PROT - struct dhcp_packet *, unsigned, - unsigned int, - struct iaddr, struct hardware *)); --extern struct timeout *timeouts; - extern omapi_object_type_t *dhcp_type_interface; - #if defined (TRACING) - trace_type_t *interface_trace; -diff -up dhcp-3.0.6/common/discover.c.libdhcp4client dhcp-3.0.6/common/discover.c ---- dhcp-3.0.6/common/discover.c.libdhcp4client 2007-08-15 16:24:55.000000000 -0400 -+++ dhcp-3.0.6/common/discover.c 2007-08-15 16:24:55.000000000 -0400 -@@ -121,6 +121,10 @@ isc_result_t interface_initialize (omapi - register that interface with the network I/O software, figure out what - subnet it's on, and add it to the list of interfaces. */ - -+#ifdef LIBDHCP -+int have_setup_fallback = 0; -+#endif -+ - void discover_interfaces (state) - int state; - { -@@ -139,7 +143,9 @@ void discover_interfaces (state) - char *s; - #endif - isc_result_t status; -+#ifndef LIBDHCP - static int setup_fallback = 0; -+#endif - int wifcount = 0; - - /* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */ -@@ -692,10 +698,17 @@ void discover_interfaces (state) - log_fatal ("Not configured to listen on any interfaces!"); - } - -+#ifdef LIBDHCP -+ if (!have_setup_fallback) { -+ have_setup_fallback = 1; -+ maybe_setup_fallback (); -+ } -+#else - if (!setup_fallback) { - setup_fallback = 1; - maybe_setup_fallback (); - } -+#endif - - #if defined (HAVE_SETFD) - if (fallback_interface) { -diff -up dhcp-3.0.6/common/alloc.c.libdhcp4client dhcp-3.0.6/common/alloc.c ---- dhcp-3.0.6/common/alloc.c.libdhcp4client 2007-08-15 16:24:55.000000000 -0400 -+++ dhcp-3.0.6/common/alloc.c 2007-08-15 16:24:55.000000000 -0400 -@@ -1009,7 +1009,11 @@ int executable_statement_reference (ptr, - return 1; - } - -+#ifdef LIBDHCP -+struct packet *free_packets; -+#else - static struct packet *free_packets; -+#endif - - #if defined (DEBUG_MEMORY_LEAKAGE) || \ - defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) -diff -up dhcp-3.0.6/common/tree.c.libdhcp4client dhcp-3.0.6/common/tree.c ---- dhcp-3.0.6/common/tree.c.libdhcp4client 2007-08-15 16:24:55.000000000 -0400 -+++ dhcp-3.0.6/common/tree.c 2007-08-15 16:24:55.000000000 -0400 -@@ -40,7 +40,7 @@ static char copyright[] = - #include "dhcpd.h" - #include - --struct binding_scope *global_scope; -+struct binding_scope __attribute__ ((visibility ("default"))) *global_scope; - - static int do_host_lookup PROTO ((struct data_string *, - struct dns_host_entry *)); -@@ -2615,6 +2615,7 @@ int evaluate_numeric_expression (result, - result of that evaluation. There should never be both an expression - and a valid data_string. */ - -+__attribute__ ((visibility ("default"))) - int evaluate_option_cache (result, packet, lease, client_state, - in_options, cfg_options, scope, oc, file, line) - struct data_string *result; -diff -up dhcp-3.0.6/common/options.c.libdhcp4client dhcp-3.0.6/common/options.c ---- dhcp-3.0.6/common/options.c.libdhcp4client 2007-08-15 16:24:55.000000000 -0400 -+++ dhcp-3.0.6/common/options.c 2007-08-15 16:24:55.000000000 -0400 -@@ -2152,6 +2152,7 @@ int fqdn_option_space_encapsulate (resul - return 1; - } - -+__attribute__ ((visibility ("default"))) - void option_space_foreach (struct packet *packet, struct lease *lease, - struct client_state *client_state, - struct option_state *in_options, -diff -up dhcp-3.0.6/common/dispatch.c.libdhcp4client dhcp-3.0.6/common/dispatch.c ---- dhcp-3.0.6/common/dispatch.c.libdhcp4client 2007-08-15 16:24:55.000000000 -0400 -+++ dhcp-3.0.6/common/dispatch.c 2007-08-15 16:24:55.000000000 -0400 -@@ -39,8 +39,24 @@ static char copyright[] = - - #include "dhcpd.h" - --struct timeout *timeouts; --static struct timeout *free_timeouts; -+struct timeout { -+#ifndef LIBDHCP -+ struct timeout *next; -+#endif -+ TIME when; -+ void (*func) PROTO ((void *)); -+ void *what; -+ tvref_t ref; -+ tvunref_t unref; -+}; -+ -+#ifdef LIBDHCP -+static struct timeout *timeouts = NULL; -+static int ntimeouts = 0; -+#else -+static struct timeout *timeouts = NULL; -+static struct timeout *free_timeouts = NULL; -+#endif - - void set_time(TIME t) - { -@@ -53,9 +69,41 @@ void set_time(TIME t) - - struct timeval *process_outstanding_timeouts (struct timeval *tvp) - { -+#ifdef LIBDHCP -+ int i; -+ struct timeout t = { 0 }; -+#endif - /* Call any expired timeouts, and then if there's - still a timeout registered, time out the select - call then. */ -+#ifdef LIBDHCP -+ if (!ntimeouts) -+ return NULL; -+ -+ for (i = 0; i < ntimeouts && timeouts[i].when <= cur_time;) { -+ struct timeout *new_timeouts; -+ size_t n; -+ -+ memmove(&t, &timeouts[i], sizeof (t)); -+ -+ n = (ntimeouts - i - 1) * sizeof (t); -+ memmove(&timeouts[i+1], &timeouts[i], n); -+ -+ n = --ntimeouts * sizeof (t); -+ new_timeouts = realloc(timeouts, n); -+ /* XXX broken API, no way to return error here */ -+ if (new_timeouts || !n) -+ timeouts = new_timeouts; -+ -+ if (t.func) -+ t.func(t.what); -+ if (t.unref) -+ t.unref(t.what, MDL); -+ } -+ if (tvp && ntimeouts) { -+ tvp->tv_sec = timeouts[0].when; -+ tvp->tv_usec = 0; -+#else - another: - if (timeouts) { - struct timeout *t; -@@ -73,9 +121,15 @@ struct timeval *process_outstanding_time - tvp -> tv_sec = timeouts -> when; - tvp -> tv_usec = 0; - } -+#endif - return tvp; -+#ifdef LIBDHCP -+ } -+ return NULL; -+#else - } else - return (struct timeval *)0; -+#endif - } - - /* Wait for packets to come in using select(). When one does, call -@@ -104,13 +158,28 @@ void add_timeout (when, where, what, ref - tvref_t ref; - tvunref_t unref; - { -+#ifdef LIBDHCP -+ struct timeout t = { -+ .when = when, -+ .func = where, -+ .what = what, -+ .ref = ref, -+ .unref = unref -+ }; -+ struct timeout *new_timeouts; -+ int i, pos = 0; -+#else - struct timeout *t, *q; -+#endif - - /* See if this timeout supersedes an existing timeout. */ -+#ifdef LIBDHCP -+ for (i = 0; i < ntimeouts; i++) { -+ struct timeout *q = &timeouts[i]; -+#else - t = (struct timeout *)0; - for (q = timeouts; q; q = q -> next) { -- if ((where == NULL || q -> func == where) && -- q -> what == what) { -+ if ((where == NULL || q -> func == where) && q -> what == what) { - if (t) - t -> next = q -> next; - else -@@ -119,7 +188,29 @@ void add_timeout (when, where, what, ref - } - t = q; - } -+#endif - -+#ifdef LIBDHCP -+ /* If this one is already in the list with a different time, -+ * remove it and re-add */ -+ if ((where == NULL || q->func == where) && -+ q->what == what) { -+ size_t n = (--ntimeouts - i) * sizeof (*q); -+ memmove(&t, q, sizeof (t)); -+ -+ if (n) -+ memmove(&timeouts[i], &timeouts[i+1], n); -+ -+ if (ntimeouts) { -+ new_timeouts = realloc(timeouts, ntimeouts * sizeof (*q)); -+ /* XXX broken API, no way to return error here */ -+ if (new_timeouts) -+ timeouts = new_timeouts; -+ } else { -+ timeouts = NULL; -+ } -+ add_timeout(when, where, what, ref, unref); -+#else - /* If we didn't supersede a timeout, allocate a timeout - structure now. */ - if (!q) { -@@ -128,7 +219,7 @@ void add_timeout (when, where, what, ref - free_timeouts = q -> next; - } else { - q = ((struct timeout *) -- dmalloc (sizeof (struct timeout), MDL)); -+ dmalloc (sizeof (struct timeout), MDL)); - if (!q) - log_fatal ("add_timeout: no memory!"); - } -@@ -158,22 +249,76 @@ void add_timeout (when, where, what, ref - if (t -> next -> when > q -> when) { - q -> next = t -> next; - t -> next = q; -+#endif - return; -+#ifdef LIBDHCP -+ } else if (timeouts[i].when > when) { -+ pos = i; -+#endif - } - } - -+#ifdef LIBDHCP -+ /* If we didn't supersede an existing timeout, then pos is set -+ * to the timeout which will post after this one. Insert this -+ * one before it. */ -+ -+ new_timeouts = realloc(timeouts, sizeof (t) * (ntimeouts+1)); -+ /* XXX broken API, no way to return error here */ -+ if (new_timeouts) { -+ /* ntimeouts = 10 -+ * pos = 3; -+ * n = 10-3 * sizeof (t) = 7 * sizeof (t) -+ */ -+ size_t n = (ntimeouts - pos) * sizeof (t); -+ -+ timeouts = new_timeouts; -+ memmove(&timeouts[pos+1], &timeouts[pos], n); -+ memmove(&timeouts[pos], &t, sizeof (t)); -+ ntimeouts++; -+ } -+#else - /* End of list. */ - t -> next = q; - q -> next = (struct timeout *)0; -+#endif - } - - void cancel_timeout (where, what) - void (*where) PROTO ((void *)); - void *what; - { -+#ifdef LIBDHCP -+ struct timeout t; -+ int i = 0; -+#else - struct timeout *t, *q; -+#endif - - /* Look for this timeout on the list, and unlink it if we find it. */ -+#ifdef LIBDHCP -+ for (i = 0; i < ntimeouts; i++) { -+ struct timeout *new_timeouts, *q = &timeouts[i]; -+ -+ if (q->func == where && q->what == what) { -+ size_t n; -+ -+ memmove(&t, q, sizeof (t)); -+ -+ n = (ntimeouts - i - 1) * sizeof (t); -+ memmove(&timeouts[i+1], &timeouts[i], n); -+ -+ n = --ntimeouts * sizeof (t); -+ new_timeouts = realloc(timeouts, n); -+ /* XXX broken API, no way to return error here */ -+ if (new_timeouts || !n) -+ timeouts = new_timeouts; -+ -+ if (t.unref) -+ t.unref(t.what, MDL); -+ } -+ } -+#else - t = (struct timeout *)0; - for (q = timeouts; q; q = q -> next) { - if (q -> func == where && q -> what == what) { -@@ -193,10 +338,15 @@ void cancel_timeout (where, what) - q -> next = free_timeouts; - free_timeouts = q; - } -+#endif - } - - void cancel_all_timeouts () - { -+#ifdef LIBDHCP -+ cur_time = TIME_MAX; -+ process_outstanding_timeouts(NULL); -+#else - struct timeout *t, *n; - for (t = timeouts; t; t = n) { - n = t -> next; -@@ -205,13 +355,20 @@ void cancel_all_timeouts () - t -> next = free_timeouts; - free_timeouts = t; - } -+#endif - } - -+__attribute__ ((visibility ("default"))) - void relinquish_timeouts () - { -+#ifdef LIBDHCP -+ while (ntimeouts) -+ cancel_timeout(timeouts[0].func, timeouts[0].what); -+#else - struct timeout *t, *n; - for (t = free_timeouts; t; t = n) { - n = t -> next; - dfree (t, MDL); - } -+#endif - } -diff -up dhcp-3.0.6/dst/hmac_link.c.libdhcp4client dhcp-3.0.6/dst/hmac_link.c ---- dhcp-3.0.6/dst/hmac_link.c.libdhcp4client 2001-02-22 02:22:08.000000000 -0500 -+++ dhcp-3.0.6/dst/hmac_link.c 2007-08-15 16:24:55.000000000 -0400 -@@ -38,6 +38,10 @@ static const char rcsid[] = "$Header: /p - - #include "dst_internal.h" - -+#ifdef LIBDHCP -+extern void* dmalloc(size_t,char *,int); -+#endif -+ - #ifdef USE_MD5 - # include "md5.h" - # ifndef _MD5_H_ -@@ -86,7 +90,11 @@ dst_hmac_md5_sign(const int mode, DST_KE - MD5_CTX *ctx = NULL; - - if (mode & SIG_MODE_INIT) -+#ifdef LIBDHCP -+ ctx = (MD5_CTX *) dmalloc(sizeof(*ctx),__FILE__,__LINE__); -+#else - ctx = (MD5_CTX *) malloc(sizeof(*ctx)); -+#endif - else if (context) - ctx = (MD5_CTX *) *context; - if (ctx == NULL) -@@ -153,7 +161,11 @@ dst_hmac_md5_verify(const int mode, DST_ - MD5_CTX *ctx = NULL; - - if (mode & SIG_MODE_INIT) -+#ifdef LIBDHCP -+ ctx = (MD5_CTX *) dmalloc(sizeof(*ctx),__FILE__,__LINE__); -+#else - ctx = (MD5_CTX *) malloc(sizeof(*ctx)); -+#endif - else if (context) - ctx = (MD5_CTX *) *context; - if (ctx == NULL) -@@ -217,8 +229,11 @@ dst_buffer_to_hmac_md5(DST_KEY *dkey, co - - if (dkey == NULL || key == NULL || keylen < 0) - return (-1); -- -+#ifdef LIBDHCP -+ if ((hkey = (HMAC_Key *) dmalloc(sizeof(HMAC_Key),__FILE__,__LINE__)) == NULL) -+#else - if ((hkey = (HMAC_Key *) malloc(sizeof(HMAC_Key))) == NULL) -+#endif - return (-2); - - memset(hkey->hk_ipad, 0, sizeof(hkey->hk_ipad)); -@@ -347,7 +362,11 @@ dst_hmac_md5_key_from_file_format(DST_KE - if (eol == NULL) - return (-4); - len = eol - p; -+#ifdef LIBDHCP -+ tmp = dmalloc(len + 2,__FILE__,__LINE__); -+#else - tmp = malloc(len + 2); -+#endif - memcpy(tmp, p, len); - *(tmp + len) = 0x0; - key_len = b64_pton((char *)tmp, key, HMAC_LEN+1); /* see above */ -@@ -439,8 +458,11 @@ dst_hmac_md5_generate_key(DST_KEY *key, - return(0); - - len = size > 64 ? 64 : size; -+#ifdef LIBDHCP -+ buff = dmalloc(len+8,__FILE__,__LINE__); -+#else - buff = malloc(len+8); -- -+#endif - n = dst_random(DST_RAND_SEMI, len, buff); - n += dst_random(DST_RAND_KEY, len, buff); - if (n <= len) { /* failed getting anything */ -@@ -463,7 +485,11 @@ dst_hmac_md5_init() - { - if (dst_t_func[KEY_HMAC_MD5] != NULL) - return (1); -+#ifdef LIBDHCP -+ dst_t_func[KEY_HMAC_MD5] = dmalloc(sizeof(struct dst_func),__FILE__,__LINE__); -+#else - dst_t_func[KEY_HMAC_MD5] = malloc(sizeof(struct dst_func)); -+#endif - if (dst_t_func[KEY_HMAC_MD5] == NULL) - return (0); - memset(dst_t_func[KEY_HMAC_MD5], 0, sizeof(struct dst_func)); -diff -up dhcp-3.0.6/Makefile.dist.libdhcp4client dhcp-3.0.6/Makefile.dist ---- dhcp-3.0.6/Makefile.dist.libdhcp4client 2004-06-10 13:59:10.000000000 -0400 -+++ dhcp-3.0.6/Makefile.dist 2007-08-15 16:24:55.000000000 -0400 -@@ -22,7 +22,7 @@ - # http://www.isc.org/ - - --SUBDIRS= common $(MINIRES) dst omapip server client relay dhcpctl -+SUBDIRS= common $(MINIRES) dst omapip server client relay dhcpctl libdhcp4client - - all: - @for dir in ${SUBDIRS}; do \ -diff -up dhcp-3.0.6/configure.libdhcp4client dhcp-3.0.6/configure ---- dhcp-3.0.6/configure.libdhcp4client 2004-09-10 17:02:30.000000000 -0400 -+++ dhcp-3.0.6/configure 2007-08-15 16:24:55.000000000 -0400 -@@ -246,7 +246,7 @@ if [ ! -d $workname ]; then - fi - - if [ x"$dirs" = x ]; then -- dirs=". client server relay common omapip dhcpctl minires dst" -+ dirs=". client server relay common omapip dhcpctl minires dst libdhcp4client" - fi - - for foo in $dirs; do diff --git a/dhcp-3.0.6-options.patch b/dhcp-3.0.6-options.patch deleted file mode 100644 index e7daa18..0000000 --- a/dhcp-3.0.6-options.patch +++ /dev/null @@ -1,402 +0,0 @@ -diff -up dhcp-3.0.6/client/dhclient.c.options dhcp-3.0.6/client/dhclient.c ---- dhcp-3.0.6/client/dhclient.c.options 2007-08-15 11:19:40.000000000 -0400 -+++ dhcp-3.0.6/client/dhclient.c 2007-08-15 11:43:18.000000000 -0400 -@@ -38,6 +38,12 @@ static char ocopyright[] = - #include "dhcpd.h" - #include "version.h" - -+/* -+ * Defined in stdio.h when _GNU_SOURCE is set, but we don't want to define -+ * that when building ISC code. -+ */ -+extern int asprintf(char **strp, const char *fmt, ...); -+ - TIME default_lease_time = 43200; /* 12 hours... */ - TIME max_lease_time = 86400; /* 24 hours... */ - -@@ -74,6 +80,9 @@ int client_env_count=0; - int onetry=0; - int quiet=0; - int nowait=0; -+int bootp_broadcast_always = 0; -+ -+extern u_int32_t default_requested_options[]; - - static void usage PROTO ((void)); - -@@ -100,6 +109,15 @@ int main (argc, argv, envp) - int no_dhclient_pid = 0; - int no_dhclient_script = 0; - char *s; -+ char *dhcp_client_identifier_arg = NULL; -+ char *dhcp_host_name_arg = NULL; -+ char *dhcp_fqdn_arg = NULL; -+ char *dhcp_vendor_class_identifier_arg = NULL; -+ char *dhclient_request_options = NULL; -+ -+ int timeout_arg = 0; -+ char *arg_conf = NULL; -+ int arg_conf_len = 0; - - /* Make sure we have stdin, stdout and stderr. */ - i = open ("/dev/null", O_RDWR); -@@ -203,6 +221,88 @@ int main (argc, argv, envp) - } else if (!strcmp (argv [i], "--version")) { - log_info ("isc-dhclient-%s", DHCP_VERSION); - exit (0); -+ } else if (!strcmp (argv [i], "-I")) { -+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { -+ usage (); -+ return EXIT_FAILURE; -+ } -+ -+ if (strlen(argv[i]) >= DHCP_OPTION_LEN) { -+ log_error("-I option dhcp-client-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1); -+ exit(1); -+ } -+ -+ dhcp_client_identifier_arg = argv[i]; -+ } else if (!strcmp (argv [i], "-B")) { -+ bootp_broadcast_always = 1; -+ } else if (!strcmp (argv [i], "-H")) { -+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { -+ usage (); -+ return EXIT_FAILURE; -+ } -+ -+ if (strlen(argv[i]) >= DHCP_OPTION_LEN) { -+ log_error("-H option host-name string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1); -+ exit(1); -+ } -+ -+ if (dhcp_host_name_arg != NULL) { -+ log_error("The -H and -F arguments are mutually exclusive"); -+ exit(1); -+ } -+ -+ dhcp_host_name_arg = argv[i]; -+ } else if (!strcmp (argv [i], "-F")) { -+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { -+ usage (); -+ return EXIT_FAILURE; -+ } -+ -+ if (strlen(argv[i]) >= DHCP_OPTION_LEN) { -+ log_error("-F option fqdn.fqdn string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1); -+ exit(1); -+ } -+ -+ if (dhcp_fqdn_arg != NULL) { -+ log_error("Only one -F argument can be specified"); -+ exit(1); -+ } -+ -+ if (dhcp_host_name_arg != NULL) { -+ log_error("The -F and -H arguments are mutually exclusive"); -+ exit(1); -+ } -+ -+ dhcp_fqdn_arg = argv[i]; -+ } else if (!strcmp (argv [i], "-T")) { -+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { -+ usage (); -+ return EXIT_FAILURE; -+ } -+ -+ if ((timeout_arg = atoi(argv[i])) <= 0) { -+ log_error("-T timeout option must be > 0 - bad value: %s",argv[i]); -+ exit(1); -+ } -+ } else if (!strcmp (argv [i], "-V")) { -+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { -+ usage (); -+ return EXIT_FAILURE; -+ } -+ -+ if (strlen(argv[i]) >= DHCP_OPTION_LEN) { -+ log_error("-V option vendor-class-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1); -+ exit(1); -+ } -+ -+ dhcp_vendor_class_identifier_arg = argv[i]; -+ } else if (!strcmp (argv [i], "-R")) { -+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { -+ usage (); -+ return EXIT_FAILURE; -+ } -+ -+ dhclient_request_options=argv[i]; - } else if (argv [i][0] == '-') { - usage (); - } else { -@@ -339,6 +439,167 @@ int main (argc, argv, envp) - /* Parse the dhclient.conf file. */ - read_client_conf (); - -+ /* Parse any extra command line configuration arguments: */ -+ if ((dhcp_client_identifier_arg != NULL) && (*dhcp_client_identifier_arg != '\0')) { -+ arg_conf_len = asprintf(&arg_conf, "send dhcp-client-identifier \"%s\";", dhcp_client_identifier_arg); -+ -+ if ((arg_conf == 0) || (arg_conf_len <= 0)) -+ log_fatal("Unable to send -I option dhcp-client-identifier"); -+ } -+ -+ if ((dhcp_host_name_arg != NULL) && (*dhcp_host_name_arg != '\0')) { -+ if (arg_conf == 0) { -+ arg_conf_len = asprintf(&arg_conf, "send host-name \"%s\";", dhcp_host_name_arg); -+ -+ if ((arg_conf == 0) || (arg_conf_len <= 0)) -+ log_fatal("Unable to send -H option host-name"); -+ } else { -+ char *last_arg_conf = arg_conf; -+ arg_conf = NULL; -+ arg_conf_len = asprintf( &arg_conf, "%s\nsend host-name \"%s\";", last_arg_conf, dhcp_host_name_arg); -+ -+ if ((arg_conf == 0) || (arg_conf_len <= 0)) -+ log_fatal("Unable to send -H option host-name"); -+ -+ free(last_arg_conf); -+ } -+ } -+ -+ if ((dhcp_fqdn_arg != NULL) && (*dhcp_fqdn_arg != '\0')) { -+ if (arg_conf == 0) { -+ arg_conf_len = asprintf(&arg_conf, "send fqdn.fqdn \"%s\";", dhcp_fqdn_arg); -+ -+ if ((arg_conf == 0) || (arg_conf_len <= 0)) -+ log_fatal("Unable to send -F option fqdn.fqdn"); -+ } else { -+ char *last_arg_conf = arg_conf; -+ arg_conf = NULL; -+ arg_conf_len = asprintf( &arg_conf, "%s\nsend fqdn.fqdn \"%s\";", last_arg_conf, dhcp_fqdn_arg); -+ -+ if ((arg_conf == 0) || (arg_conf_len <= 0)) -+ log_fatal("Unable to send -F option fqdn.fqdn"); -+ -+ free(last_arg_conf); -+ } -+ } -+ -+ if (timeout_arg) { -+ if (arg_conf == 0) { -+ arg_conf_len = asprintf(&arg_conf, "timeout %d;", timeout_arg); -+ -+ if ((arg_conf == 0) || (arg_conf_len <= 0)) -+ log_fatal("Unable to process -T timeout argument"); -+ } else { -+ char *last_arg_conf = arg_conf; -+ arg_conf = NULL; -+ arg_conf_len = asprintf( &arg_conf, "%s\ntimeout %d;", last_arg_conf, timeout_arg); -+ -+ if ((arg_conf == 0) || (arg_conf_len == 0)) -+ log_fatal("Unable to process -T timeout argument"); -+ -+ free(last_arg_conf); -+ } -+ } -+ -+ if ((dhcp_vendor_class_identifier_arg != NULL) && (*dhcp_vendor_class_identifier_arg != '\0')) { -+ if (arg_conf == 0) { -+ arg_conf_len = asprintf(&arg_conf, "send vendor-class-identifier \"%s\";", dhcp_vendor_class_identifier_arg); -+ -+ if ((arg_conf == 0) || (arg_conf_len <= 0)) -+ log_fatal("Unable to send -V option vendor-class-identifier"); -+ } else { -+ char *last_arg_conf = arg_conf; -+ arg_conf = NULL; -+ arg_conf_len = asprintf(&arg_conf, "%s\nsend vendor-class-identifier \"%s\";", last_arg_conf, dhcp_vendor_class_identifier_arg); -+ -+ if ((arg_conf == 0) || (arg_conf_len <= 0)) -+ log_fatal("Unable to send -V option vendor-class-identifier"); -+ -+ free(last_arg_conf); -+ } -+ } -+ -+ if (dhclient_request_options != NULL) { -+ if (arg_conf == 0) { -+ arg_conf_len = asprintf(&arg_conf, "request %s;", dhclient_request_options); -+ -+ if ((arg_conf == 0) || (arg_conf_len <= 0)) -+ log_fatal("Unable to parse -R argument"); -+ } else { -+ char *last_arg_conf = arg_conf; -+ arg_conf = NULL; -+ arg_conf_len = asprintf(&arg_conf, "%s\nrequest %s;", last_arg_conf, dhclient_request_options); -+ -+ if ((arg_conf == 0) || (arg_conf_len <= 0)) -+ log_fatal("Unable to parse -R argument"); -+ -+ free(last_arg_conf); -+ } -+ } -+ -+ if (arg_conf) { -+ if (arg_conf_len == 0) -+ if ((arg_conf_len = strlen(arg_conf)) == 0) -+ /* huh ? cannot happen ! */ -+ log_fatal("Unable to process -I/-H/-F/-T/-V/-R configuration arguments"); -+ -+ /* parse the extra dhclient.conf configuration arguments -+ * into top level config: */ -+ struct parse *cfile = (struct parse *)0; -+ const char *val = NULL; -+ int token; -+ -+ status = new_parse (&cfile, -1, arg_conf, arg_conf_len, "extra dhclient -I/-H/-F/-T/-V/-R configuration arguments", 0); -+ -+ if ((status != ISC_R_SUCCESS) || (cfile -> warnings_occurred)) -+ log_fatal("Cannot parse -I/-H/-F/-T/-V/-R configuration arguments !"); -+ /* more detailed parse failures will be logged */ -+ -+ do { -+ token = peek_token (&val, (unsigned *)0, cfile); -+ if (token == END_OF_FILE) -+ break; -+ -+ parse_client_statement (cfile, (struct interface_info *)0, &top_level_config); -+ } while (1); -+ -+ if (cfile -> warnings_occurred) -+ log_fatal ("Cannot parse -I/-H/-F/-T/-V/-R configuration arguments !"); -+ end_parse (&cfile); -+ -+ if (timeout_arg) { -+ /* we just set the toplevel timeout, but per-client -+ * timeouts may still be at defaults. Also, it makes no -+ * sense having the reboot_timeout or backoff_cutoff -+ * greater than the timeout: -+ */ -+ if ((top_level_config.backoff_cutoff == 15) && (top_level_config.backoff_cutoff > (timeout_arg / 2))) -+ top_level_config.backoff_cutoff = (((unsigned long)(timeout_arg / 2)) == 0) ? timeout_arg : (unsigned long)(timeout_arg / 2); -+ -+ for (ip = interfaces; ip; ip = ip -> next) { -+ if (ip->client->config->timeout == 60) -+ ip->client->config->timeout = timeout_arg; -+ -+ if ((ip->client->config->reboot_timeout == 10) && (ip->client->config->reboot_timeout > ip->client->config->timeout)) -+ ip->client->config->reboot_timeout = ip->client->config->timeout; -+ -+ if ((ip->client->config->backoff_cutoff == 15) && (ip->client->config->backoff_cutoff > top_level_config.backoff_cutoff)) -+ ip->client->config->backoff_cutoff = top_level_config.backoff_cutoff; -+ } -+ } -+ -+ if ((dhclient_request_options != 0) && (top_level_config.requested_options != default_requested_options)) { -+ for (ip = interfaces; ip; ip = ip -> next) { -+ if (ip->client->config->requested_options == default_requested_options) -+ ip->client->config->requested_options = top_level_config.requested_options; -+ } -+ } -+ -+ free(arg_conf); -+ arg_conf = NULL; -+ arg_conf_len = 0; -+ } -+ - /* Parse the lease database. */ - read_client_leases (); - -@@ -1912,7 +2173,8 @@ void make_discover (client, lease) - client -> packet.xid = random (); - client -> packet.secs = 0; /* filled in by send_discover. */ - -- if (can_receive_unicast_unconfigured (client -> interface)) -+ if ((!(bootp_broadcast_always || client->config->bootp_broadcast_always)) -+ && can_receive_unicast_unconfigured(client->interface)) - client -> packet.flags = 0; - else - client -> packet.flags = htons (BOOTP_BROADCAST); -@@ -1996,7 +2258,9 @@ void make_request (client, lease) - } else { - memset (&client -> packet.ciaddr, 0, - sizeof client -> packet.ciaddr); -- if (can_receive_unicast_unconfigured (client -> interface)) -+ if ((!(bootp_broadcast_always || -+ client ->config->bootp_broadcast_always)) && -+ can_receive_unicast_unconfigured (client -> interface)) - client -> packet.flags = 0; - else - client -> packet.flags = htons (BOOTP_BROADCAST); -@@ -2055,7 +2319,8 @@ void make_decline (client, lease) - client -> packet.hops = 0; - client -> packet.xid = client -> xid; - client -> packet.secs = 0; /* Filled in by send_request. */ -- if (can_receive_unicast_unconfigured (client -> interface)) -+ if ((!(bootp_broadcast_always || client->config-> bootp_broadcast_always)) -+ && can_receive_unicast_unconfigured (client->interface)) - client -> packet.flags = 0; - else - client -> packet.flags = htons (BOOTP_BROADCAST); -diff -up dhcp-3.0.6/client/clparse.c.options dhcp-3.0.6/client/clparse.c ---- dhcp-3.0.6/client/clparse.c.options 2007-08-15 11:19:40.000000000 -0400 -+++ dhcp-3.0.6/client/clparse.c 2007-08-15 11:44:34.000000000 -0400 -@@ -81,6 +81,7 @@ isc_result_t read_client_conf () - top_level_config.requested_options = default_requested_options; - top_level_config.omapi_port = -1; - top_level_config.do_forward_update = 1; -+ top_level_config.bootp_broadcast_always = 0; - - group_allocate (&top_level_config.on_receipt, MDL); - if (!top_level_config.on_receipt) -@@ -227,7 +228,8 @@ void read_client_leases () - interface-declaration | - LEASE client-lease-statement | - ALIAS client-lease-statement | -- KEY key-definition */ -+ KEY key-definition | -+ BOOTP_BROADCAST_ALWAYS */ - - void parse_client_statement (cfile, ip, config) - struct parse *cfile; -@@ -549,6 +551,12 @@ void parse_client_statement (cfile, ip, - parse_reject_statement (cfile, config); - return; - -+ case BOOTP_BROADCAST_ALWAYS: -+ token = next_token(&val, (unsigned*)0, cfile); -+ config -> bootp_broadcast_always = 1; -+ parse_semi (cfile); -+ return; -+ - default: - lose = 0; - stmt = (struct executable_statement *)0; -diff -up dhcp-3.0.6/includes/dhcpd.h.options dhcp-3.0.6/includes/dhcpd.h ---- dhcp-3.0.6/includes/dhcpd.h.options 2007-08-15 11:19:40.000000000 -0400 -+++ dhcp-3.0.6/includes/dhcpd.h 2007-08-15 11:45:51.000000000 -0400 -@@ -773,6 +773,9 @@ struct client_config { - int do_forward_update; /* If nonzero, and if we have the - information we need, update the - A record for the address we get. */ -+ -+ int bootp_broadcast_always; /* If nonzero, always set the BOOTP_BROADCAST -+ flag in requests */ - }; - - /* Per-interface state used in the dhcp client... */ -diff -up dhcp-3.0.6/includes/dhctoken.h.options dhcp-3.0.6/includes/dhctoken.h ---- dhcp-3.0.6/includes/dhctoken.h.options 2005-09-22 12:19:57.000000000 -0400 -+++ dhcp-3.0.6/includes/dhctoken.h 2007-08-15 11:46:11.000000000 -0400 -@@ -309,7 +309,8 @@ enum dhcp_token { - DOMAIN_NAME = 613, - DO_FORWARD_UPDATE = 614, - KNOWN_CLIENTS = 615, -- ATSFP = 616 -+ ATSFP = 616, -+ BOOTP_BROADCAST_ALWAYS = 617 - }; - - #define is_identifier(x) ((x) >= FIRST_TOKEN && \ -diff -up dhcp-3.0.6/common/conflex.c.options dhcp-3.0.6/common/conflex.c ---- dhcp-3.0.6/common/conflex.c.options 2007-08-15 11:19:40.000000000 -0400 -+++ dhcp-3.0.6/common/conflex.c 2007-08-15 11:45:02.000000000 -0400 -@@ -599,6 +599,8 @@ static enum dhcp_token intern (atom, dfv - return BALANCE; - if (!strcasecmp (atom + 1, "ound")) - return BOUND; -+ if (!strcasecmp (atom + 1, "ootp-broadcast-always")) -+ return BOOTP_BROADCAST_ALWAYS; - break; - case 'c': - if (!strcasecmp (atom + 1, "ase")) diff --git a/dhcp-3.0.6-xen-checksum.patch b/dhcp-3.0.6-xen-checksum.patch deleted file mode 100644 index d180441..0000000 --- a/dhcp-3.0.6-xen-checksum.patch +++ /dev/null @@ -1,243 +0,0 @@ -diff -up dhcp-3.0.6/includes/dhcpd.h.xen dhcp-3.0.6/includes/dhcpd.h ---- dhcp-3.0.6/includes/dhcpd.h.xen 2007-07-10 11:50:22.000000000 -0400 -+++ dhcp-3.0.6/includes/dhcpd.h 2007-07-10 14:03:52.000000000 -0400 -@@ -1985,7 +1985,7 @@ ssize_t decode_hw_header PROTO ((struct - unsigned, struct hardware *)); - ssize_t decode_udp_ip_header PROTO ((struct interface_info *, unsigned char *, - unsigned, struct sockaddr_in *, -- unsigned, unsigned *)); -+ unsigned, unsigned *, int)); - - /* ethernet.c */ - void assemble_ethernet_header PROTO ((struct interface_info *, unsigned char *, -diff -up dhcp-3.0.6/common/bpf.c.xen dhcp-3.0.6/common/bpf.c ---- dhcp-3.0.6/common/bpf.c.xen 2007-05-01 16:42:55.000000000 -0400 -+++ dhcp-3.0.6/common/bpf.c 2007-07-10 14:04:24.000000000 -0400 -@@ -478,7 +478,7 @@ ssize_t receive_packet (interface, buf, - offset = decode_udp_ip_header (interface, - interface -> rbuf, - interface -> rbuf_offset, -- from, hdr.bh_caplen, &paylen); -+ from, hdr.bh_caplen, &paylen, 0); - - /* If the IP or UDP checksum was bad, skip the packet... */ - if (offset < 0) { -diff -up dhcp-3.0.6/common/dlpi.c.xen dhcp-3.0.6/common/dlpi.c ---- dhcp-3.0.6/common/dlpi.c.xen 2007-05-01 16:42:55.000000000 -0400 -+++ dhcp-3.0.6/common/dlpi.c 2007-07-10 14:04:36.000000000 -0400 -@@ -680,7 +680,7 @@ ssize_t receive_packet (interface, buf, - length -= offset; - #endif - offset = decode_udp_ip_header (interface, dbuf, bufix, -- from, length, &paylen); -+ from, length, &paylen, 0); - - /* If the IP or UDP checksum was bad, skip the packet... */ - if (offset < 0) { -diff -up dhcp-3.0.6/common/lpf.c.xen dhcp-3.0.6/common/lpf.c ---- dhcp-3.0.6/common/lpf.c.xen 2007-07-10 11:50:22.000000000 -0400 -+++ dhcp-3.0.6/common/lpf.c 2007-07-10 14:09:29.000000000 -0400 -@@ -34,16 +34,31 @@ static char copyright[] = - #include "dhcpd.h" - #if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE) - #include -+#include - #include - - #include - #include - #include -+#include - #include - #include "includes/netinet/ip.h" - #include "includes/netinet/udp.h" - #include "includes/netinet/if_ether.h" - -+#ifndef PACKET_AUXDATA -+#define PACKET_AUXDATA 8 -+ -+struct tpacket_auxdata -+{ -+ __u32 tp_status; -+ __u32 tp_len; -+ __u32 tp_snaplen; -+ __u16 tp_mac; -+ __u16 tp_net; -+}; -+#endif -+ - /* Reinitializes the specified interface after an address change. This - is not required for packet-filter APIs. */ - -@@ -69,10 +84,14 @@ int if_register_lpf (info) - struct interface_info *info; - { - int sock; -- struct sockaddr sa; -+ union { -+ struct sockaddr_ll ll; -+ struct sockaddr common; -+ } sa; -+ struct ifreq ifr; - - /* Make an LPF socket. */ -- if ((sock = socket(PF_PACKET, SOCK_PACKET, -+ if ((sock = socket(PF_PACKET, SOCK_RAW, - htons((short)ETH_P_ALL))) < 0) { - if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || - errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT || -@@ -87,11 +106,16 @@ int if_register_lpf (info) - log_fatal ("Open a socket for LPF: %m"); - } - -+ memset (&ifr, 0, sizeof ifr); -+ strncpy (ifr.ifr_name, (const char *)info -> ifp, sizeof ifr.ifr_name); -+ if (ioctl (sock, SIOCGIFINDEX, &ifr)) -+ log_fatal ("Failed to get interface index: %m"); -+ - /* Bind to the interface name */ - memset (&sa, 0, sizeof sa); -- sa.sa_family = AF_PACKET; -- strncpy (sa.sa_data, (const char *)info -> ifp, sizeof sa.sa_data); -- if (bind (sock, &sa, sizeof sa)) { -+ sa.ll.sll_family = AF_PACKET; -+ sa.ll.sll_ifindex = ifr.ifr_ifindex; -+ if (bind (sock, &sa.common, sizeof sa)) { - if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || - errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT || - errno == EAFNOSUPPORT || errno == EINVAL) { -@@ -171,9 +195,18 @@ static void lpf_gen_filter_setup (struct - void if_register_receive (info) - struct interface_info *info; - { -+ int val; -+ - /* Open a LPF device and hang it on this interface... */ - info -> rfdesc = if_register_lpf (info); - -+ val = 1; -+ if (setsockopt (info -> rfdesc, SOL_PACKET, PACKET_AUXDATA, &val, -+ sizeof val) < 0) { -+ if (errno != ENOPROTOOPT) -+ log_fatal ("Failed to set auxiliary packet data: %m"); -+ } -+ - #if defined (HAVE_TR_SUPPORT) - if (info -> hw_address.hbuf [0] == HTYPE_IEEE802) - lpf_tr_filter_setup (info); -@@ -292,7 +325,6 @@ ssize_t send_packet (interface, packet, - double hh [16]; - double ih [1536 / sizeof (double)]; - unsigned char *buf = (unsigned char *)ih; -- struct sockaddr sa; - int result; - int fudge; - -@@ -310,15 +342,7 @@ ssize_t send_packet (interface, packet, - (unsigned char *)raw, len); - memcpy (buf + ibufp, raw, len); - -- /* For some reason, SOCK_PACKET sockets can't be connected, -- so we have to do a sentdo every time. */ -- memset (&sa, 0, sizeof sa); -- sa.sa_family = AF_PACKET; -- strncpy (sa.sa_data, -- (const char *)interface -> ifp, sizeof sa.sa_data); -- -- result = sendto (interface -> wfdesc, -- buf + fudge, ibufp + len - fudge, 0, &sa, sizeof sa); -+ result = write (interface -> wfdesc, buf + fudge, ibufp + len - fudge); - if (result < 0) - log_error ("send_packet: %m"); - return result; -@@ -335,14 +359,35 @@ ssize_t receive_packet (interface, buf, - { - int length = 0; - int offset = 0; -+ int nocsum = 0; - unsigned char ibuf [1536]; - unsigned bufix = 0; - unsigned paylen; -+ unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))]; -+ struct iovec iov = { -+ .iov_base = ibuf, -+ .iov_len = sizeof ibuf, -+ }; -+ struct msghdr msg = { -+ .msg_iov = &iov, -+ .msg_iovlen = 1, -+ .msg_control = cmsgbuf, -+ .msg_controllen = sizeof(cmsgbuf), -+ }; -+ struct cmsghdr *cmsg; - -- length = read (interface -> rfdesc, ibuf, sizeof ibuf); -+ length = recvmsg (interface -> rfdesc, &msg, 0); - if (length <= 0) - return length; - -+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) { -+ if (cmsg->cmsg_level == SOL_PACKET && -+ cmsg->cmsg_type == PACKET_AUXDATA) { -+ struct tpacket_auxdata *aux = (void *)CMSG_DATA(cmsg); -+ nocsum = aux->tp_status & TP_STATUS_CSUMNOTREADY; -+ } -+ } -+ - bufix = 0; - /* Decode the physical header... */ - offset = decode_hw_header (interface, ibuf, bufix, hfrom); -@@ -359,7 +404,7 @@ ssize_t receive_packet (interface, buf, - - /* Decode the IP and UDP headers... */ - offset = decode_udp_ip_header (interface, ibuf, bufix, from, -- (unsigned)length, &paylen); -+ (unsigned)length, &paylen, nocsum); - - /* If the IP or UDP checksum was bad, skip the packet... */ - if (offset < 0) -diff -up dhcp-3.0.6/common/nit.c.xen dhcp-3.0.6/common/nit.c ---- dhcp-3.0.6/common/nit.c.xen 2007-05-01 16:42:55.000000000 -0400 -+++ dhcp-3.0.6/common/nit.c 2007-07-10 14:05:16.000000000 -0400 -@@ -371,7 +371,7 @@ ssize_t receive_packet (interface, buf, - - /* Decode the IP and UDP headers... */ - offset = decode_udp_ip_header (interface, ibuf, bufix, -- from, length, &paylen); -+ from, length, &paylen, 0); - - /* If the IP or UDP checksum was bad, skip the packet... */ - if (offset < 0) -diff -up dhcp-3.0.6/common/packet.c.xen dhcp-3.0.6/common/packet.c ---- dhcp-3.0.6/common/packet.c.xen 2007-07-10 11:50:22.000000000 -0400 -+++ dhcp-3.0.6/common/packet.c 2007-07-10 14:06:24.000000000 -0400 -@@ -215,7 +215,7 @@ ssize_t - decode_udp_ip_header(struct interface_info *interface, - unsigned char *buf, unsigned bufix, - struct sockaddr_in *from, unsigned buflen, -- unsigned *rbuflen) -+ unsigned *rbuflen, int nocsum) - { - unsigned char *data; - struct ip ip; -@@ -326,7 +326,7 @@ decode_udp_ip_header(struct interface_in - 8, IPPROTO_UDP + ulen)))); - - udp_packets_seen++; -- if (usum && usum != sum) { -+ if (!nocsum && usum && usum != sum) { - udp_packets_bad_checksum++; - if (udp_packets_seen > 4 && - (udp_packets_seen / udp_packets_bad_checksum) < 2) { -diff -up dhcp-3.0.6/common/upf.c.xen dhcp-3.0.6/common/upf.c ---- dhcp-3.0.6/common/upf.c.xen 2007-05-01 16:42:56.000000000 -0400 -+++ dhcp-3.0.6/common/upf.c 2007-07-10 14:06:37.000000000 -0400 -@@ -322,7 +322,7 @@ ssize_t receive_packet (interface, buf, - - /* Decode the IP and UDP headers... */ - offset = decode_udp_ip_header (interface, ibuf, bufix, -- from, length, &paylen); -+ from, length, &paylen, 0); - - /* If the IP or UDP checksum was bad, skip the packet... */ - if (offset < 0) diff --git a/dhcp-3.1.0-dhclient-anycast.patch b/dhcp-3.1.0-dhclient-anycast.patch new file mode 100644 index 0000000..47cf2e6 --- /dev/null +++ b/dhcp-3.1.0-dhclient-anycast.patch @@ -0,0 +1,82 @@ +diff -up dhcp-3.1.0/common/lpf.c.anycast dhcp-3.1.0/common/lpf.c +--- dhcp-3.1.0/common/lpf.c.anycast 2007-10-22 16:16:48.000000000 -0400 ++++ dhcp-3.1.0/common/lpf.c 2007-10-22 16:19:01.000000000 -0400 +@@ -334,6 +334,9 @@ ssize_t send_packet (interface, packet, + return send_fallback (interface, packet, raw, + len, from, to, hto); + ++ if (hto == NULL && interface->anycast_mac_addr.hlen) ++ hto = &interface->anycast_mac_addr; ++ + /* Assemble the headers... */ + assemble_hw_header (interface, (unsigned char *)hh, &hbufp, hto); + fudge = hbufp % 4; /* IP header must be word-aligned. */ +diff -up dhcp-3.1.0/common/conflex.c.anycast dhcp-3.1.0/common/conflex.c +--- dhcp-3.1.0/common/conflex.c.anycast 2007-10-22 16:16:47.000000000 -0400 ++++ dhcp-3.1.0/common/conflex.c 2007-10-22 16:18:52.000000000 -0400 +@@ -549,6 +549,8 @@ static enum dhcp_token intern (atom, dfv + } + if (!strcasecmp (atom + 1, "nd")) + return AND; ++ if (!strcasecmp (atom + 1, "nycast-mac")) ++ return ANYCAST_MAC; + if (!strcasecmp (atom + 1, "ppend")) + return APPEND; + if (!strcasecmp (atom + 1, "llow")) +diff -up dhcp-3.1.0/includes/site.h.anycast dhcp-3.1.0/includes/site.h +--- dhcp-3.1.0/includes/site.h.anycast 2007-10-22 16:16:47.000000000 -0400 ++++ dhcp-3.1.0/includes/site.h 2007-10-22 16:19:43.000000000 -0400 +@@ -184,6 +184,8 @@ + + #define TRACING + ++#define USE_LPF ++ + /* Define this if you want to read your config from LDAP. Read README.ldap + about how to set this up */ + +diff -up dhcp-3.1.0/includes/dhcpd.h.anycast dhcp-3.1.0/includes/dhcpd.h +--- dhcp-3.1.0/includes/dhcpd.h.anycast 2007-10-22 16:16:48.000000000 -0400 ++++ dhcp-3.1.0/includes/dhcpd.h 2007-10-22 16:19:17.000000000 -0400 +@@ -990,6 +990,7 @@ struct interface_info { + int dlpi_sap_length; + struct hardware dlpi_broadcast_addr; + # endif /* DLPI_SEND || DLPI_RECEIVE */ ++ struct hardware anycast_mac_addr; + }; + + struct hardware_link { +diff -up dhcp-3.1.0/includes/dhctoken.h.anycast dhcp-3.1.0/includes/dhctoken.h +--- dhcp-3.1.0/includes/dhctoken.h.anycast 2007-10-22 16:16:48.000000000 -0400 ++++ dhcp-3.1.0/includes/dhctoken.h 2007-10-22 16:20:33.000000000 -0400 +@@ -326,7 +326,8 @@ enum dhcp_token { + DOMAIN_LIST = 630, + LEASEQUERY = 631, + EXECUTE = 632, +- BOOTP_BROADCAST_ALWAYS = 633 ++ BOOTP_BROADCAST_ALWAYS = 633, ++ ANYCAST_MAC = 634 + }; + + #define is_identifier(x) ((x) >= FIRST_TOKEN && \ +diff -up dhcp-3.1.0/client/clparse.c.anycast dhcp-3.1.0/client/clparse.c +--- dhcp-3.1.0/client/clparse.c.anycast 2007-10-22 16:16:48.000000000 -0400 ++++ dhcp-3.1.0/client/clparse.c 2007-10-22 16:18:40.000000000 -0400 +@@ -407,6 +407,17 @@ void parse_client_statement (cfile, ip, + } + return; + ++ case ANYCAST_MAC: ++ token = next_token (&val, (unsigned *)0, cfile); ++ if (ip) { ++ parse_hardware_param (cfile, &ip -> anycast_mac_addr); ++ } else { ++ parse_warn (cfile, "anycast mac address parameter %s", ++ "not allowed here."); ++ skip_to_semi (cfile); ++ } ++ return; ++ + case REQUEST: + token = next_token (&val, (unsigned *)0, cfile); + if (config -> requested_options == default_requested_options) diff --git a/dhcp-3.1.0-dhclient-usage.patch b/dhcp-3.1.0-dhclient-usage.patch new file mode 100644 index 0000000..efdc702 --- /dev/null +++ b/dhcp-3.1.0-dhclient-usage.patch @@ -0,0 +1,39 @@ +diff -up dhcp-3.1.0/client/dhclient.c.usage dhcp-3.1.0/client/dhclient.c +--- dhcp-3.1.0/client/dhclient.c.usage 2007-10-22 15:52:06.000000000 -0400 ++++ dhcp-3.1.0/client/dhclient.c 2007-10-22 15:54:21.000000000 -0400 +@@ -818,16 +818,25 @@ int main (argc, argv, envp) + + static void usage () + { +- log_info ("%s %s", message, DHCP_VERSION); +- log_info (copyright); +- log_info (arr); +- log_info (url); +- +- log_error ("Usage: dhclient [-1dqrx] [-nw] [-p ] %s", +- "[-s server]"); +- log_error (" [-cf config-file] [-lf lease-file]%s", +- "[-pf pid-file] [-e VAR=val]"); +- log_fatal (" [-sf script-file] [interface]"); ++ printf ("%s %s\n", message, DHCP_VERSION); ++ printf (copyright); ++ printf ("\n"); ++ printf (arr); ++ printf ("\n"); ++ printf (url); ++ printf ("\n"); ++ ++ printf ("Usage: dhclient [-1dqr] [-nw] [-p ] %s", ++ "[-s server]"); ++ printf (" [-cf config-file] [-lf lease-file]%s", ++ "[-pf pid-file] [-e VAR=val]"); ++ printf (" [ -I ] [-B]\n"); ++ printf (" [ -H | -F ] [ -T ]\n"); ++ printf (" [ -V ]\n"); ++ printf (" [ -R ]\n"); ++ printf (" [-sf script-file] [interface]\n"); ++ ++ exit (EXIT_FAILURE); + } + + isc_result_t find_class (struct class **c, diff --git a/dhcp-3.1.0-ldap-configuration.patch b/dhcp-3.1.0-ldap-configuration.patch new file mode 100644 index 0000000..cd674a3 --- /dev/null +++ b/dhcp-3.1.0-ldap-configuration.patch @@ -0,0 +1,1488 @@ +diff -up dhcp-3.1.0/server/mdb.c.ldap dhcp-3.1.0/server/mdb.c +--- dhcp-3.1.0/server/mdb.c.ldap 2007-06-08 14:57:02.000000000 -0400 ++++ dhcp-3.1.0/server/mdb.c 2007-10-22 16:29:48.000000000 -0400 +@@ -454,6 +454,12 @@ int find_hosts_by_haddr (struct host_dec + { + struct host_decl *foo; + struct hardware h; ++ int ret; ++ ++#if defined(LDAP_CONFIGURATION) ++ if ((ret = find_haddr_in_ldap (hp, htype, hlen, haddr, file, line))) ++ return ret; ++#endif + + h.hlen = hlen + 1; + h.hbuf [0] = htype; +diff -up dhcp-3.1.0/server/Makefile.dist.ldap dhcp-3.1.0/server/Makefile.dist +--- dhcp-3.1.0/server/Makefile.dist.ldap 2006-07-25 09:26:00.000000000 -0400 ++++ dhcp-3.1.0/server/Makefile.dist 2007-10-22 16:29:48.000000000 -0400 +@@ -25,9 +25,9 @@ + CATMANPAGES = dhcpd.cat8 dhcpd.conf.cat5 dhcpd.leases.cat5 + SEDMANPAGES = dhcpd.man8 dhcpd.conf.man5 dhcpd.leases.man5 + SRCS = dhcpd.c dhcp.c bootp.c confpars.c db.c class.c failover.c \ +- omapi.c mdb.c stables.c salloc.c ddns.c dhcpleasequery.c ++ omapi.c mdb.c stables.c salloc.c ddns.c dhcpleasequery.c ldap.c + OBJS = dhcpd.o dhcp.o bootp.o confpars.o db.o class.o failover.o \ +- omapi.o mdb.o stables.o salloc.o ddns.o dhcpleasequery.o ++ omapi.o mdb.o stables.o salloc.o ddns.o dhcpleasequery.o ldap.o + PROG = dhcpd + MAN = dhcpd.8 dhcpd.conf.5 dhcpd.leases.5 + +@@ -106,6 +106,6 @@ dhcpd.leases.man5: dhcpd.leases.5 + -e "s#RUNDIR#$(VARRUN)#g" < dhcpd.leases.5 >dhcpd.leases.man5 + + dhcpd: $(OBJS) $(COBJ) $(DHCPLIB) +- $(CC) $(LFLAGS) -o dhcpd $(OBJS) $(DHCPLIB) $(LIBS) ++ $(CC) $(LFLAGS) -o dhcpd $(OBJS) $(DHCPLIB) $(LIBS) -lldap + + # Dependencies (semi-automatically-generated) +diff -up dhcp-3.1.0/server/dhcpd.c.ldap dhcp-3.1.0/server/dhcpd.c +--- dhcp-3.1.0/server/dhcpd.c.ldap 2007-05-29 13:49:44.000000000 -0400 ++++ dhcp-3.1.0/server/dhcpd.c 2007-10-22 16:29:48.000000000 -0400 +@@ -440,6 +440,9 @@ int main (argc, argv, envp) + /* Add the ddns update style enumeration prior to parsing. */ + add_enumeration (&ddns_styles); + add_enumeration (&syslog_enum); ++#if defined (LDAP_CONFIGURATION) ++ add_enumeration (&ldap_methods); ++#endif + + if (!group_allocate (&root_group, MDL)) + log_fatal ("Can't allocate root group!"); +diff -up /dev/null dhcp-3.1.0/server/ldap.c +--- /dev/null 2007-10-22 10:27:59.854008585 -0400 ++++ dhcp-3.1.0/server/ldap.c 2007-10-22 16:29:48.000000000 -0400 +@@ -0,0 +1,1142 @@ ++/* ldap.c ++ ++ Routines for reading the configuration from LDAP */ ++ ++/* ++ * Copyright (c) 1996-2001 Ntelos, Inc. ++ * 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 LDAP module was written by Brian Masney . It's ++ * development was sponsored by Ntelos, Inc. (www.ntelos.com). ++ */ ++ ++#include "dhcpd.h" ++ ++#if defined(LDAP_CONFIGURATION) ++ ++static LDAP * ld = NULL; ++static char *ldap_server = NULL, ++ *ldap_username = NULL, ++ *ldap_password = NULL, ++ *ldap_base_dn = NULL; ++static int ldap_method = LDAP_METHOD_DYNAMIC, ++ disable_ldap = 0; ++static struct ldap_config_stack *ldap_stack = NULL; ++ ++ ++static void ++ldap_parse_class (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **temp; ++ ++ if ((temp = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || ++ temp[0]->bv_val == NULL) ++ { ++ if (temp != NULL) ++ ldap_value_free_len (temp); ++ ++ return; ++ } ++ ++ strncat (cfile->inbuf, "class \"", LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, temp[0]->bv_val, LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, "\" {\n", LDAP_BUFFER_SIZE); ++ ++ item->close_brace = 1; ++ ldap_value_free_len (temp); ++} ++ ++ ++static void ++ldap_parse_subclass (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **temp, **classdata; ++ ++ if ((temp = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || ++ temp[0]->bv_val == NULL) ++ { ++ if (temp != NULL) ++ ldap_value_free_len (temp); ++ ++ return; ++ } ++ ++ ++ if ((classdata = ldap_get_values_len (ld, item->ldent, ++ "dhcpClassData")) == NULL || ++ classdata[0]->bv_val == NULL) ++ { ++ if (classdata != NULL) ++ ldap_value_free_len (classdata); ++ ldap_value_free_len (temp); ++ ++ return; ++ } ++ ++ strncat (cfile->inbuf, "subclass ", LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, (*classdata)->bv_val, LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, (*temp)->bv_val, LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE); ++ ++ item->close_brace = 1; ++ ldap_value_free_len (temp); ++ ldap_value_free_len (classdata); ++} ++ ++ ++static void ++ldap_parse_host (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **temp, **hwaddr; ++ ++ ++ if ((temp = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || ++ temp[0]->bv_val == NULL) ++ { ++ if (temp != NULL) ++ ldap_value_free_len (temp); ++ ++ return; ++ } ++ ++ if ((hwaddr = ldap_get_values_len (ld, item->ldent, ++ "dhcpHWAddress")) == NULL || ++ hwaddr[0]->bv_val == NULL) ++ { ++ if (hwaddr != NULL) ++ ldap_value_free_len (hwaddr); ++ ldap_value_free_len (temp); ++ ++ return; ++ } ++ ++ strncat (cfile->inbuf, "host ", LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, (*temp)->bv_val, LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, " {\nhardware ", LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, (*hwaddr)->bv_val, LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ ++ item->close_brace = 1; ++ ldap_value_free_len (temp); ++ ldap_value_free_len (hwaddr); ++} ++ ++ ++static void ++ldap_parse_shared_network (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **temp; ++ ++ ++ if ((temp = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || ++ temp[0]->bv_val == NULL) ++ { ++ if (temp != NULL) ++ ldap_value_free_len (temp); ++ ++ return; ++ } ++ ++ strncat (cfile->inbuf, "shared-network ", LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, (*temp)->bv_val, LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE); ++ ++ item->close_brace = 1; ++ ldap_value_free_len (temp); ++} ++ ++ ++static void ++parse_netmask (int netmask, char *netmaskbuf) ++{ ++ unsigned long nm; ++ int i; ++ ++ nm = 0; ++ for (i=1; i <= netmask; i++) ++ { ++ nm |= 1 << (32 - i); ++ } ++ ++ sprintf (netmaskbuf, "%d.%d.%d.%d", (int) (nm >> 24) & 0xff, ++ (int) (nm >> 16) & 0xff, ++ (int) (nm >> 8) & 0xff, ++ (int) nm & 0xff); ++} ++ ++static void ++ldap_parse_subnet (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **temp, **netmask; ++ char netmaskbuf[16]; ++ int i; ++ ++ if ((temp = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || ++ temp[0]->bv_val == NULL) ++ { ++ if (temp != NULL) ++ ldap_value_free_len (temp); ++ ++ return; ++ } ++ ++ if ((netmask = ldap_get_values_len (ld, item->ldent, ++ "dhcpNetmask")) == NULL || ++ netmask[0]->bv_val == NULL) ++ { ++ if (netmask != NULL) ++ ldap_value_free_len (netmask); ++ ldap_value_free_len (temp); ++ ++ return; ++ } ++ ++ strncat (cfile->inbuf, "subnet ", LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, temp[0]->bv_val, LDAP_BUFFER_SIZE); ++ ++ strncat (cfile->inbuf, " netmask ", LDAP_BUFFER_SIZE); ++ parse_netmask (strtol (netmask[0]->bv_val, NULL, 10), netmaskbuf); ++ strncat (cfile->inbuf, netmaskbuf, LDAP_BUFFER_SIZE); ++ ++ strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE); ++ ++ ldap_value_free_len (temp); ++ ldap_value_free_len (netmask); ++ ++ if ((temp = ldap_get_values_len (ld, item->ldent, "dhcpRange")) != NULL) ++ { ++ strncat (cfile->inbuf, "range", LDAP_BUFFER_SIZE); ++ for (i=0; temp[i] != NULL && temp[i]->bv_val != NULL; i++) ++ { ++ strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, temp[i]->bv_val, LDAP_BUFFER_SIZE); ++ } ++ strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ ldap_value_free_len (temp); ++ } ++ ++ item->close_brace = 1; ++} ++ ++ ++static void ++ldap_parse_pool (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **temp; ++ int i; ++ ++ strncat (cfile->inbuf, "pool {\n", LDAP_BUFFER_SIZE); ++ ++ if ((temp = ldap_get_values_len (ld, item->ldent, "dhcpRange")) != NULL) ++ { ++ strncat (cfile->inbuf, "range", LDAP_BUFFER_SIZE); ++ for (i=0; temp[i] != NULL && temp[i]->bv_val != NULL; i++) ++ { ++ strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, temp[i]->bv_val, LDAP_BUFFER_SIZE); ++ } ++ strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ ldap_value_free_len (temp); ++ } ++ ++ if ((temp = ldap_get_values_len (ld, item->ldent, "dhcpPermitList")) != NULL) ++ { ++ for (i=0; temp[i] != NULL && temp[i]->bv_val != NULL; i++) ++ { ++ strncat (cfile->inbuf, temp[i]->bv_val, LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ } ++ ldap_value_free_len (temp); ++ } ++ ++ item->close_brace = 1; ++} ++ ++ ++static void ++ldap_parse_group (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ strncat (cfile->inbuf, "group {\n", LDAP_BUFFER_SIZE); ++ item->close_brace = 1; ++} ++ ++ ++static void ++parse_external_dns (LDAPMessage * ent) ++{ ++ char *search[] = {"dhcpOptionsDN", "dhcpSharedNetworkDN", "dhcpSubnetDN", ++ "dhcpGroupDN", "dhcpHostDN", "dhcpClassesDN", ++ "dhcpPoolDN", NULL}; ++ LDAPMessage * newres, * newent; ++ struct ldap_config_stack *ns; ++ struct berval **temp; ++ int i, ret; ++ ++ for (i=0; search[i] != NULL; i++) ++ { ++ if ((ldap_method == LDAP_METHOD_DYNAMIC) && ++ (strcmp (search[i], "dhcpHostDN") == 0)) ++ continue; ++ ++ if ((temp = ldap_get_values_len (ld, ent, search[i])) == NULL) ++ continue; ++ ++ if ((ret = ldap_search_ext_s (ld, temp[0]->bv_val, LDAP_SCOPE_BASE, ++ "objectClass=*", NULL, 0, ++ NULL, NULL, NULL, 0, ++ &newres)) != LDAP_SUCCESS) ++ { ++ ldap_value_free_len (temp); ++ ldap_unbind_ext (ld, NULL, NULL); ++ ld = NULL; ++ return; ++ } ++ ++ ldap_value_free_len (temp); ++ ++ newent = ldap_first_entry (ld, newres); ++ if (newent == NULL) ++ { ++ ldap_msgfree (newres); ++ continue; ++ } ++ ++#if defined(DEBUG_LDAP) ++ log_info ("Adding LDAP entry '%s' as child", ldap_get_dn (ld, newent)); ++#endif ++ ++ ns = dmalloc (sizeof (*ns), MDL); ++ ns->res = newres; ++ ns->ldent = newent; ++ ns->close_brace = 0; ++ ns->processed = 0; ++ ns->children = NULL; ++ ns->next = ldap_stack->children; ++ ldap_stack->children = ns; ++ } ++} ++ ++ ++static void ++ldap_generate_config_string (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **objectClass, **temp; ++ int i, j, ignore, found; ++ ++ if ((objectClass = ldap_get_values_len (ld, item->ldent, ++ "objectClass")) == NULL) ++ return; ++ ++ ignore = 0; ++ found = 1; ++ for (i=0; objectClass[i] != NULL && objectClass[i]->bv_val != NULL; i++) ++ { ++ if (strcmp (objectClass[i]->bv_val, "dhcpSharedNetwork") == 0) ++ ldap_parse_shared_network (item, cfile); ++ else if (strcmp (objectClass[i]->bv_val, "dhcpClass") == 0) ++ ldap_parse_class (item, cfile); ++ else if (strcmp (objectClass[i]->bv_val, "dhcpSubnet") == 0) ++ ldap_parse_subnet (item, cfile); ++ else if (strcmp (objectClass[i]->bv_val, "dhcpPool") == 0) ++ ldap_parse_pool (item, cfile); ++ else if (strcmp (objectClass[i]->bv_val, "dhcpGroup") == 0) ++ ldap_parse_group (item, cfile); ++ else if (strcmp (objectClass[i]->bv_val, "dhcpHost") == 0) ++ { ++ if (ldap_method == LDAP_METHOD_STATIC) ++ ldap_parse_host (item, cfile); ++ else ++ { ++ ignore = 1; ++ break; ++ } ++ } ++ else if (strcmp (objectClass[i]->bv_val, "dhcpSubClass") == 0) ++ { ++ if (ldap_method == LDAP_METHOD_STATIC) ++ ldap_parse_subclass (item, cfile); ++ else ++ { ++ ignore = 1; ++ break; ++ } ++ } ++ else ++ found = 0; ++ ++ if (found && cfile->inbuf[0] == '\0') ++ { ++ ignore = 1; ++ break; ++ } ++ } ++ ++ ldap_value_free_len (objectClass); ++ ++ if (ignore) ++ return; ++ ++ if ((temp = ldap_get_values_len (ld, item->ldent, "dhcpOption")) != NULL) ++ { ++ for (j=0; temp[j] != NULL && temp[j]->bv_val != NULL; j++) ++ { ++ strncat (cfile->inbuf, "option ", LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, temp[j]->bv_val, LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ } ++ ldap_value_free_len (temp); ++ } ++ ++ if ((temp = ldap_get_values_len (ld, item->ldent, "dhcpStatements")) != NULL) ++ { ++ for (j=0; temp[j] != NULL && temp[j]->bv_val != NULL; j++) ++ { ++ strncat (cfile->inbuf, temp[j]->bv_val, LDAP_BUFFER_SIZE); ++ strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ } ++ ldap_value_free_len (temp); ++ } ++ ++ parse_external_dns (item->ldent); ++} ++ ++ ++static void ++free_stack_entry (struct ldap_config_stack *item) ++{ ++ ldap_msgfree (item->res); ++ dfree (item, MDL); ++} ++ ++ ++static void ++next_ldap_entry (struct parse *cfile) ++{ ++ struct ldap_config_stack *temp_stack; ++ ++ if (ldap_stack->processed && ldap_stack->children != NULL) ++ { ++ temp_stack = ldap_stack->children; ++ if (temp_stack->close_brace) ++ strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE); ++ ++ ldap_stack->children = ldap_stack->children->next; ++ free_stack_entry (temp_stack); ++ ++ if (ldap_stack->processed && ldap_stack->children != NULL) ++ return; ++ } ++ ++ if (ldap_stack->close_brace) ++ { ++ strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE); ++ ldap_stack->close_brace = 0; ++ } ++ ++ while (ldap_stack != NULL && ldap_stack->children == NULL && ++ (ldap_stack->ldent = ldap_next_entry (ld, ldap_stack->ldent)) == NULL) ++ { ++ if (ldap_stack->close_brace) ++ { ++ strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE); ++ ldap_stack->close_brace = 0; ++ } ++ ++ temp_stack = ldap_stack; ++ ldap_stack = ldap_stack->next; ++ free_stack_entry (temp_stack); ++ } ++ ++ if (ldap_stack != NULL && ldap_stack->children == NULL && ++ ldap_stack->close_brace) ++ { ++ strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE); ++ ldap_stack->close_brace = 0; ++ } ++} ++ ++ ++static void ++add_to_config_stack (LDAPMessage * res, LDAPMessage * ent) ++{ ++ struct ldap_config_stack *ns; ++ ++ ns = dmalloc (sizeof (*ns), MDL); ++ ns->res = res; ++ ns->ldent = ent; ++ ns->close_brace = 0; ++ ns->processed = 0; ++ ns->children = NULL; ++ ns->next = ldap_stack; ++ ldap_stack = ns; ++} ++ ++ ++static void ++ldap_start (void) ++{ ++ struct option_state *options; ++ struct option_cache *oc; ++ struct data_string db; ++ int ret; ++ ++ if (ld != NULL) ++ return; ++ ++ if (ldap_server == NULL) ++ { ++ options = NULL; ++ option_state_allocate (&options, MDL); ++ ++ execute_statements_in_scope ((struct binding_value **) NULL, ++ (struct packet *) NULL, (struct lease *) NULL, ++ (struct client_state *) NULL, (struct option_state *) NULL, ++ options, &global_scope, root_group, (struct group *) NULL); ++ ++ memset (&db, 0, sizeof (db)); ++ oc = lookup_option (&server_universe, options, SV_LDAP_SERVER); ++ if (oc && ++ evaluate_option_cache (&db, (struct packet*) NULL, ++ (struct lease *) NULL, (struct client_state *) NULL, ++ options, (struct option_state *) NULL, &global_scope, oc, MDL)) ++ { ++ ldap_server = dmalloc (db.len + 1, MDL); ++ if (!ldap_server) ++ log_fatal ("no memory for ldap server"); ++ memcpy (ldap_server, db.data, db.len); ++ ldap_server[db.len] = 0; ++ data_string_forget (&db, MDL); ++ } ++ ++ oc = lookup_option (&server_universe, options, SV_LDAP_USERNAME); ++ if (oc && ++ evaluate_option_cache (&db, (struct packet*) NULL, ++ (struct lease *) NULL, (struct client_state *) NULL, ++ options, (struct option_state *) NULL, &global_scope, oc, MDL)) ++ { ++ ldap_username = dmalloc (db.len + 1, MDL); ++ if (!ldap_username) ++ log_fatal ("no memory for ldap username"); ++ memcpy (ldap_username, db.data, db.len); ++ ldap_username[db.len] = 0; ++ data_string_forget (&db, MDL); ++ } ++ ++ oc = lookup_option (&server_universe, options, SV_LDAP_PASSWORD); ++ if (oc && ++ evaluate_option_cache (&db, (struct packet*) NULL, ++ (struct lease *) NULL, (struct client_state *) NULL, ++ options, (struct option_state *) NULL, &global_scope, oc, MDL)) ++ { ++ ldap_password = dmalloc (db.len + 1, MDL); ++ if (!ldap_password) ++ log_fatal ("no memory for ldap password"); ++ memcpy (ldap_password, db.data, db.len); ++ ldap_password[db.len] = 0; ++ data_string_forget (&db, MDL); ++ } ++ ++ oc = lookup_option (&server_universe, options, SV_LDAP_BASE_DN); ++ if (oc && ++ evaluate_option_cache (&db, (struct packet*) NULL, ++ (struct lease *) NULL, (struct client_state *) NULL, ++ options, (struct option_state *) NULL, &global_scope, oc, MDL)) ++ { ++ ldap_base_dn = dmalloc (db.len + 1, MDL); ++ if (!ldap_base_dn) ++ log_fatal ("no memory for ldap password"); ++ memcpy (ldap_base_dn, db.data, db.len); ++ ldap_base_dn[db.len] = 0; ++ data_string_forget (&db, MDL); ++ } ++ ++ oc = lookup_option (&server_universe, options, SV_LDAP_METHOD); ++ if (oc && ++ evaluate_option_cache (&db, (struct packet*) NULL, ++ (struct lease *) NULL, (struct client_state *) NULL, ++ options, (struct option_state *) NULL, &global_scope, oc, MDL)) ++ { ++ ++ if (db.len == 1) ++ ldap_method = db.data [0]; ++ else ++ log_fatal ("invalid dns update type"); ++ data_string_forget (&db, MDL); ++ } ++ ++ option_state_dereference (&options, MDL); ++ } ++ ++ if (ldap_server == NULL || ldap_username == NULL || ldap_password == NULL || ++ ldap_base_dn == NULL) ++ { ++ log_info ("Not searching LDAP since ldap-server, ldap-username, ldap-password and ldap-base-dn were not specified in the config file"); ++ disable_ldap = 1; ++ return; ++ } ++ ++#if defined (DEBUG_LDAP) ++ log_info ("Connecting to LDAP server ldap://%s", ldap_server); ++#endif ++ ++ char *tmpserver = NULL; ++ if ((tmpserver = malloc(strlen(ldap_server) + 8)) == NULL) ++ { ++ log_error ("Cannot init tmpldapserver string to ldap://%s", ldap_server); ++ disable_ldap = 1; ++ return; ++ } ++ ++ if (sprintf(tmpserver, "ldap://%s", ldap_server) == -1) ++ { ++ log_error ("Cannot init tmpldapserver via sprintf()"); ++ disable_ldap = 1; ++ return; ++ } ++ ++ ldap_initialize (&ld, tmpserver); ++ if (ld == NULL) ++ { ++ log_error ("Cannot init ldap session to %s", ldap_server); ++ disable_ldap = 1; ++ return; ++ } ++ ++ free (tmpserver); ++ ++ struct berval cred; ++ cred.bv_val = strdup(ldap_password); ++ cred.bv_len = strlen(ldap_password); ++ ret = ldap_sasl_bind_s (ld, ldap_username, LDAP_SASL_SIMPLE, ++ &cred, NULL,NULL, NULL); ++ if (ret != LDAP_SUCCESS) ++ { ++ log_error ("Error: Cannot log into ldap server %s: %s", ldap_server, ++ ldap_err2string (ret)); ++ disable_ldap = 1; ++ ldap_unbind_ext (ld, NULL, NULL); ++ ld = NULL; ++ return; ++ } ++ ++#if defined (DEBUG_LDAP) ++ log_info ("Successfully logged into LDAP server %s", ldap_server); ++#endif ++} ++ ++ ++static int ++ldap_read_function (struct parse *cfile) ++{ ++ char *dn, eofstring[2] = {EOF, '\0'}; ++ struct ldap_config_stack *curentry; ++ LDAPMessage * ent, * res; ++ int ret; ++ ++ cfile->inbuf[0] = '\0'; ++ cfile->buflen = 0; ++ while (1) ++ { ++ if (ldap_stack == NULL) ++ { ++ strncat (cfile->inbuf, eofstring, LDAP_BUFFER_SIZE); ++ cfile->buflen = strlen (cfile->inbuf); ++ cfile->bufix = 1; ++ return (cfile->inbuf[0]); ++ } ++ ++ if (ldap_stack->processed && ldap_stack->children != NULL) ++ curentry = ldap_stack->children; ++ else ++ curentry = ldap_stack; ++ ++ dn = ldap_get_dn (ld, curentry->ldent); ++#if defined(DEBUG_LDAP) ++ log_info ("Found LDAP entry '%s'", dn); ++#endif ++ ++ ldap_generate_config_string (curentry, cfile); ++ if (strlen (cfile->inbuf) == 0) ++ { ++#if defined(DEBUG_LDAP) ++ log_info ("Skipping LDAP entry '%s'", dn); ++#endif ++ ldap_memfree (dn); ++ dn = NULL; ++ next_ldap_entry (cfile); ++ continue; ++ } ++ ++ curentry->processed = 1; ++ break; ++ } ++ ++ if (ld == NULL) ++ ldap_start (); ++ ++ if (ld == NULL) ++ { ++ strncat (cfile->inbuf, eofstring, LDAP_BUFFER_SIZE); ++ cfile->buflen = strlen (cfile->inbuf); ++ cfile->bufix = 1; ++ return (cfile->inbuf[0]); ++ } ++ ++ if ((ret = ldap_search_ext_s (ld, dn, LDAP_SCOPE_ONELEVEL, "objectClass=*", ++ NULL, 0, NULL, NULL, NULL, 0, ++ &res)) != LDAP_SUCCESS) ++ { ++ ldap_unbind_ext (ld, NULL, NULL); ++ ld = NULL; ++ ++ strncat (cfile->inbuf, eofstring, LDAP_BUFFER_SIZE); ++ cfile->buflen = strlen (cfile->inbuf); ++ cfile->bufix = 1; ++ return (cfile->inbuf[0]); ++ } ++ ++ ldap_memfree (dn); ++ ++ ent = ldap_first_entry (ld, res); ++ if (ent != NULL) ++ add_to_config_stack (res, ent); ++ else ++ { ++ ldap_msgfree (res); ++ next_ldap_entry (cfile); ++ } ++ ++#if defined (DEBUG_LDAP) ++ log_info ("Sending config line '%s'", cfile->inbuf); ++#endif ++ ++ cfile->buflen = strlen (cfile->inbuf); ++ cfile->bufix = 1; ++ return (cfile->inbuf[0]); ++} ++ ++ ++static char * ++ldap_get_host_name (LDAPMessage * ent) ++{ ++ struct berval **name; ++ char *ret; ++ ++ ret = NULL; ++ if ((name = ldap_get_values_len (ld, ent, "cn")) == NULL || name[0] == NULL) ++ { ++ if (name != NULL) ++ ldap_value_free_len (name); ++ ++#if defined (DEBUG_LDAP) ++ log_info ("Cannot get cn attribute for LDAP entry %s", ++ ldap_get_dn (ld, ent)); ++#endif ++ return (NULL); ++ } ++ ++ ret = dmalloc (strlen (name[0]->bv_val) + 1, MDL); ++ strcpy (ret, name[0]->bv_val); ++ ldap_value_free_len (name); ++ ++ return (ret); ++} ++ ++ ++isc_result_t ++ldap_read_config (void) ++{ ++ struct berval **temp; ++ char *buffer, dn[256]; ++ LDAPMessage * ldres, * ent; ++ struct parse *cfile; ++ struct utsname unme; ++ isc_result_t res; ++ int ret; ++ ++ ++ buffer = dmalloc (LDAP_BUFFER_SIZE, MDL); ++ cfile = (struct parse *) NULL; ++ res = new_parse (&cfile, -1, buffer, LDAP_BUFFER_SIZE, "LDAP", 0); ++ if (res != ISC_R_SUCCESS) ++ return (res); ++ ++ cfile->bufix = cfile->buflen = 0; ++ cfile->read_function = ldap_read_function; ++ ++ if (ld == NULL) ++ ldap_start (); ++ if (ld == NULL) ++ return (ldap_server == NULL ? ISC_R_SUCCESS : ISC_R_FAILURE); ++ ++ uname (&unme); ++ snprintf (dn, sizeof (dn), "(&(objectClass=dhcpServer)(cn=%s))", ++ unme.nodename); ++ ++ if ((ret = ldap_search_ext_s (ld, ldap_base_dn, LDAP_SCOPE_SUBTREE, dn, NULL, ++ 0, NULL, NULL, NULL, 0, &ldres)) != LDAP_SUCCESS) ++ { ++ ldap_unbind_ext (ld, NULL, NULL); ++ ld = NULL; ++ log_error ("Cannot search LDAP for %s: %s", dn, ldap_err2string (ret)); ++ return (ISC_R_FAILURE); ++ } ++ ++ if ((ent = ldap_first_entry (ld, ldres)) == NULL) ++ { ++ ldap_unbind_ext (ld, NULL, NULL); ++ ld = NULL; ++ log_error ("Error: Cannot find LDAP entry matching %s", dn); ++ return (ISC_R_FAILURE); ++ } ++ ++#if defined(DEBUG_LDAP) ++ buffer = ldap_get_dn (ld, ent); ++ log_info ("Found LDAP entry '%s'", buffer); ++ ldap_memfree (buffer); ++#endif ++ ++ if ((temp = ldap_get_values_len (ld, ent, "dhcpServiceDN")) == NULL || ++ temp[0]->bv_val == NULL) ++ { ++ if (temp != NULL) ++ ldap_value_free_len (temp); ++ ++ ldap_unbind_ext (ld, NULL, NULL); ++ ld = NULL; ++ log_error ("Error: Cannot find LDAP entry matching %s", dn); ++ return (ISC_R_FAILURE); ++ } ++ ++ ldap_msgfree (ldres); ++ ++ if ((ret = ldap_search_ext_s (ld, temp[0]->bv_val, LDAP_SCOPE_BASE, ++ "objectClass=*", NULL, 0, ++ NULL, NULL, NULL, 0, &ldres)) != LDAP_SUCCESS) ++ { ++ ldap_value_free_len (temp); ++ ldap_unbind_ext (ld, NULL, NULL); ++ ld = NULL; ++ log_error ("Cannot search LDAP for %s: %s", temp[0]->bv_val, ++ ldap_err2string (ret)); ++ return (ISC_R_FAILURE); ++ } ++ ++ if ((ent = ldap_first_entry (ld, ldres)) == NULL) ++ { ++ ldap_value_free_len (temp); ++ ldap_unbind_ext (ld, NULL, NULL); ++ ld = NULL; ++ log_error ("Error: Cannot find LDAP entry matching %s", temp[0]->bv_val); ++ return (ISC_R_FAILURE); ++ } ++ ++ ldap_value_free_len (temp); ++ ++ add_to_config_stack (ldres, ent); ++ ++ res = conf_file_subparse (cfile, root_group, ROOT_GROUP); ++ end_parse (&cfile); ++ ++ return (res); ++} ++ ++ ++/* This function will parse the dhcpOption and dhcpStatements field in the LDAP ++ entry if it exists. Right now, type will be either HOST_DECL or CLASS_DECL. ++ If we are parsing a HOST_DECL, this always returns 0. If we are parsing a ++ CLASS_DECL, this will return what the current lease limit is in LDAP. If ++ there is no lease limit specified, we return 0 */ ++ ++static int ++ldap_parse_options (LDAPMessage * ent, struct group *group, ++ int type, struct host_decl *host, ++ struct class **class) ++{ ++ struct berval **temp; ++ char option_buffer[8192]; ++ int i, declaration, lease_limit; ++ enum dhcp_token token; ++ struct parse *cfile; ++ isc_result_t res; ++ const char *val; ++ ++ lease_limit = 0; ++ *option_buffer = '\0'; ++ if ((temp = ldap_get_values_len (ld, ent, "dhcpStatements")) != NULL) ++ { ++ for (i=0; temp[i] != NULL && temp[i]->bv_val != NULL; i++) ++ { ++ if (strncasecmp ("lease limit ", temp[i]->bv_val, 12) == 0) ++ { ++ lease_limit = strtol ((temp[i]->bv_val) + 12, NULL, 10); ++ continue; ++ } ++ ++ strncat (option_buffer, temp[i]->bv_val, sizeof (option_buffer) - strlen (option_buffer) - 1); ++ strncat (option_buffer, ";\n", sizeof (option_buffer) - strlen (option_buffer) - 1); ++ } ++ ldap_value_free_len (temp); ++ } ++ ++ if ((temp = ldap_get_values_len (ld, ent, "dhcpOption")) != NULL) ++ { ++ for (i=0; temp[i] != NULL && temp[i]->bv_val != NULL; i++) ++ { ++ strncat (option_buffer, "option ", sizeof (option_buffer) - strlen (option_buffer) - 1); ++ strncat (option_buffer, temp[i]->bv_val, sizeof (option_buffer) - strlen (option_buffer) - 1); ++ strncat (option_buffer, ";\n", sizeof (option_buffer) - strlen (option_buffer) - 1); ++ } ++ ldap_value_free_len (temp); ++ } ++ ++ if (*option_buffer == '\0') ++ return (lease_limit); ++ ++ cfile = (struct parse *) NULL; ++ res = new_parse (&cfile, -1, option_buffer, strlen (option_buffer), ++ type == HOST_DECL ? "LDAP-HOST" : "LDAP-SUBCLASS", 0); ++ if (res != ISC_R_SUCCESS) ++ return (lease_limit); ++ ++#if defined (DEBUG_LDAP) ++ log_info ("Sending the following options: '%s'", option_buffer); ++#endif ++ ++ declaration = 0; ++ do { ++ token = peek_token (&val, NULL, cfile); ++ if (token == END_OF_FILE) ++ break; ++ declaration = parse_statement (cfile, group, type, host, declaration); ++ } while (1); ++ ++ end_parse (&cfile); ++ ++ return (lease_limit); ++} ++ ++ ++ ++int ++find_haddr_in_ldap (struct host_decl **hp, int htype, unsigned hlen, ++ const unsigned char *haddr, const char *file, int line) ++{ ++ char buf[60], *type_str; ++ LDAPMessage * res, *ent; ++ struct host_decl * host; ++ isc_result_t status; ++ int ret; ++ ++ if (disable_ldap || ldap_method == LDAP_METHOD_STATIC) ++ return (0); ++ ++ if (ld == NULL) ++ ldap_start (); ++ if (ld == NULL) ++ return (0); ++ ++ switch (htype) ++ { ++ case HTYPE_ETHER: ++ type_str = "ethernet"; ++ break; ++ case HTYPE_IEEE802: ++ type_str = "token-ring"; ++ break; ++ case HTYPE_FDDI: ++ type_str = "fddi"; ++ break; ++ default: ++ log_info ("Ignoring unknown type %d", htype); ++ return (0); ++ } ++ ++ snprintf (buf, sizeof (buf), "dhcpHWAddress=%s %s", type_str, ++ print_hw_addr (htype, hlen, haddr)); ++#if defined (DEBUG_LDAP) ++ log_info ("Searching for %s in LDAP tree %s", buf, ldap_base_dn); ++#endif ++ ++ if ((ret = ldap_search_ext_s (ld, ldap_base_dn, LDAP_SCOPE_SUBTREE, ++ buf, NULL, 0, NULL, NULL, NULL, 0, ++ &res)) != LDAP_SUCCESS) ++ { ++ if (ret != LDAP_NO_SUCH_OBJECT) ++ { ++ log_error ("Cannot search for %s in LDAP tree %s: %s", buf, ++ ldap_base_dn, ldap_err2string (ret)); ++ ldap_unbind_ext (ld, NULL, NULL); ++ ld = NULL; ++ } ++#if defined (DEBUG_LDAP) ++ else ++ log_info ("ldap_search_ext_s returned %s when searching for %s in %s", ++ ldap_err2string (ret), buf, ldap_base_dn); ++#endif ++ ++ return (0); ++ } ++ ++ if ((ent = ldap_first_entry (ld, res)) != NULL) ++ { ++#if defined (DEBUG_LDAP) ++ log_info ("Found LDAP entry %s", ldap_get_dn (ld, ent)); ++#endif ++ ++ host = (struct host_decl *)0; ++ status = host_allocate (&host, MDL); ++ if (status != ISC_R_SUCCESS) ++ { ++ log_fatal ("can't allocate host decl struct: %s", ++ isc_result_totext (status)); ++ return (0); ++ } ++ ++ host->name = ldap_get_host_name (ent); ++ if (host->name == NULL) ++ { ++ host_dereference (&host, MDL); ++ ldap_msgfree (res); ++ return (0); ++ } ++ ++ if (!clone_group (&host->group, root_group, MDL)) ++ { ++ log_fatal ("can't clone group for host %s", host->name); ++ host_dereference (&host, MDL); ++ return (0); ++ } ++ ++ ldap_parse_options (ent, host->group, HOST_DECL, host, NULL); ++ ++ *hp = host; ++ ldap_msgfree (res); ++ return (1); ++ } ++ ++ ++ ldap_msgfree (res); ++ return (0); ++} ++ ++ ++int ++find_subclass_in_ldap (struct class *class, struct class **newclass, ++ struct data_string *data) ++{ ++ LDAPMessage * res, * ent; ++ int ret, lease_limit; ++ isc_result_t status; ++ char buf[1024]; ++ ++ if (disable_ldap || ldap_method == LDAP_METHOD_STATIC) ++ return (0); ++ ++ if (ld == NULL) ++ ldap_start (); ++ if (ld == NULL) ++ return (0); ++ ++ snprintf (buf, sizeof (buf), "(&(objectClass=dhcpSubClass)(cn=%s)(dhcpClassData=%s))", print_hex_1 (data->len, data->data, 60), print_hex_2 (strlen (class->name), (const u_int8_t *) class->name, 60)); ++#if defined (DEBUG_LDAP) ++ log_info ("Searching LDAP for %s", buf); ++#endif ++ ++ if ((ret = ldap_search_ext_s (ld, ldap_base_dn, LDAP_SCOPE_SUBTREE, ++ buf, NULL, 0, NULL, NULL, NULL, 0, ++ &res)) != LDAP_SUCCESS) ++ { ++ if (ret != LDAP_NO_SUCH_OBJECT) ++ { ++ log_error ("Cannot search for %s in LDAP tree %s: %s", buf, ++ ldap_base_dn, ldap_err2string (ret)); ++ ldap_unbind_ext (ld, NULL, NULL); ++ ld = NULL; ++ } ++#if defined (DEBUG_LDAP) ++ else ++ log_info ("ldap_search_ext_s returned %s when searching for %s in %s", ++ ldap_err2string (ret), buf, ldap_base_dn); ++#endif ++ ++ return (0); ++ } ++ ++ if ((ent = ldap_first_entry (ld, res)) != NULL) ++ { ++#if defined (DEBUG_LDAP) ++ log_info ("Found LDAP entry %s", ldap_get_dn (ld, ent)); ++#endif ++ ++ status = class_allocate (newclass, MDL); ++ if (status != ISC_R_SUCCESS) ++ { ++ log_error ("Cannot allocate memory for a new class"); ++ return (0); ++ } ++ ++ group_reference (&(*newclass)->group, class->group, MDL); ++ class_reference (&(*newclass)->superclass, class, MDL); ++ lease_limit = ldap_parse_options (ent, (*newclass)->group, ++ CLASS_DECL, NULL, newclass); ++ if (lease_limit == 0) ++ (*newclass)->lease_limit = class->lease_limit; ++ else ++ class->lease_limit = lease_limit; ++ ++ if ((*newclass)->lease_limit) ++ { ++ (*newclass)->billed_leases = ++ dmalloc ((*newclass)->lease_limit * sizeof (struct lease *), MDL); ++ if (!(*newclass)->billed_leases) ++ { ++ log_error ("no memory for billing"); ++ class_dereference (newclass, MDL); ++ return (0); ++ } ++ memset ((*newclass)->billed_leases, 0, ++ ((*newclass)->lease_limit * sizeof (*newclass)->billed_leases)); ++ } ++ ++ data_string_copy (&(*newclass)->hash_string, data, MDL); ++ ++ ldap_msgfree (res); ++ return (1); ++ } ++ ++ ++ ldap_msgfree (res); ++ return (0); ++} ++ ++#endif ++ +diff -up dhcp-3.1.0/server/confpars.c.ldap dhcp-3.1.0/server/confpars.c +--- dhcp-3.1.0/server/confpars.c.ldap 2007-06-28 13:20:40.000000000 -0400 ++++ dhcp-3.1.0/server/confpars.c 2007-10-22 16:29:48.000000000 -0400 +@@ -63,7 +63,17 @@ void parse_trace_setup () + + isc_result_t readconf () + { +- return read_conf_file (path_dhcpd_conf, root_group, ROOT_GROUP, 0); ++ isc_result_t res; ++ ++ res = read_conf_file (path_dhcpd_conf, root_group, ROOT_GROUP, 0); ++#if defined(LDAP_CONFIGURATION) ++ if (res != ISC_R_SUCCESS) ++ return (res); ++ ++ return ldap_read_config (); ++#else ++ return (res); ++#endif + } + + isc_result_t read_conf_file (const char *filename, struct group *group, +diff -up dhcp-3.1.0/server/class.c.ldap dhcp-3.1.0/server/class.c +--- dhcp-3.1.0/server/class.c.ldap 2006-06-01 16:23:17.000000000 -0400 ++++ dhcp-3.1.0/server/class.c 2007-10-22 16:29:48.000000000 -0400 +@@ -90,6 +90,7 @@ int check_collection (packet, lease, col + int matched = 0; + int status; + int ignorep; ++ int classfound; + + for (class = collection -> classes; class; class = class -> nic) { + #if defined (DEBUG_CLASS_MATCHING) +@@ -135,9 +136,15 @@ int check_collection (packet, lease, col + class -> submatch, MDL)); + if (status && data.len) { + nc = (struct class *)0; +- if (class_hash_lookup (&nc, class -> hash, +- (const char *)data.data, +- data.len, MDL)) { ++ classfound = class_hash_lookup (&nc, class -> hash, ++ (const char *)data.data, data.len, MDL); ++ ++#ifdef LDAP_CONFIGURATION ++ if (!classfound && find_subclass_in_ldap (class, &nc, &data)) ++ classfound = 1; ++#endif ++ ++ if (classfound) { + #if defined (DEBUG_CLASS_MATCHING) + log_info ("matches subclass %s.", + print_hex_1 (data.len, +diff -up dhcp-3.1.0/server/stables.c.ldap dhcp-3.1.0/server/stables.c +--- dhcp-3.1.0/server/stables.c.ldap 2007-04-27 18:48:10.000000000 -0400 ++++ dhcp-3.1.0/server/stables.c 2007-10-22 16:29:48.000000000 -0400 +@@ -238,9 +238,38 @@ static struct option server_options[] = + { "adaptive-lease-time-threshold", "B", &server_universe, 50, 1 }, + { "do-reverse-updates", "f", &server_universe, 51, 1 }, + { "fqdn-reply", "f", &server_universe, 52, 1 }, ++#if defined(LDAP_CONFIGURATION) ++ { "ldap-server", "t", &server_universe, 53 }, ++ { "ldap-port", "d", &server_universe, 54 }, ++ { "ldap-username", "t", &server_universe, 55 }, ++ { "ldap-password", "t", &server_universe, 56 }, ++ { "ldap-base-dn", "t", &server_universe, 57 }, ++ { "ldap-method", "Nldap-methods.", &server_universe, 58 }, ++#else ++ { "unknown-53", "X", &server_universe, 53 }, ++ { "unknown-54", "X", &server_universe, 54 }, ++ { "unknown-55", "X", &server_universe, 55 }, ++ { "unknown-56", "X", &server_universe, 56 }, ++ { "unknown-57", "X", &server_universe, 57 }, ++ { "unknown-58", "X", &server_universe, 58 }, ++#endif + { NULL, NULL, NULL, 0, 0 } + }; + ++#if defined(LDAP_CONFIGURATION) ++struct enumeration_value ldap_values [] = { ++ { "static", LDAP_METHOD_STATIC }, ++ { "dynamic", LDAP_METHOD_DYNAMIC }, ++ { (char *) 0, 0 } ++}; ++ ++struct enumeration ldap_methods = { ++ (struct enumeration *)0, ++ "ldap-methods", ++ ldap_values ++}; ++#endif ++ + struct enumeration_value ddns_styles_values [] = { + { "none", 0 }, + { "ad-hoc", 1 }, +diff -up dhcp-3.1.0/common/print.c.ldap dhcp-3.1.0/common/print.c +--- dhcp-3.1.0/common/print.c.ldap 2007-05-29 13:49:44.000000000 -0400 ++++ dhcp-3.1.0/common/print.c 2007-10-22 16:29:48.000000000 -0400 +@@ -168,9 +168,9 @@ char *print_base64 (const unsigned char + } + + char *print_hw_addr (htype, hlen, data) +- int htype; +- int hlen; +- unsigned char *data; ++ const int htype; ++ const int hlen; ++ const unsigned char *data; + { + static char habuf [49]; + char *s; +diff -up dhcp-3.1.0/common/conflex.c.ldap dhcp-3.1.0/common/conflex.c +--- dhcp-3.1.0/common/conflex.c.ldap 2007-05-29 13:49:44.000000000 -0400 ++++ dhcp-3.1.0/common/conflex.c 2007-10-22 16:29:48.000000000 -0400 +@@ -47,6 +47,7 @@ static enum dhcp_token read_string PROTO + static enum dhcp_token read_number PROTO ((int, struct parse *)); + static enum dhcp_token read_num_or_name PROTO ((int, struct parse *)); + static enum dhcp_token intern PROTO ((unsigned char *, enum dhcp_token)); ++static int read_function PROTO ((struct parse *)); + + isc_result_t new_parse (cfile, file, inbuf, buflen, name, eolp) + struct parse **cfile; +@@ -74,6 +75,10 @@ isc_result_t new_parse (cfile, file, inb + tmp -> file = file; + tmp -> eol_token = eolp; + ++ if (file != -1) { ++ tmp -> read_function = read_function;; ++ } ++ + tmp -> bufix = 0; + tmp -> buflen = buflen; + if (inbuf) { +@@ -113,22 +118,11 @@ static int get_char (cfile) + int c; + + if (cfile -> bufix == cfile -> buflen) { +- if (cfile -> file != -1) { +- cfile -> buflen = +- read (cfile -> file, +- cfile -> inbuf, cfile -> bufsiz); +- if (cfile -> buflen == 0) { +- c = EOF; +- cfile -> bufix = 0; +- } else if (cfile -> buflen < 0) { +- c = EOF; +- cfile -> bufix = cfile -> buflen = 0; +- } else { +- c = cfile -> inbuf [0]; +- cfile -> bufix = 1; +- } +- } else ++ if (cfile -> read_function) { ++ c = cfile -> read_function (cfile); ++ } else { + c = EOF; ++ } + } else { + c = cfile -> inbuf [cfile -> bufix]; + cfile -> bufix++; +@@ -1213,3 +1207,23 @@ static enum dhcp_token intern (atom, dfv + } + return dfv; + } ++ ++static int ++read_function (struct parse * cfile) ++{ ++ int c; ++ ++ cfile -> buflen = read (cfile -> file, cfile -> inbuf, cfile -> bufsiz); ++ if (cfile -> buflen == 0) { ++ c = EOF; ++ cfile -> bufix = 0; ++ } else if (cfile -> buflen < 0) { ++ c = EOF; ++ cfile -> bufix = cfile -> buflen = 0; ++ } else { ++ c = cfile -> inbuf [0]; ++ cfile -> bufix = 1; ++ } ++ ++ return c; ++} +diff -up dhcp-3.1.0/includes/dhcpd.h.ldap dhcp-3.1.0/includes/dhcpd.h +--- dhcp-3.1.0/includes/dhcpd.h.ldap 2007-05-29 13:49:44.000000000 -0400 ++++ dhcp-3.1.0/includes/dhcpd.h 2007-10-22 16:29:56.000000000 -0400 +@@ -81,6 +81,11 @@ typedef struct hash_table class_hash_t; + #include + #include + ++#if defined(LDAP_CONFIGURATION) ++# include ++# include /* for uname() */ ++#endif ++ + #if !defined (BYTE_NAME_HASH_SIZE) + # define BYTE_NAME_HASH_SIZE 401 /* Default would be rediculous. */ + #endif +@@ -251,6 +256,8 @@ struct parse { + char *inbuf; + unsigned bufix, buflen; + unsigned bufsiz; ++ ++ int (*read_function) (struct parse *); + }; + + /* Variable-length array of data. */ +@@ -362,6 +369,26 @@ struct hardware { + u_int8_t hbuf [17]; + }; + ++#if defined(LDAP_CONFIGURATION) ++# define LDAP_BUFFER_SIZE 8192 ++# define LDAP_METHOD_STATIC 0 ++# define LDAP_METHOD_DYNAMIC 1 ++ ++/* This is a tree of the current configuration we are building from LDAP */ ++struct ldap_config_stack { ++ LDAPMessage * res; /* Pointer returned from ldap_search */ ++ LDAPMessage * ldent; /* Current item in LDAP that we're processing. ++ in res */ ++ int close_brace; /* Put a closing } after we're through with ++ this item */ ++ int processed; /* We set this flag if this base item has been ++ processed. After this base item is processed, ++ we can start processing the children */ ++ struct ldap_config_stack *children; ++ struct ldap_config_stack *next; ++}; ++#endif ++ + typedef enum { + server_startup = 0, + server_running = 1, +@@ -558,6 +585,15 @@ struct lease_state { + # define DEFAULT_PING_TIMEOUT 1 + #endif + ++#if defined(LDAP_CONFIGURATION) ++# define SV_LDAP_SERVER 47 ++# define SV_LDAP_PORT 48 ++# define SV_LDAP_USERNAME 49 ++# define SV_LDAP_PASSWORD 50 ++# define SV_LDAP_BASE_DN 51 ++# define SV_LDAP_METHOD 52 ++#endif ++ + #if !defined (DEFAULT_DEFAULT_LEASE_TIME) + # define DEFAULT_DEFAULT_LEASE_TIME 43200 + #endif +@@ -1702,7 +1738,7 @@ extern int db_time_format; + char *quotify_string (const char *, const char *, int); + char *quotify_buf (const unsigned char *, unsigned, const char *, int); + char *print_base64 (const unsigned char *, unsigned, const char *, int); +-char *print_hw_addr PROTO ((int, int, unsigned char *)); ++char *print_hw_addr PROTO ((const int, const int, const unsigned char *)); + void print_lease PROTO ((struct lease *)); + void dump_raw PROTO ((const unsigned char *, unsigned)); + void dump_packet_option (struct option_cache *, struct packet *, +@@ -2812,3 +2848,13 @@ OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_l + #endif /* FAILOVER_PROTOCOL */ + + const char *binding_state_print (enum failover_state); ++ ++/* ldap.c */ ++#if defined(LDAP_CONFIGURATION) ++extern struct enumeration ldap_methods; ++isc_result_t ldap_read_config (void); ++int find_haddr_in_ldap (struct host_decl **, int, unsigned, ++ const unsigned char *, const char *, int); ++int find_subclass_in_ldap (struct class *, struct class **, ++ struct data_string *); ++#endif +diff -up dhcp-3.1.0/includes/site.h.ldap dhcp-3.1.0/includes/site.h +--- dhcp-3.1.0/includes/site.h.ldap 2006-07-31 18:19:51.000000000 -0400 ++++ dhcp-3.1.0/includes/site.h 2007-10-22 16:29:48.000000000 -0400 +@@ -183,3 +183,13 @@ + traces. */ + + #define TRACING ++ ++/* Define this if you want to read your config from LDAP. Read README.ldap ++ about how to set this up */ ++ ++#define LDAP_CONFIGURATION ++ ++#define _PATH_DHCPD_DB "/var/lib/dhcpd/dhcpd.leases" ++#define _PATH_DHCLIENT_DB "/var/lib/dhclient/dhclient.leases" ++#define _PATH_DHCPD_DB "/var/lib/dhcpd/dhcpd.leases" ++#define _PATH_DHCLIENT_DB "/var/lib/dhclient/dhclient.leases" diff --git a/dhcp-3.1.0-libdhcp4client.patch b/dhcp-3.1.0-libdhcp4client.patch new file mode 100644 index 0000000..cd8f9bb --- /dev/null +++ b/dhcp-3.1.0-libdhcp4client.patch @@ -0,0 +1,1091 @@ +diff -up dhcp-3.1.0/omapip/dispatch.c.libdhcp4client dhcp-3.1.0/omapip/dispatch.c +--- dhcp-3.1.0/omapip/dispatch.c.libdhcp4client 2005-03-17 15:15:21.000000000 -0500 ++++ dhcp-3.1.0/omapip/dispatch.c 2007-10-22 16:00:15.000000000 -0400 +@@ -34,7 +34,7 @@ + + #include + +-static omapi_io_object_t omapi_io_states; ++omapi_io_object_t omapi_io_states; + TIME cur_time; + + OMAPI_OBJECT_ALLOC (omapi_io, +diff -up dhcp-3.1.0/omapip/errwarn.c.libdhcp4client dhcp-3.1.0/omapip/errwarn.c +--- dhcp-3.1.0/omapip/errwarn.c.libdhcp4client 2007-10-22 15:55:40.000000000 -0400 ++++ dhcp-3.1.0/omapip/errwarn.c 2007-10-22 16:00:30.000000000 -0400 +@@ -39,6 +39,11 @@ static char copyright[] = + #include + #include + ++#ifdef LIBDHCP ++#include ++extern LIBDHCP_Control *libdhcp_control; ++#endif ++ + #ifdef DEBUG + int log_perror = -1; + #else +@@ -48,7 +53,9 @@ int log_priority; + void (*log_cleanup) (void); + + #define CVT_BUF_MAX 1023 ++#ifndef LIBDHCP + static char mbuf [CVT_BUF_MAX + 1]; ++#endif + static char fbuf [CVT_BUF_MAX + 1]; + + /* Log an error message, then exit... */ +@@ -58,6 +65,16 @@ void log_fatal (const char * fmt, ... ) + va_list list; + + do_percentm (fbuf, fmt); ++ ++#ifdef LIBDHCP ++ if (libdhcp_control && (libdhcp_control->eh)) { ++ va_start (list, fmt); ++ libdhcp_control->eh(libdhcp_control, LOG_FATAL, fbuf, list); ++ va_end(list); ++ libdhcp_control->finished = 1; ++ return; ++ } ++#else + + /* %Audit% This is log output. %2004.06.17,Safe% + * If we truncate we hope the user can get a hint from the log. +@@ -91,6 +108,7 @@ void log_fatal (const char * fmt, ... ) + if (log_cleanup) + (*log_cleanup) (); + exit (1); ++#endif + } + + /* Log an error message... */ +@@ -101,6 +119,13 @@ int log_error (const char * fmt, ...) + + do_percentm (fbuf, fmt); + ++#ifdef LIBDHCP ++ if (libdhcp_control && libdhcp_control->eh) { ++ va_start (list, fmt); ++ libdhcp_control->eh(libdhcp_control, LOG_ERR, fbuf, list); ++ va_end(list); ++ } ++#else + /* %Audit% This is log output. %2004.06.17,Safe% + * If we truncate we hope the user can get a hint from the log. + */ +@@ -116,7 +141,7 @@ int log_error (const char * fmt, ...) + write (STDERR_FILENO, mbuf, strlen (mbuf)); + write (STDERR_FILENO, "\n", 1); + } +- ++#endif + return 0; + } + +@@ -128,6 +153,13 @@ int log_info (const char *fmt, ...) + + do_percentm (fbuf, fmt); + ++#ifdef LIBDHCP ++ if (libdhcp_control && libdhcp_control->eh) { ++ va_start (list, fmt); ++ libdhcp_control->eh(libdhcp_control, LOG_INFO, fbuf, list); ++ va_end(list); ++ } ++#else + /* %Audit% This is log output. %2004.06.17,Safe% + * If we truncate we hope the user can get a hint from the log. + */ +@@ -143,7 +175,7 @@ int log_info (const char *fmt, ...) + write (STDERR_FILENO, mbuf, strlen (mbuf)); + write (STDERR_FILENO, "\n", 1); + } +- ++#endif + return 0; + } + +@@ -154,7 +186,13 @@ int log_debug (const char *fmt, ...) + va_list list; + + do_percentm (fbuf, fmt); +- ++#ifdef LIBDHCP ++ if (libdhcp_control && libdhcp_control->eh) { ++ va_start (list, fmt); ++ libdhcp_control->eh(libdhcp_control, LOG_DEBUG, fbuf, list); ++ va_end(list); ++ } ++#else + /* %Audit% This is log output. %2004.06.17,Safe% + * If we truncate we hope the user can get a hint from the log. + */ +@@ -170,7 +208,7 @@ int log_debug (const char *fmt, ...) + write (STDERR_FILENO, mbuf, strlen (mbuf)); + write (STDERR_FILENO, "\n", 1); + } +- ++#endif + return 0; + } + +diff -up dhcp-3.1.0/omapip/alloc.c.libdhcp4client dhcp-3.1.0/omapip/alloc.c +--- dhcp-3.1.0/omapip/alloc.c.libdhcp4client 2006-02-24 18:16:30.000000000 -0500 ++++ dhcp-3.1.0/omapip/alloc.c 2007-10-22 16:00:03.000000000 -0400 +@@ -40,6 +40,33 @@ static char copyright[] = + + #include + ++#ifdef LIBDHCP ++/* OK, we need a quick and dirty way of freeing all memory used by libdhcp. ++ All pointers will be stored in a glibc tree on alloc, and removed on free. ++ This is not too expensive for light single-call library use. ++*/ ++#include ++extern void tdestroy (void *root, void (*free_node)(void *nodep)); ++static void *all_pointers=0L; ++static int ptr_comparator(const void *p1, const void *p2) { ++ return ((p1 == p2) ? 0 : ((p1 > p2) ? 1 : -1)); ++} ++ ++static void record_pointer(void *ptr) { ++ tsearch(ptr, &(all_pointers), ptr_comparator); ++} ++ ++static void forget_pointer(void *ptr) { ++ tdelete(ptr, &(all_pointers), ptr_comparator); ++} ++ ++void omapi_free_all_pointers(void) { ++ if (all_pointers != NULL) ++ tdestroy(all_pointers, free); ++ all_pointers = NULL; ++} ++#endif ++ + #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \ + defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) + struct dmalloc_preamble *dmalloc_list; +@@ -78,7 +105,9 @@ VOIDPTR dmalloc (size, file, line) + return (VOIDPTR)0; + + foo = malloc(len); +- ++#ifdef LIBDHCP ++ record_pointer(foo); ++#endif + if (!foo) + return (VOIDPTR)0; + bar = (VOIDPTR)(foo + DMDOFFSET); +@@ -200,6 +229,9 @@ void dfree (ptr, file, line) + 0, (unsigned char *)ptr + DMDOFFSET, 0, 1, RC_MALLOC); + #endif + free (ptr); ++#ifdef LIBDHCP ++ forget_pointer(ptr); ++#endif + } + + #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \ +diff -up dhcp-3.1.0/configure.libdhcp4client dhcp-3.1.0/configure +--- dhcp-3.1.0/configure.libdhcp4client 2005-03-17 15:14:55.000000000 -0500 ++++ dhcp-3.1.0/configure 2007-10-22 15:59:07.000000000 -0400 +@@ -246,7 +246,7 @@ if [ ! -d $workname ]; then + fi + + if [ x"$dirs" = x ]; then +- dirs=". client server relay common omapip dhcpctl minires dst" ++ dirs=". client server relay common omapip dhcpctl minires dst libdhcp4client" + fi + + for foo in $dirs; do +diff -up dhcp-3.1.0/dst/hmac_link.c.libdhcp4client dhcp-3.1.0/dst/hmac_link.c +--- dhcp-3.1.0/dst/hmac_link.c.libdhcp4client 2001-02-22 02:22:08.000000000 -0500 ++++ dhcp-3.1.0/dst/hmac_link.c 2007-10-22 15:59:24.000000000 -0400 +@@ -38,6 +38,10 @@ static const char rcsid[] = "$Header: /p + + #include "dst_internal.h" + ++#ifdef LIBDHCP ++extern void* dmalloc(size_t,char *,int); ++#endif ++ + #ifdef USE_MD5 + # include "md5.h" + # ifndef _MD5_H_ +@@ -86,7 +90,11 @@ dst_hmac_md5_sign(const int mode, DST_KE + MD5_CTX *ctx = NULL; + + if (mode & SIG_MODE_INIT) ++#ifdef LIBDHCP ++ ctx = (MD5_CTX *) dmalloc(sizeof(*ctx),__FILE__,__LINE__); ++#else + ctx = (MD5_CTX *) malloc(sizeof(*ctx)); ++#endif + else if (context) + ctx = (MD5_CTX *) *context; + if (ctx == NULL) +@@ -153,7 +161,11 @@ dst_hmac_md5_verify(const int mode, DST_ + MD5_CTX *ctx = NULL; + + if (mode & SIG_MODE_INIT) ++#ifdef LIBDHCP ++ ctx = (MD5_CTX *) dmalloc(sizeof(*ctx),__FILE__,__LINE__); ++#else + ctx = (MD5_CTX *) malloc(sizeof(*ctx)); ++#endif + else if (context) + ctx = (MD5_CTX *) *context; + if (ctx == NULL) +@@ -217,8 +229,11 @@ dst_buffer_to_hmac_md5(DST_KEY *dkey, co + + if (dkey == NULL || key == NULL || keylen < 0) + return (-1); +- ++#ifdef LIBDHCP ++ if ((hkey = (HMAC_Key *) dmalloc(sizeof(HMAC_Key),__FILE__,__LINE__)) == NULL) ++#else + if ((hkey = (HMAC_Key *) malloc(sizeof(HMAC_Key))) == NULL) ++#endif + return (-2); + + memset(hkey->hk_ipad, 0, sizeof(hkey->hk_ipad)); +@@ -347,7 +362,11 @@ dst_hmac_md5_key_from_file_format(DST_KE + if (eol == NULL) + return (-4); + len = eol - p; ++#ifdef LIBDHCP ++ tmp = dmalloc(len + 2,__FILE__,__LINE__); ++#else + tmp = malloc(len + 2); ++#endif + memcpy(tmp, p, len); + *(tmp + len) = 0x0; + key_len = b64_pton((char *)tmp, key, HMAC_LEN+1); /* see above */ +@@ -439,8 +458,11 @@ dst_hmac_md5_generate_key(DST_KEY *key, + return(0); + + len = size > 64 ? 64 : size; ++#ifdef LIBDHCP ++ buff = dmalloc(len+8,__FILE__,__LINE__); ++#else + buff = malloc(len+8); +- ++#endif + n = dst_random(DST_RAND_SEMI, len, buff); + n += dst_random(DST_RAND_KEY, len, buff); + if (n <= len) { /* failed getting anything */ +@@ -463,7 +485,11 @@ dst_hmac_md5_init() + { + if (dst_t_func[KEY_HMAC_MD5] != NULL) + return (1); ++#ifdef LIBDHCP ++ dst_t_func[KEY_HMAC_MD5] = dmalloc(sizeof(struct dst_func),__FILE__,__LINE__); ++#else + dst_t_func[KEY_HMAC_MD5] = malloc(sizeof(struct dst_func)); ++#endif + if (dst_t_func[KEY_HMAC_MD5] == NULL) + return (0); + memset(dst_t_func[KEY_HMAC_MD5], 0, sizeof(struct dst_func)); +diff -up dhcp-3.1.0/common/discover.c.libdhcp4client dhcp-3.1.0/common/discover.c +--- dhcp-3.1.0/common/discover.c.libdhcp4client 2006-11-07 18:41:39.000000000 -0500 ++++ dhcp-3.1.0/common/discover.c 2007-10-22 15:58:09.000000000 -0400 +@@ -121,6 +121,10 @@ isc_result_t interface_initialize (omapi + register that interface with the network I/O software, figure out what + subnet it's on, and add it to the list of interfaces. */ + ++#ifdef LIBDHCP ++int have_setup_fallback = 0; ++#endif ++ + void discover_interfaces (state) + int state; + { +@@ -141,7 +145,9 @@ void discover_interfaces (state) + char *s; + #endif + isc_result_t status; ++#ifndef LIBDHCP + static int setup_fallback = 0; ++#endif + int wifcount = 0; + + /* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */ +@@ -695,10 +701,17 @@ void discover_interfaces (state) + log_fatal ("Not configured to listen on any interfaces!"); + } + ++#ifdef LIBDHCP ++ if (!have_setup_fallback) { ++ have_setup_fallback = 1; ++ maybe_setup_fallback (); ++ } ++#else + if (!setup_fallback) { + setup_fallback = 1; + maybe_setup_fallback (); + } ++#endif + + #if defined (HAVE_SETFD) + if (fallback_interface) { +diff -up dhcp-3.1.0/common/tree.c.libdhcp4client dhcp-3.1.0/common/tree.c +--- dhcp-3.1.0/common/tree.c.libdhcp4client 2007-02-14 17:41:22.000000000 -0500 ++++ dhcp-3.1.0/common/tree.c 2007-10-22 15:58:54.000000000 -0400 +@@ -41,7 +41,7 @@ static char copyright[] = + #include + #include + +-struct binding_scope *global_scope; ++struct binding_scope __attribute__ ((visibility ("default"))) *global_scope; + + static int do_host_lookup PROTO ((struct data_string *, + struct dns_host_entry *)); +@@ -2761,6 +2761,7 @@ int evaluate_numeric_expression (result, + result of that evaluation. There should never be both an expression + and a valid data_string. */ + ++__attribute__ ((visibility ("default"))) + int evaluate_option_cache (result, packet, lease, client_state, + in_options, cfg_options, scope, oc, file, line) + struct data_string *result; +diff -up dhcp-3.1.0/common/options.c.libdhcp4client dhcp-3.1.0/common/options.c +--- dhcp-3.1.0/common/options.c.libdhcp4client 2007-05-23 15:26:22.000000000 -0400 ++++ dhcp-3.1.0/common/options.c 2007-10-22 15:58:39.000000000 -0400 +@@ -2501,6 +2501,7 @@ int fqdn_option_space_encapsulate (resul + return 1; + } + ++__attribute__ ((visibility ("default"))) + void option_space_foreach (struct packet *packet, struct lease *lease, + struct client_state *client_state, + struct option_state *in_options, +diff -up dhcp-3.1.0/common/dispatch.c.libdhcp4client dhcp-3.1.0/common/dispatch.c +--- dhcp-3.1.0/common/dispatch.c.libdhcp4client 2007-10-22 15:55:40.000000000 -0400 ++++ dhcp-3.1.0/common/dispatch.c 2007-10-22 15:58:24.000000000 -0400 +@@ -39,8 +39,24 @@ static char copyright[] = + + #include "dhcpd.h" + +-struct timeout *timeouts; +-static struct timeout *free_timeouts; ++struct timeout { ++#ifndef LIBDHCP ++ struct timeout *next; ++#endif ++ TIME when; ++ void (*func) PROTO ((void *)); ++ void *what; ++ tvref_t ref; ++ tvunref_t unref; ++}; ++ ++#ifdef LIBDHCP ++static struct timeout *timeouts = NULL; ++static int ntimeouts = 0; ++#else ++static struct timeout *timeouts = NULL; ++static struct timeout *free_timeouts = NULL; ++#endif + + void set_time(TIME t) + { +@@ -53,9 +69,41 @@ void set_time(TIME t) + + struct timeval *process_outstanding_timeouts (struct timeval *tvp) + { ++#ifdef LIBDHCP ++ int i; ++ struct timeout t = { 0 }; ++#endif + /* Call any expired timeouts, and then if there's + still a timeout registered, time out the select + call then. */ ++#ifdef LIBDHCP ++ if (!ntimeouts) ++ return NULL; ++ ++ for (i = 0; i < ntimeouts && timeouts[i].when <= cur_time;) { ++ struct timeout *new_timeouts; ++ size_t n; ++ ++ memmove(&t, &timeouts[i], sizeof (t)); ++ ++ n = (ntimeouts - i - 1) * sizeof (t); ++ memmove(&timeouts[i+1], &timeouts[i], n); ++ ++ n = --ntimeouts * sizeof (t); ++ new_timeouts = realloc(timeouts, n); ++ /* XXX broken API, no way to return error here */ ++ if (new_timeouts || !n) ++ timeouts = new_timeouts; ++ ++ if (t.func) ++ t.func(t.what); ++ if (t.unref) ++ t.unref(t.what, MDL); ++ } ++ if (tvp && ntimeouts) { ++ tvp->tv_sec = timeouts[0].when; ++ tvp->tv_usec = 0; ++#else + another: + if (timeouts) { + struct timeout *t; +@@ -73,9 +121,15 @@ struct timeval *process_outstanding_time + tvp -> tv_sec = timeouts -> when; + tvp -> tv_usec = 0; + } ++#endif + return tvp; ++#ifdef LIBDHCP ++ } ++ return NULL; ++#else + } else + return (struct timeval *)0; ++#endif + } + + /* Wait for packets to come in using select(). When one does, call +@@ -104,13 +158,28 @@ void add_timeout (when, where, what, ref + tvref_t ref; + tvunref_t unref; + { ++#ifdef LIBDHCP ++ struct timeout t = { ++ .when = when, ++ .func = where, ++ .what = what, ++ .ref = ref, ++ .unref = unref ++ }; ++ struct timeout *new_timeouts; ++ int i, pos = 0; ++#else + struct timeout *t, *q; ++#endif + + /* See if this timeout supersedes an existing timeout. */ ++#ifdef LIBDHCP ++ for (i = 0; i < ntimeouts; i++) { ++ struct timeout *q = &timeouts[i]; ++#else + t = (struct timeout *)0; + for (q = timeouts; q; q = q -> next) { +- if ((where == NULL || q -> func == where) && +- q -> what == what) { ++ if ((where == NULL || q -> func == where) && q -> what == what) { + if (t) + t -> next = q -> next; + else +@@ -119,7 +188,29 @@ void add_timeout (when, where, what, ref + } + t = q; + } ++#endif + ++#ifdef LIBDHCP ++ /* If this one is already in the list with a different time, ++ * remove it and re-add */ ++ if ((where == NULL || q->func == where) && ++ q->what == what) { ++ size_t n = (--ntimeouts - i) * sizeof (*q); ++ memmove(&t, q, sizeof (t)); ++ ++ if (n) ++ memmove(&timeouts[i], &timeouts[i+1], n); ++ ++ if (ntimeouts) { ++ new_timeouts = realloc(timeouts, ntimeouts * sizeof (*q)); ++ /* XXX broken API, no way to return error here */ ++ if (new_timeouts) ++ timeouts = new_timeouts; ++ } else { ++ timeouts = NULL; ++ } ++ add_timeout(when, where, what, ref, unref); ++#else + /* If we didn't supersede a timeout, allocate a timeout + structure now. */ + if (!q) { +@@ -128,7 +219,7 @@ void add_timeout (when, where, what, ref + free_timeouts = q -> next; + } else { + q = ((struct timeout *) +- dmalloc (sizeof (struct timeout), MDL)); ++ dmalloc (sizeof (struct timeout), MDL)); + if (!q) + log_fatal ("add_timeout: no memory!"); + } +@@ -158,22 +249,76 @@ void add_timeout (when, where, what, ref + if (t -> next -> when > q -> when) { + q -> next = t -> next; + t -> next = q; ++#endif + return; ++#ifdef LIBDHCP ++ } else if (timeouts[i].when > when) { ++ pos = i; ++#endif + } + } + ++#ifdef LIBDHCP ++ /* If we didn't supersede an existing timeout, then pos is set ++ * to the timeout which will post after this one. Insert this ++ * one before it. */ ++ ++ new_timeouts = realloc(timeouts, sizeof (t) * (ntimeouts+1)); ++ /* XXX broken API, no way to return error here */ ++ if (new_timeouts) { ++ /* ntimeouts = 10 ++ * pos = 3; ++ * n = 10-3 * sizeof (t) = 7 * sizeof (t) ++ */ ++ size_t n = (ntimeouts - pos) * sizeof (t); ++ ++ timeouts = new_timeouts; ++ memmove(&timeouts[pos+1], &timeouts[pos], n); ++ memmove(&timeouts[pos], &t, sizeof (t)); ++ ntimeouts++; ++ } ++#else + /* End of list. */ + t -> next = q; + q -> next = (struct timeout *)0; ++#endif + } + + void cancel_timeout (where, what) + void (*where) PROTO ((void *)); + void *what; + { ++#ifdef LIBDHCP ++ struct timeout t; ++ int i = 0; ++#else + struct timeout *t, *q; ++#endif + + /* Look for this timeout on the list, and unlink it if we find it. */ ++#ifdef LIBDHCP ++ for (i = 0; i < ntimeouts; i++) { ++ struct timeout *new_timeouts, *q = &timeouts[i]; ++ ++ if (q->func == where && q->what == what) { ++ size_t n; ++ ++ memmove(&t, q, sizeof (t)); ++ ++ n = (ntimeouts - i - 1) * sizeof (t); ++ memmove(&timeouts[i+1], &timeouts[i], n); ++ ++ n = --ntimeouts * sizeof (t); ++ new_timeouts = realloc(timeouts, n); ++ /* XXX broken API, no way to return error here */ ++ if (new_timeouts || !n) ++ timeouts = new_timeouts; ++ ++ if (t.unref) ++ t.unref(t.what, MDL); ++ } ++ } ++#else + t = (struct timeout *)0; + for (q = timeouts; q; q = q -> next) { + if (q -> func == where && q -> what == what) { +@@ -193,10 +338,15 @@ void cancel_timeout (where, what) + q -> next = free_timeouts; + free_timeouts = q; + } ++#endif + } + + void cancel_all_timeouts () + { ++#ifdef LIBDHCP ++ cur_time = TIME_MAX; ++ process_outstanding_timeouts(NULL); ++#else + struct timeout *t, *n; + for (t = timeouts; t; t = n) { + n = t -> next; +@@ -205,13 +355,20 @@ void cancel_all_timeouts () + t -> next = free_timeouts; + free_timeouts = t; + } ++#endif + } + ++__attribute__ ((visibility ("default"))) + void relinquish_timeouts () + { ++#ifdef LIBDHCP ++ while (ntimeouts) ++ cancel_timeout(timeouts[0].func, timeouts[0].what); ++#else + struct timeout *t, *n; + for (t = free_timeouts; t; t = n) { + n = t -> next; + dfree (t, MDL); + } ++#endif + } +diff -up dhcp-3.1.0/common/alloc.c.libdhcp4client dhcp-3.1.0/common/alloc.c +--- dhcp-3.1.0/common/alloc.c.libdhcp4client 2006-06-01 16:23:17.000000000 -0400 ++++ dhcp-3.1.0/common/alloc.c 2007-10-22 15:57:53.000000000 -0400 +@@ -1013,7 +1013,11 @@ int executable_statement_reference (ptr, + return 1; + } + ++#ifdef LIBDHCP ++struct packet *free_packets; ++#else + static struct packet *free_packets; ++#endif + + #if defined (DEBUG_MEMORY_LEAKAGE) || \ + defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) +diff -up dhcp-3.1.0/includes/dhcpd.h.libdhcp4client dhcp-3.1.0/includes/dhcpd.h +--- dhcp-3.1.0/includes/dhcpd.h.libdhcp4client 2007-10-22 15:55:40.000000000 -0400 ++++ dhcp-3.1.0/includes/dhcpd.h 2007-10-22 15:59:51.000000000 -0400 +@@ -1000,14 +1000,6 @@ struct hardware_link { + + typedef void (*tvref_t)(void *, void *, const char *, int); + typedef void (*tvunref_t)(void *, const char *, int); +-struct timeout { +- struct timeout *next; +- TIME when; +- void (*func) PROTO ((void *)); +- void *what; +- tvref_t ref; +- tvunref_t unref; +-}; + + struct protocol { + struct protocol *next; +@@ -1960,7 +1952,6 @@ extern void (*bootp_packet_handler) PROT + struct dhcp_packet *, unsigned, + unsigned int, + struct iaddr, struct hardware *)); +-extern struct timeout *timeouts; + extern omapi_object_type_t *dhcp_type_interface; + #if defined (TRACING) + trace_type_t *interface_trace; +diff -up dhcp-3.1.0/client/dhclient.c.libdhcp4client dhcp-3.1.0/client/dhclient.c +--- dhcp-3.1.0/client/dhclient.c.libdhcp4client 2007-10-22 15:55:40.000000000 -0400 ++++ dhcp-3.1.0/client/dhclient.c 2007-10-22 16:08:09.000000000 -0400 +@@ -82,14 +82,50 @@ int quiet=0; + int nowait=0; + int bootp_broadcast_always = 0; + ++#ifdef LIBDHCP ++FILE *leaseFile = NULL; ++#endif ++ + extern u_int32_t default_requested_options[]; + + static void usage PROTO ((void)); + ++#ifdef LIBDHCP ++#include "libdhcp_control.h" ++LIBDHCP_Control *libdhcp_control; ++static void libdhcp_dispatch(void) ++{ ++ struct timeval tv = { 0, 0 }, *tvp; ++ isc_result_t status; ++ ++ /* Wait for a packet, or a timeout, or libdhcp being finished */ ++ do { ++ tvp = process_outstanding_timeouts(&tv); ++ status = omapi_one_dispatch(0, tvp); ++ ++ if (libdhcp_control && ((status == ISC_R_TIMEDOUT) || (libdhcp_control->timeout && (time(NULL) >= (libdhcp_control->timeout + libdhcp_control->now))))) { ++ if (libdhcp_control->callback) ++ libdhcp_control->callback(libdhcp_control, DHC_TIMEDOUT, NULL); ++ ++ break; ++ } ++ } while ((status != ISC_R_TIMEDOUT) && ((!libdhcp_control) || (!(libdhcp_control->finished)))); ++} ++ ++extern void omapi_free_all_pointers(void); ++ ++__attribute__ ((visibility ("default"))) ++int dhcpv4_client (libdhcp_ctl, argc, argv, envp) ++ LIBDHCP_Control *libdhcp_ctl; ++#else + int main (argc, argv, envp) ++#endif + int argc; + char **argv, **envp; + { ++#ifdef LIBDHCP ++ libdhcp_control = libdhcp_ctl; ++#endif + int fd; + int i; + struct servent *ent; +@@ -120,6 +156,7 @@ int main (argc, argv, envp) + char *arg_conf = NULL; + int arg_conf_len = 0; + ++#ifndef LIBDHCP + /* Make sure that file descriptors 0 (stdin), 1, (stdout), and + 2 (stderr) are open. To do this, we assume that when we + open a file the lowest available file decriptor is used. */ +@@ -143,6 +180,7 @@ int main (argc, argv, envp) + #if !(defined (DEBUG) || defined (SYSLOG_4_2) || defined (__CYGWIN32__)) + setlogmask (LOG_UPTO (LOG_INFO)); + #endif ++#endif + + /* Set up the OMAPI. */ + status = omapi_init (); +@@ -439,8 +477,12 @@ int main (argc, argv, envp) + } + } + ++#ifdef LIBDHCP ++ if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_PID_FILE)) ++#endif + write_client_pid_file(); + ++#ifndef LIBDHCP + if (!quiet) { + log_info ("%s %s", message, DHCP_VERSION); + log_info (copyright); +@@ -449,6 +491,7 @@ int main (argc, argv, envp) + log_info ("%s", ""); + } else + log_perror = 0; ++#endif + + /* If we're given a relay agent address to insert, for testing + purposes, figure out what it is. */ +@@ -680,11 +723,17 @@ int main (argc, argv, envp) + arg_conf_len = 0; + } + ++#ifdef LIBDHCP ++ if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_LEASE_DATABASE)) { ++#endif + /* Parse the lease database. */ + read_client_leases (); + + /* Rewrite the lease database... */ + rewrite_client_leases (); ++#ifdef LIBDHCP ++ } ++#endif + + /* XXX */ + /* config_counter(&snd_counter, &rcv_counter); */ +@@ -703,7 +752,7 @@ int main (argc, argv, envp) + if (!persist) { + /* Nothing more to do. */ + log_info ("No broadcast interfaces found - exiting."); +- exit (0); ++ return (0); + } + } else if (!release_mode && !exit_mode) { + /* Call the script with the list of interfaces. */ +@@ -799,6 +848,7 @@ int main (argc, argv, envp) + dmalloc_outstanding = 0; + #endif + ++#ifndef LIBDHCP + /* If we're not supposed to wait before getting the address, + don't. */ + if (nowait) +@@ -811,6 +861,126 @@ int main (argc, argv, envp) + + /* Start dispatching packets and timeouts... */ + dispatch (); ++#else ++ if (libdhcp_control) { ++ if (libdhcp_control->timeout) ++ libdhcp_control->now = time(NULL); ++ else ++ libdhcp_control->now = 0; ++ } ++ ++ libdhcp_dispatch(); ++ ++ /* libdhcp is finished with us. */ ++ ++ /* close all file descriptors: */ ++ for (ip = interfaces; ip; ip = ip->next) { ++ shutdown(ip->wfdesc, SHUT_RDWR); ++ close(ip->wfdesc); ++ ++ if (ip->rfdesc != ip->wfdesc) ++ close(ip->rfdesc); ++ } ++ ++ if (fallback_interface != 0) { ++ ip = fallback_interface; ++ shutdown(ip->wfdesc, SHUT_RDWR); ++ close(ip->wfdesc); ++ ++ if (ip->rfdesc != ip->wfdesc) ++ close(ip->rfdesc); ++ } ++ ++ if (leaseFile) ++ fclose (leaseFile); ++ ++ closelog(); ++ ++ char *current_pid_file = _PATH_DHCLIENT_PID; ++ ++ /* Free ALL allocated memory: */ ++ omapi_free_all_pointers(); ++ ++ /* Re-Initialize globals: */ ++ client_env = 0; ++ client_env_count = 0; ++ default_lease_time = 43200; ++ ++ dhcp_max_agent_option_packet_length = 0; ++ iaddr_any.len = 4; ++ memset(&(iaddr_any.iabuf[0]), '\0', 4); ++ iaddr_broadcast.len = 4; ++ memset(&(iaddr_broadcast.iabuf[0]), 0xff, 4); ++ interfaces_requested = 0; ++ leaseFile = 0; ++ ++ libdhcp_control = 0; ++ ++ local_port = 0; ++ no_daemon = 0; ++ nowait = 0; ++ onetry = 0; ++ quiet = 0; ++ max_lease_time = 86400; ++ path_dhclient_conf = _PATH_DHCLIENT_CONF; ++ path_dhclient_db = _PATH_DHCLIENT_DB; ++ path_dhclient_pid = _PATH_DHCLIENT_PID; ++ strcpy(&(path_dhclient_script_array[0]), _PATH_DHCLIENT_SCRIPT); ++ path_dhclient_script = path_dhclient_script_array; ++ remote_port = 0; ++ resolver_inited = 0; ++ log_perror = 1; ++ global_scope = NULL; ++ root_group = NULL; ++ group_name_hash = NULL; ++ interfaces = NULL; ++ dummy_interfaces = NULL; ++ fallback_interface = NULL; ++ extern int have_setup_fallback; ++ have_setup_fallback = 0; ++ quiet_interface_discovery = 1; ++#ifndef LIBDHCP ++ timeouts = NULL; ++#endif ++ dhcp_type_interface = NULL; ++ interface_vector = NULL; ++ interface_count = 0; ++ interface_max = 0; ++ name_servers = 0; ++ domains = 0; ++ dhcp_type_interface = NULL; ++ dhcp_type_group = NULL; ++ dhcp_type_shared_network = NULL; ++ dhcp_type_control = NULL; ++ memset(&dhcp_universe, '\0', sizeof(struct universe)); ++ memset(&nwip_universe, '\0', sizeof(struct universe)); ++ memset(&fqdn_universe, '\0', sizeof(struct universe)); ++ universe_hash = 0; ++ universes = 0; ++ universe_count = 0; ++ universe_max = 0; ++ config_universe = 0; ++ extern struct hash_bucket *free_hash_buckets; ++ free_hash_buckets = NULL; ++ extern struct dhcp_packet *dhcp_free_list; ++ dhcp_free_list = NULL; ++ extern struct packet *packet_free_list; ++ packet_free_list = NULL; ++ extern struct binding_value *free_binding_values; ++ free_binding_values = NULL; ++ extern struct expression *free_expressions; ++ free_expressions = NULL; ++ extern struct option_cache *free_option_caches; ++ free_option_caches = NULL; ++ extern struct packet *free_packets; ++ free_packets = NULL; ++ extern pair free_pairs; ++ free_pairs = NULL; ++ extern omapi_io_object_t omapi_io_states; ++ memset(&omapi_io_states, '\0', sizeof(omapi_io_states)); ++ dhcp_control_object = NULL; ++ unlink(current_pid_file); ++#endif + + /*NOTREACHED*/ + return 0; +@@ -1203,7 +1373,20 @@ void dhcpack (packet) + if (client -> new -> rebind < cur_time) + client -> new -> rebind = TIME_MAX; + ++#ifdef LIBDHCP ++ /* We need the server's siaddr for the 'bootServer' ++ * pump option ++ */ ++ u_int32_t set_siaddr = 0; ++ set_siaddr = client->packet.siaddr.s_addr; ++ client->packet.siaddr.s_addr = packet->raw->siaddr.s_addr; ++#endif ++ + bind_lease (client); ++ ++#ifdef LIBDHCP ++ client->packet.siaddr.s_addr = set_siaddr; ++#endif + } + + void bind_lease (client) +@@ -1241,6 +1424,9 @@ void bind_lease (client) + return; + } + ++#ifdef LIBDHCP ++ if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_LEASE_DATABASE)) ++#endif + /* Write out the new lease. */ + write_client_lease (client, client -> new, 0, 0); + +@@ -1343,11 +1529,13 @@ int commit_leases () + return 0; + } + ++#ifndef LIBDHCP + int write_lease (lease) + struct lease *lease; + { + return 0; + } ++#endif + + int write_host (host) + struct host_decl *host; +@@ -1957,6 +2145,10 @@ void state_panic (cpp) + tell the shell script that we failed to allocate an address, + and try again later. */ + if (onetry) { ++#ifdef LIBDHCP ++ script_init (client, "FAIL", (struct string_list *)0); ++ return; ++#endif + if (!quiet) + log_info ("Unable to obtain a lease on first try.%s", + " Exiting."); +@@ -2579,7 +2771,9 @@ void destroy_client_lease (lease) + free_client_lease (lease, MDL); + } + ++#ifndef LIBDHCP + FILE *leaseFile; ++#endif + + void rewrite_client_leases () + { +@@ -2960,6 +3154,54 @@ void script_write_params (client, prefix + int script_go (client) + struct client_state *client; + { ++#ifdef LIBDHCP ++ struct string_list *sp; ++ ++ if (libdhcp_control && libdhcp_control->callback) { ++ int dhcmsg; ++ char *reason=""; ++ ++ for (sp = client->env; sp; sp = sp->next) ++ if (strncmp(sp->string, "reason=", 7) == 0) { ++ reason = sp->string + 7; ++ break; ++ } ++ ++ if (strcmp(reason,"NBI") == 0) ++ dhcmsg = DHC4_NBI; ++ else if (strcmp(reason,"PREINIT") == 0) ++ dhcmsg = DHC4_PREINIT; ++ else if (strcmp(reason,"BOUND") == 0) ++ dhcmsg = DHC4_BOUND; ++ else if (strcmp(reason,"RENEW") == 0) ++ dhcmsg = DHC4_RENEW; ++ else if (strcmp(reason,"REBOOT") == 0) ++ dhcmsg = DHC4_REBOOT; ++ else if (strcmp(reason,"REBIND") == 0) ++ dhcmsg = DHC4_REBIND; ++ else if (strcmp(reason,"STOP") == 0) ++ dhcmsg = DHC4_STOP; ++ else if (strcmp(reason,"MEDIUM") == 0) ++ dhcmsg = DHC4_MEDIUM; ++ else if (strcmp(reason,"TIMEOUT") == 0) ++ dhcmsg = DHC4_TIMEOUT; ++ else if (strcmp(reason,"FAIL") == 0) ++ dhcmsg = DHC4_FAIL; ++ else if (strcmp(reason,"EXPIRE") == 0) ++ dhcmsg = DHC4_EXPIRE; ++ else if (strcmp(reason,"RELEASE") == 0) ++ dhcmsg = DHC4_RELEASE; ++ else ++ dhcmsg = DHC4_NBI; ++ ++ (*libdhcp_control->callback) (libdhcp_control, dhcmsg, client); ++ ++ if (libdhcp_control->decline) ++ return 1; ++ } ++ ++ return 0; ++#else + int rval; + char *scriptName; + char *argv [2]; +@@ -3038,6 +3280,7 @@ int script_go (client) + GET_TIME (&cur_time); + return (WIFEXITED (wstatus) ? + WEXITSTATUS (wstatus) : -WTERMSIG (wstatus)); ++#endif + } + + void client_envadd (struct client_state *client, +@@ -3120,6 +3363,9 @@ void go_daemon () + + /* Don't become a daemon if the user requested otherwise. */ + if (no_daemon) { ++#ifdef LIBDHCP ++ if (libdhcp_control && (libdhcp_control->capability & DHCP_USE_PID_FILE )) ++#endif + write_client_pid_file (); + return; + } +@@ -3129,6 +3375,10 @@ void go_daemon () + return; + state = 1; + ++#ifdef LIBDHCP ++ return; ++#endif ++ + /* Stop logging to stderr... */ + log_perror = 0; + +diff -up dhcp-3.1.0/Makefile.dist.libdhcp4client dhcp-3.1.0/Makefile.dist +--- dhcp-3.1.0/Makefile.dist.libdhcp4client 2005-03-17 15:14:54.000000000 -0500 ++++ dhcp-3.1.0/Makefile.dist 2007-10-22 15:57:26.000000000 -0400 +@@ -22,7 +22,7 @@ + # http://www.isc.org/ + + +-SUBDIRS= common $(MINIRES) dst omapip server client relay dhcpctl ++SUBDIRS= common $(MINIRES) dst omapip server client relay dhcpctl libdhcp4client + + all: + @for dir in ${SUBDIRS}; do \ diff --git a/dhcp-3.1.0-options.patch b/dhcp-3.1.0-options.patch new file mode 100644 index 0000000..0871328 --- /dev/null +++ b/dhcp-3.1.0-options.patch @@ -0,0 +1,402 @@ +diff -up dhcp-3.1.0/common/conflex.c.options dhcp-3.1.0/common/conflex.c +--- dhcp-3.1.0/common/conflex.c.options 2007-10-22 15:46:24.000000000 -0400 ++++ dhcp-3.1.0/common/conflex.c 2007-10-22 15:48:07.000000000 -0400 +@@ -599,6 +599,8 @@ static enum dhcp_token intern (atom, dfv + return BALANCE; + if (!strcasecmp (atom + 1, "ound")) + return BOUND; ++ if (!strcasecmp (atom + 1, "ootp-broadcast-always")) ++ return BOOTP_BROADCAST_ALWAYS; + break; + case 'c': + if (!strcasecmp (atom + 1, "ase")) +diff -up dhcp-3.1.0/includes/dhcpd.h.options dhcp-3.1.0/includes/dhcpd.h +--- dhcp-3.1.0/includes/dhcpd.h.options 2007-10-22 15:46:24.000000000 -0400 ++++ dhcp-3.1.0/includes/dhcpd.h 2007-10-22 15:48:21.000000000 -0400 +@@ -912,6 +912,9 @@ struct client_config { + int do_forward_update; /* If nonzero, and if we have the + information we need, update the + A record for the address we get. */ ++ ++ int bootp_broadcast_always; /* If nonzero, always set the BOOTP_BROADCAST ++ flag in requests */ + }; + + /* Per-interface state used in the dhcp client... */ +diff -up dhcp-3.1.0/includes/dhctoken.h.options dhcp-3.1.0/includes/dhctoken.h +--- dhcp-3.1.0/includes/dhctoken.h.options 2006-07-31 18:19:51.000000000 -0400 ++++ dhcp-3.1.0/includes/dhctoken.h 2007-10-22 15:49:24.000000000 -0400 +@@ -325,7 +325,8 @@ enum dhcp_token { + MIN_BALANCE = 629, + DOMAIN_LIST = 630, + LEASEQUERY = 631, +- EXECUTE = 632 ++ EXECUTE = 632, ++ BOOTP_BROADCAST_ALWAYS = 633 + }; + + #define is_identifier(x) ((x) >= FIRST_TOKEN && \ +diff -up dhcp-3.1.0/client/dhclient.c.options dhcp-3.1.0/client/dhclient.c +--- dhcp-3.1.0/client/dhclient.c.options 2007-05-22 16:37:04.000000000 -0400 ++++ dhcp-3.1.0/client/dhclient.c 2007-10-22 15:47:51.000000000 -0400 +@@ -38,6 +38,12 @@ static char ocopyright[] = + #include "dhcpd.h" + #include "version.h" + ++/* ++ * Defined in stdio.h when _GNU_SOURCE is set, but we don't want to define ++ * that when building ISC code. ++ */ ++extern int asprintf(char **strp, const char *fmt, ...); ++ + TIME default_lease_time = 43200; /* 12 hours... */ + TIME max_lease_time = 86400; /* 24 hours... */ + +@@ -74,6 +80,9 @@ int client_env_count=0; + int onetry=0; + int quiet=0; + int nowait=0; ++int bootp_broadcast_always = 0; ++ ++extern u_int32_t default_requested_options[]; + + static void usage PROTO ((void)); + +@@ -101,6 +110,15 @@ int main (argc, argv, envp) + int no_dhclient_pid = 0; + int no_dhclient_script = 0; + char *s; ++ char *dhcp_client_identifier_arg = NULL; ++ char *dhcp_host_name_arg = NULL; ++ char *dhcp_fqdn_arg = NULL; ++ char *dhcp_vendor_class_identifier_arg = NULL; ++ char *dhclient_request_options = NULL; ++ ++ int timeout_arg = 0; ++ char *arg_conf = NULL; ++ int arg_conf_len = 0; + + /* Make sure that file descriptors 0 (stdin), 1, (stdout), and + 2 (stderr) are open. To do this, we assume that when we +@@ -211,6 +229,88 @@ int main (argc, argv, envp) + } else if (!strcmp (argv [i], "--version")) { + log_info ("isc-dhclient-%s", DHCP_VERSION); + exit (0); ++ } else if (!strcmp (argv [i], "-I")) { ++ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { ++ usage (); ++ return EXIT_FAILURE; ++ } ++ ++ if (strlen(argv[i]) >= DHCP_OPTION_LEN) { ++ log_error("-I option dhcp-client-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1); ++ exit(1); ++ } ++ ++ dhcp_client_identifier_arg = argv[i]; ++ } else if (!strcmp (argv [i], "-B")) { ++ bootp_broadcast_always = 1; ++ } else if (!strcmp (argv [i], "-H")) { ++ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { ++ usage (); ++ return EXIT_FAILURE; ++ } ++ ++ if (strlen(argv[i]) >= DHCP_OPTION_LEN) { ++ log_error("-H option host-name string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1); ++ exit(1); ++ } ++ ++ if (dhcp_host_name_arg != NULL) { ++ log_error("The -H and -F arguments are mutually exclusive"); ++ exit(1); ++ } ++ ++ dhcp_host_name_arg = argv[i]; ++ } else if (!strcmp (argv [i], "-F")) { ++ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { ++ usage (); ++ return EXIT_FAILURE; ++ } ++ ++ if (strlen(argv[i]) >= DHCP_OPTION_LEN) { ++ log_error("-F option fqdn.fqdn string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1); ++ exit(1); ++ } ++ ++ if (dhcp_fqdn_arg != NULL) { ++ log_error("Only one -F argument can be specified"); ++ exit(1); ++ } ++ ++ if (dhcp_host_name_arg != NULL) { ++ log_error("The -F and -H arguments are mutually exclusive"); ++ exit(1); ++ } ++ ++ dhcp_fqdn_arg = argv[i]; ++ } else if (!strcmp (argv [i], "-T")) { ++ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { ++ usage (); ++ return EXIT_FAILURE; ++ } ++ ++ if ((timeout_arg = atoi(argv[i])) <= 0) { ++ log_error("-T timeout option must be > 0 - bad value: %s",argv[i]); ++ exit(1); ++ } ++ } else if (!strcmp (argv [i], "-V")) { ++ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { ++ usage (); ++ return EXIT_FAILURE; ++ } ++ ++ if (strlen(argv[i]) >= DHCP_OPTION_LEN) { ++ log_error("-V option vendor-class-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1); ++ exit(1); ++ } ++ ++ dhcp_vendor_class_identifier_arg = argv[i]; ++ } else if (!strcmp (argv [i], "-R")) { ++ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { ++ usage (); ++ return EXIT_FAILURE; ++ } ++ ++ dhclient_request_options=argv[i]; + } else if (argv [i][0] == '-') { + usage (); + } else { +@@ -347,6 +447,167 @@ int main (argc, argv, envp) + /* Parse the dhclient.conf file. */ + read_client_conf (); + ++ /* Parse any extra command line configuration arguments: */ ++ if ((dhcp_client_identifier_arg != NULL) && (*dhcp_client_identifier_arg != '\0')) { ++ arg_conf_len = asprintf(&arg_conf, "send dhcp-client-identifier \"%s\";", dhcp_client_identifier_arg); ++ ++ if ((arg_conf == 0) || (arg_conf_len <= 0)) ++ log_fatal("Unable to send -I option dhcp-client-identifier"); ++ } ++ ++ if ((dhcp_host_name_arg != NULL) && (*dhcp_host_name_arg != '\0')) { ++ if (arg_conf == 0) { ++ arg_conf_len = asprintf(&arg_conf, "send host-name \"%s\";", dhcp_host_name_arg); ++ ++ if ((arg_conf == 0) || (arg_conf_len <= 0)) ++ log_fatal("Unable to send -H option host-name"); ++ } else { ++ char *last_arg_conf = arg_conf; ++ arg_conf = NULL; ++ arg_conf_len = asprintf( &arg_conf, "%s\nsend host-name \"%s\";", last_arg_conf, dhcp_host_name_arg); ++ ++ if ((arg_conf == 0) || (arg_conf_len <= 0)) ++ log_fatal("Unable to send -H option host-name"); ++ ++ free(last_arg_conf); ++ } ++ } ++ ++ if ((dhcp_fqdn_arg != NULL) && (*dhcp_fqdn_arg != '\0')) { ++ if (arg_conf == 0) { ++ arg_conf_len = asprintf(&arg_conf, "send fqdn.fqdn \"%s\";", dhcp_fqdn_arg); ++ ++ if ((arg_conf == 0) || (arg_conf_len <= 0)) ++ log_fatal("Unable to send -F option fqdn.fqdn"); ++ } else { ++ char *last_arg_conf = arg_conf; ++ arg_conf = NULL; ++ arg_conf_len = asprintf( &arg_conf, "%s\nsend fqdn.fqdn \"%s\";", last_arg_conf, dhcp_fqdn_arg); ++ ++ if ((arg_conf == 0) || (arg_conf_len <= 0)) ++ log_fatal("Unable to send -F option fqdn.fqdn"); ++ ++ free(last_arg_conf); ++ } ++ } ++ ++ if (timeout_arg) { ++ if (arg_conf == 0) { ++ arg_conf_len = asprintf(&arg_conf, "timeout %d;", timeout_arg); ++ ++ if ((arg_conf == 0) || (arg_conf_len <= 0)) ++ log_fatal("Unable to process -T timeout argument"); ++ } else { ++ char *last_arg_conf = arg_conf; ++ arg_conf = NULL; ++ arg_conf_len = asprintf( &arg_conf, "%s\ntimeout %d;", last_arg_conf, timeout_arg); ++ ++ if ((arg_conf == 0) || (arg_conf_len == 0)) ++ log_fatal("Unable to process -T timeout argument"); ++ ++ free(last_arg_conf); ++ } ++ } ++ ++ if ((dhcp_vendor_class_identifier_arg != NULL) && (*dhcp_vendor_class_identifier_arg != '\0')) { ++ if (arg_conf == 0) { ++ arg_conf_len = asprintf(&arg_conf, "send vendor-class-identifier \"%s\";", dhcp_vendor_class_identifier_arg); ++ ++ if ((arg_conf == 0) || (arg_conf_len <= 0)) ++ log_fatal("Unable to send -V option vendor-class-identifier"); ++ } else { ++ char *last_arg_conf = arg_conf; ++ arg_conf = NULL; ++ arg_conf_len = asprintf(&arg_conf, "%s\nsend vendor-class-identifier \"%s\";", last_arg_conf, dhcp_vendor_class_identifier_arg); ++ ++ if ((arg_conf == 0) || (arg_conf_len <= 0)) ++ log_fatal("Unable to send -V option vendor-class-identifier"); ++ ++ free(last_arg_conf); ++ } ++ } ++ ++ if (dhclient_request_options != NULL) { ++ if (arg_conf == 0) { ++ arg_conf_len = asprintf(&arg_conf, "request %s;", dhclient_request_options); ++ ++ if ((arg_conf == 0) || (arg_conf_len <= 0)) ++ log_fatal("Unable to parse -R argument"); ++ } else { ++ char *last_arg_conf = arg_conf; ++ arg_conf = NULL; ++ arg_conf_len = asprintf(&arg_conf, "%s\nrequest %s;", last_arg_conf, dhclient_request_options); ++ ++ if ((arg_conf == 0) || (arg_conf_len <= 0)) ++ log_fatal("Unable to parse -R argument"); ++ ++ free(last_arg_conf); ++ } ++ } ++ ++ if (arg_conf) { ++ if (arg_conf_len == 0) ++ if ((arg_conf_len = strlen(arg_conf)) == 0) ++ /* huh ? cannot happen ! */ ++ log_fatal("Unable to process -I/-H/-F/-T/-V/-R configuration arguments"); ++ ++ /* parse the extra dhclient.conf configuration arguments ++ * into top level config: */ ++ struct parse *cfile = (struct parse *)0; ++ const char *val = NULL; ++ int token; ++ ++ status = new_parse (&cfile, -1, arg_conf, arg_conf_len, "extra dhclient -I/-H/-F/-T/-V/-R configuration arguments", 0); ++ ++ if ((status != ISC_R_SUCCESS) || (cfile -> warnings_occurred)) ++ log_fatal("Cannot parse -I/-H/-F/-T/-V/-R configuration arguments !"); ++ /* more detailed parse failures will be logged */ ++ ++ do { ++ token = peek_token (&val, (unsigned *)0, cfile); ++ if (token == END_OF_FILE) ++ break; ++ ++ parse_client_statement (cfile, (struct interface_info *)0, &top_level_config); ++ } while (1); ++ ++ if (cfile -> warnings_occurred) ++ log_fatal ("Cannot parse -I/-H/-F/-T/-V/-R configuration arguments !"); ++ end_parse (&cfile); ++ ++ if (timeout_arg) { ++ /* we just set the toplevel timeout, but per-client ++ * timeouts may still be at defaults. Also, it makes no ++ * sense having the reboot_timeout or backoff_cutoff ++ * greater than the timeout: ++ */ ++ if ((top_level_config.backoff_cutoff == 15) && (top_level_config.backoff_cutoff > (timeout_arg / 2))) ++ top_level_config.backoff_cutoff = (((unsigned long)(timeout_arg / 2)) == 0) ? timeout_arg : (unsigned long)(timeout_arg / 2); ++ ++ for (ip = interfaces; ip; ip = ip -> next) { ++ if (ip->client->config->timeout == 60) ++ ip->client->config->timeout = timeout_arg; ++ ++ if ((ip->client->config->reboot_timeout == 10) && (ip->client->config->reboot_timeout > ip->client->config->timeout)) ++ ip->client->config->reboot_timeout = ip->client->config->timeout; ++ ++ if ((ip->client->config->backoff_cutoff == 15) && (ip->client->config->backoff_cutoff > top_level_config.backoff_cutoff)) ++ ip->client->config->backoff_cutoff = top_level_config.backoff_cutoff; ++ } ++ } ++ ++ if ((dhclient_request_options != 0) && (top_level_config.requested_options != default_requested_options)) { ++ for (ip = interfaces; ip; ip = ip -> next) { ++ if (ip->client->config->requested_options == default_requested_options) ++ ip->client->config->requested_options = top_level_config.requested_options; ++ } ++ } ++ ++ free(arg_conf); ++ arg_conf = NULL; ++ arg_conf_len = 0; ++ } ++ + /* Parse the lease database. */ + read_client_leases (); + +@@ -1978,7 +2239,8 @@ void make_discover (client, lease) + client -> packet.xid = random (); + client -> packet.secs = 0; /* filled in by send_discover. */ + +- if (can_receive_unicast_unconfigured (client -> interface)) ++ if ((!(bootp_broadcast_always || client->config->bootp_broadcast_always)) ++ && can_receive_unicast_unconfigured(client->interface)) + client -> packet.flags = 0; + else + client -> packet.flags = htons (BOOTP_BROADCAST); +@@ -2065,7 +2327,9 @@ void make_request (client, lease) + } else { + memset (&client -> packet.ciaddr, 0, + sizeof client -> packet.ciaddr); +- if (can_receive_unicast_unconfigured (client -> interface)) ++ if ((!(bootp_broadcast_always || ++ client ->config->bootp_broadcast_always)) && ++ can_receive_unicast_unconfigured (client -> interface)) + client -> packet.flags = 0; + else + client -> packet.flags = htons (BOOTP_BROADCAST); +@@ -2125,7 +2389,8 @@ void make_decline (client, lease) + client -> packet.hops = 0; + client -> packet.xid = client -> xid; + client -> packet.secs = 0; /* Filled in by send_request. */ +- if (can_receive_unicast_unconfigured (client -> interface)) ++ if ((!(bootp_broadcast_always || client->config-> bootp_broadcast_always)) ++ && can_receive_unicast_unconfigured (client->interface)) + client -> packet.flags = 0; + else + client -> packet.flags = htons (BOOTP_BROADCAST); +diff -up dhcp-3.1.0/client/clparse.c.options dhcp-3.1.0/client/clparse.c +--- dhcp-3.1.0/client/clparse.c.options 2007-02-14 17:41:22.000000000 -0500 ++++ dhcp-3.1.0/client/clparse.c 2007-10-22 15:47:12.000000000 -0400 +@@ -84,6 +84,7 @@ isc_result_t read_client_conf () + top_level_config.requested_options = default_requested_options; + top_level_config.omapi_port = -1; + top_level_config.do_forward_update = 1; ++ top_level_config.bootp_broadcast_always = 0; + + group_allocate (&top_level_config.on_receipt, MDL); + if (!top_level_config.on_receipt) +@@ -230,7 +231,8 @@ void read_client_leases () + interface-declaration | + LEASE client-lease-statement | + ALIAS client-lease-statement | +- KEY key-definition */ ++ KEY key-definition | ++ BOOTP_BROADCAST_ALWAYS */ + + void parse_client_statement (cfile, ip, config) + struct parse *cfile; +@@ -554,6 +556,12 @@ void parse_client_statement (cfile, ip, + parse_reject_statement (cfile, config); + return; + ++ case BOOTP_BROADCAST_ALWAYS: ++ token = next_token(&val, (unsigned*)0, cfile); ++ config -> bootp_broadcast_always = 1; ++ parse_semi (cfile); ++ return; ++ + default: + lose = 0; + stmt = (struct executable_statement *)0; diff --git a/dhcp-3.1.0-warnings.patch b/dhcp-3.1.0-warnings.patch index 2c1a235..13b6f7f 100644 --- a/dhcp-3.1.0-warnings.patch +++ b/dhcp-3.1.0-warnings.patch @@ -1,6 +1,6 @@ diff -up dhcp-3.1.0/relay/dhcrelay.c.warnings dhcp-3.1.0/relay/dhcrelay.c --- dhcp-3.1.0/relay/dhcrelay.c.warnings 2007-02-14 17:41:23.000000000 -0500 -+++ dhcp-3.1.0/relay/dhcrelay.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/relay/dhcrelay.c 2007-10-23 14:33:17.000000000 -0400 @@ -739,7 +739,7 @@ int add_relay_agent_options (ip, packet, unsigned length; struct in_addr giaddr; @@ -12,7 +12,7 @@ diff -up dhcp-3.1.0/relay/dhcrelay.c.warnings dhcp-3.1.0/relay/dhcrelay.c diff -up dhcp-3.1.0/dhcpctl/dhcpctl.c.warnings dhcp-3.1.0/dhcpctl/dhcpctl.c --- dhcp-3.1.0/dhcpctl/dhcpctl.c.warnings 2005-03-17 15:15:03.000000000 -0500 -+++ dhcp-3.1.0/dhcpctl/dhcpctl.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/dhcpctl/dhcpctl.c 2007-10-23 14:33:17.000000000 -0400 @@ -101,7 +101,6 @@ dhcpctl_status dhcpctl_connect (dhcpctl_ dhcpctl_handle authinfo) { @@ -63,7 +63,7 @@ diff -up dhcp-3.1.0/dhcpctl/dhcpctl.c.warnings dhcp-3.1.0/dhcpctl/dhcpctl.c if (status != ISC_R_SUCCESS) diff -up dhcp-3.1.0/dhcpctl/cltest.c.warnings dhcp-3.1.0/dhcpctl/cltest.c --- dhcp-3.1.0/dhcpctl/cltest.c.warnings 2005-03-17 15:15:03.000000000 -0500 -+++ dhcp-3.1.0/dhcpctl/cltest.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/dhcpctl/cltest.c 2007-10-23 14:33:17.000000000 -0400 @@ -60,9 +60,8 @@ int main (argc, argv) isc_result_t status, waitstatus; dhcpctl_handle authenticator; @@ -78,7 +78,7 @@ diff -up dhcp-3.1.0/dhcpctl/cltest.c.warnings dhcp-3.1.0/dhcpctl/cltest.c const char *interface = 0; diff -up dhcp-3.1.0/dhcpctl/remote.c.warnings dhcp-3.1.0/dhcpctl/remote.c --- dhcp-3.1.0/dhcpctl/remote.c.warnings 2005-03-17 15:15:04.000000000 -0500 -+++ dhcp-3.1.0/dhcpctl/remote.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/dhcpctl/remote.c 2007-10-23 14:33:17.000000000 -0400 @@ -354,8 +354,6 @@ isc_result_t dhcpctl_remote_stuff_values omapi_object_t *id, omapi_object_t *p) @@ -90,7 +90,7 @@ diff -up dhcp-3.1.0/dhcpctl/remote.c.warnings dhcp-3.1.0/dhcpctl/remote.c diff -up dhcp-3.1.0/dhcpctl/callback.c.warnings dhcp-3.1.0/dhcpctl/callback.c --- dhcp-3.1.0/dhcpctl/callback.c.warnings 2005-03-17 15:15:02.000000000 -0500 -+++ dhcp-3.1.0/dhcpctl/callback.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/dhcpctl/callback.c 2007-10-23 14:33:17.000000000 -0400 @@ -59,7 +59,6 @@ dhcpctl_status dhcpctl_set_callback (dhc { dhcpctl_callback_object_t *callback; @@ -110,7 +110,7 @@ diff -up dhcp-3.1.0/dhcpctl/callback.c.warnings dhcp-3.1.0/dhcpctl/callback.c diff -up dhcp-3.1.0/dhcpctl/omshell.c.warnings dhcp-3.1.0/dhcpctl/omshell.c --- dhcp-3.1.0/dhcpctl/omshell.c.warnings 2007-02-14 17:41:22.000000000 -0500 -+++ dhcp-3.1.0/dhcpctl/omshell.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/dhcpctl/omshell.c 2007-10-23 14:33:17.000000000 -0400 @@ -82,11 +82,9 @@ int main (int argc, char **argv, char ** dhcpctl_handle connection; dhcpctl_handle authenticator; @@ -134,7 +134,7 @@ diff -up dhcp-3.1.0/dhcpctl/omshell.c.warnings dhcp-3.1.0/dhcpctl/omshell.c "dotted octet > 255: %s", diff -up dhcp-3.1.0/omapip/message.c.warnings dhcp-3.1.0/omapip/message.c --- dhcp-3.1.0/omapip/message.c.warnings 2005-03-17 15:15:22.000000000 -0500 -+++ dhcp-3.1.0/omapip/message.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/message.c 2007-10-23 14:33:17.000000000 -0400 @@ -209,8 +209,6 @@ isc_result_t omapi_message_get_value (om isc_result_t omapi_message_destroy (omapi_object_t *h, const char *file, int line) @@ -154,8 +154,8 @@ diff -up dhcp-3.1.0/omapip/message.c.warnings dhcp-3.1.0/omapip/message.c return ISC_R_INVALIDARG; diff -up dhcp-3.1.0/omapip/alloc.c.warnings dhcp-3.1.0/omapip/alloc.c ---- dhcp-3.1.0/omapip/alloc.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/omapip/alloc.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/omapip/alloc.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/omapip/alloc.c 2007-10-23 14:33:17.000000000 -0400 @@ -93,7 +93,6 @@ VOIDPTR dmalloc (size, file, line) { unsigned char *foo; @@ -166,7 +166,7 @@ diff -up dhcp-3.1.0/omapip/alloc.c.warnings dhcp-3.1.0/omapip/alloc.c defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) diff -up dhcp-3.1.0/omapip/connection.c.warnings dhcp-3.1.0/omapip/connection.c --- dhcp-3.1.0/omapip/connection.c.warnings 2005-03-17 15:15:21.000000000 -0500 -+++ dhcp-3.1.0/omapip/connection.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/connection.c 2007-10-23 14:33:17.000000000 -0400 @@ -111,10 +111,6 @@ isc_result_t omapi_connect_list (omapi_o omapi_connection_object_t *obj; int flag; @@ -189,7 +189,7 @@ diff -up dhcp-3.1.0/omapip/connection.c.warnings dhcp-3.1.0/omapip/connection.c diff -up dhcp-3.1.0/omapip/protocol.c.warnings dhcp-3.1.0/omapip/protocol.c --- dhcp-3.1.0/omapip/protocol.c.warnings 2007-05-23 19:30:33.000000000 -0400 -+++ dhcp-3.1.0/omapip/protocol.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/protocol.c 2007-10-23 14:33:17.000000000 -0400 @@ -165,7 +165,6 @@ isc_result_t omapi_protocol_send_message omapi_remote_auth_t *ra; omapi_value_t *signature; @@ -218,7 +218,7 @@ diff -up dhcp-3.1.0/omapip/protocol.c.warnings dhcp-3.1.0/omapip/protocol.c diff -up dhcp-3.1.0/omapip/listener.c.warnings dhcp-3.1.0/omapip/listener.c --- dhcp-3.1.0/omapip/listener.c.warnings 2005-03-17 15:15:22.000000000 -0500 -+++ dhcp-3.1.0/omapip/listener.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/listener.c 2007-10-23 14:33:17.000000000 -0400 @@ -68,12 +68,9 @@ isc_result_t omapi_listen_addr (omapi_ob omapi_addr_t *addr, int max) @@ -260,7 +260,7 @@ diff -up dhcp-3.1.0/omapip/listener.c.warnings dhcp-3.1.0/omapip/listener.c diff -up dhcp-3.1.0/omapip/handle.c.warnings dhcp-3.1.0/omapip/handle.c --- dhcp-3.1.0/omapip/handle.c.warnings 2006-02-24 18:16:30.000000000 -0500 -+++ dhcp-3.1.0/omapip/handle.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/handle.c 2007-10-23 14:33:17.000000000 -0400 @@ -76,7 +76,6 @@ static isc_result_t omapi_handle_table_e isc_result_t omapi_object_handle (omapi_handle_t *h, omapi_object_t *o) @@ -279,7 +279,7 @@ diff -up dhcp-3.1.0/omapip/handle.c.warnings dhcp-3.1.0/omapip/handle.c if (handle -> type == omapi_datatype_int) diff -up dhcp-3.1.0/omapip/trace.c.warnings dhcp-3.1.0/omapip/trace.c --- dhcp-3.1.0/omapip/trace.c.warnings 2007-05-23 19:30:33.000000000 -0400 -+++ dhcp-3.1.0/omapip/trace.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/trace.c 2007-10-23 14:33:17.000000000 -0400 @@ -319,7 +319,7 @@ trace_type_t *trace_type_register (const void (*stop_tracing) (trace_type_t *), const char *file, int line) @@ -307,7 +307,7 @@ diff -up dhcp-3.1.0/omapip/trace.c.warnings dhcp-3.1.0/omapip/trace.c diff -up dhcp-3.1.0/omapip/buffer.c.warnings dhcp-3.1.0/omapip/buffer.c --- dhcp-3.1.0/omapip/buffer.c.warnings 2006-02-24 18:16:30.000000000 -0500 -+++ dhcp-3.1.0/omapip/buffer.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/buffer.c 2007-10-23 14:33:17.000000000 -0400 @@ -438,7 +438,6 @@ isc_result_t omapi_connection_writer (om int bytes_written; unsigned first_byte; @@ -334,7 +334,7 @@ diff -up dhcp-3.1.0/omapip/buffer.c.warnings dhcp-3.1.0/omapip/buffer.c diff -up dhcp-3.1.0/omapip/support.c.warnings dhcp-3.1.0/omapip/support.c --- dhcp-3.1.0/omapip/support.c.warnings 2006-02-24 18:16:30.000000000 -0500 -+++ dhcp-3.1.0/omapip/support.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/support.c 2007-10-23 14:33:17.000000000 -0400 @@ -53,7 +53,6 @@ omapi_object_type_t *omapi_type_auth_key omapi_object_type_t *omapi_object_types; @@ -397,7 +397,7 @@ diff -up dhcp-3.1.0/omapip/support.c.warnings dhcp-3.1.0/omapip/support.c if (status != ISC_R_SUCCESS) diff -up dhcp-3.1.0/omapip/hash.c.warnings dhcp-3.1.0/omapip/hash.c --- dhcp-3.1.0/omapip/hash.c.warnings 2007-05-29 13:49:44.000000000 -0400 -+++ dhcp-3.1.0/omapip/hash.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/hash.c 2007-10-23 14:33:17.000000000 -0400 @@ -103,8 +103,6 @@ void free_hash_table (tp, file, line) const char *file; int line; @@ -438,7 +438,7 @@ diff -up dhcp-3.1.0/omapip/hash.c.warnings dhcp-3.1.0/omapip/hash.c return retbuf; diff -up dhcp-3.1.0/omapip/mrtrace.c.warnings dhcp-3.1.0/omapip/mrtrace.c --- dhcp-3.1.0/omapip/mrtrace.c.warnings 2005-03-17 15:15:22.000000000 -0500 -+++ dhcp-3.1.0/omapip/mrtrace.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/mrtrace.c 2007-10-23 14:33:17.000000000 -0400 @@ -85,7 +85,6 @@ void trace_mr_statp_setup (res_state sta unsigned buflen = 0; char *buf = (char *)0; @@ -456,8 +456,8 @@ diff -up dhcp-3.1.0/omapip/mrtrace.c.warnings dhcp-3.1.0/omapip/mrtrace.c if (status != ISC_R_SUCCESS) { log_error ("trace_mr_statp: no statp packet found."); diff -up dhcp-3.1.0/omapip/errwarn.c.warnings dhcp-3.1.0/omapip/errwarn.c ---- dhcp-3.1.0/omapip/errwarn.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/omapip/errwarn.c 2007-10-23 10:10:23.000000000 -0400 +--- dhcp-3.1.0/omapip/errwarn.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/omapip/errwarn.c 2007-10-23 14:33:17.000000000 -0400 @@ -65,7 +65,7 @@ void log_fatal (const char * fmt, ... ) va_list list; @@ -548,7 +548,7 @@ diff -up dhcp-3.1.0/omapip/errwarn.c.warnings dhcp-3.1.0/omapip/errwarn.c return 0; diff -up dhcp-3.1.0/omapip/array.c.warnings dhcp-3.1.0/omapip/array.c --- dhcp-3.1.0/omapip/array.c.warnings 2006-02-24 18:16:30.000000000 -0500 -+++ dhcp-3.1.0/omapip/array.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/array.c 2007-10-23 14:33:17.000000000 -0400 @@ -46,7 +46,6 @@ isc_result_t omapi_array_allocate (omapi omapi_array_deref_t deref, const char *file, int line) @@ -567,7 +567,7 @@ diff -up dhcp-3.1.0/omapip/array.c.warnings dhcp-3.1.0/omapip/array.c diff -up dhcp-3.1.0/omapip/generic.c.warnings dhcp-3.1.0/omapip/generic.c --- dhcp-3.1.0/omapip/generic.c.warnings 2006-02-24 18:16:30.000000000 -0500 -+++ dhcp-3.1.0/omapip/generic.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/generic.c 2007-10-23 14:33:17.000000000 -0400 @@ -292,7 +292,6 @@ isc_result_t omapi_generic_stuff_values isc_result_t omapi_generic_clear_flags (omapi_object_t *o) { @@ -578,7 +578,7 @@ diff -up dhcp-3.1.0/omapip/generic.c.warnings dhcp-3.1.0/omapip/generic.c if (o -> type != omapi_type_generic) diff -up dhcp-3.1.0/omapip/convert.c.warnings dhcp-3.1.0/omapip/convert.c --- dhcp-3.1.0/omapip/convert.c.warnings 2005-03-17 15:15:21.000000000 -0500 -+++ dhcp-3.1.0/omapip/convert.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/omapip/convert.c 2007-10-23 14:33:17.000000000 -0400 @@ -165,7 +165,7 @@ int binary_to_ascii (outbuf, inbuf, base u_int32_t number; static char h2a [] = "0123456789abcdef"; @@ -589,8 +589,8 @@ diff -up dhcp-3.1.0/omapip/convert.c.warnings dhcp-3.1.0/omapip/convert.c if (base > 16) return 0; diff -up dhcp-3.1.0/server/dhcp.c.warnings dhcp-3.1.0/server/dhcp.c ---- dhcp-3.1.0/server/dhcp.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/server/dhcp.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/server/dhcp.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/server/dhcp.c 2007-10-23 14:33:17.000000000 -0400 @@ -265,7 +265,7 @@ void dhcpdiscover (packet, ms_nulltp) if (lease && lease -> client_hostname) { @@ -720,8 +720,8 @@ diff -up dhcp-3.1.0/server/dhcp.c.warnings dhcp-3.1.0/server/dhcp.c option_code_hash_lookup(&oc->option, dhcp_universe.code_hash, diff -up dhcp-3.1.0/server/dhcpd.c.warnings dhcp-3.1.0/server/dhcpd.c ---- dhcp-3.1.0/server/dhcpd.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/server/dhcpd.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/server/dhcpd.c.warnings 2007-10-23 14:33:16.000000000 -0400 ++++ dhcp-3.1.0/server/dhcpd.c 2007-10-23 14:33:17.000000000 -0400 @@ -200,7 +200,7 @@ int main (argc, argv, envp) int fd; int i, status; @@ -771,7 +771,7 @@ diff -up dhcp-3.1.0/server/dhcpd.c.warnings dhcp-3.1.0/server/dhcpd.c log_fatal ("No memory for shared subnet: %s", diff -up dhcp-3.1.0/server/omapi.c.warnings dhcp-3.1.0/server/omapi.c --- dhcp-3.1.0/server/omapi.c.warnings 2007-05-23 19:30:33.000000000 -0400 -+++ dhcp-3.1.0/server/omapi.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/server/omapi.c 2007-10-23 14:33:17.000000000 -0400 @@ -212,7 +212,6 @@ isc_result_t dhcp_lease_set_value (omap { struct lease *lease; @@ -879,7 +879,7 @@ diff -up dhcp-3.1.0/server/omapi.c.warnings dhcp-3.1.0/server/omapi.c diff -up dhcp-3.1.0/server/ddns.c.warnings dhcp-3.1.0/server/ddns.c --- dhcp-3.1.0/server/ddns.c.warnings 2007-04-27 18:48:10.000000000 -0400 -+++ dhcp-3.1.0/server/ddns.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/server/ddns.c 2007-10-23 14:33:17.000000000 -0400 @@ -224,7 +224,6 @@ int ddns_updates (struct packet *packet, struct data_string ddns_fwd_name; struct data_string ddns_rev_name; @@ -898,7 +898,7 @@ diff -up dhcp-3.1.0/server/ddns.c.warnings dhcp-3.1.0/server/ddns.c diff -up dhcp-3.1.0/server/db.c.warnings dhcp-3.1.0/server/db.c --- dhcp-3.1.0/server/db.c.warnings 2007-06-06 19:17:51.000000000 -0400 -+++ dhcp-3.1.0/server/db.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/server/db.c 2007-10-23 14:33:17.000000000 -0400 @@ -54,7 +54,6 @@ int write_lease (lease) struct lease *lease; { @@ -976,8 +976,8 @@ diff -up dhcp-3.1.0/server/db.c.warnings dhcp-3.1.0/server/db.c if (lease_file_is_corrupt) if (!new_lease_file ()) diff -up dhcp-3.1.0/server/confpars.c.warnings dhcp-3.1.0/server/confpars.c ---- dhcp-3.1.0/server/confpars.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/server/confpars.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/server/confpars.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/server/confpars.c 2007-10-23 14:33:17.000000000 -0400 @@ -39,7 +39,6 @@ static char copyright[] = #include "dhcpd.h" @@ -1063,7 +1063,7 @@ diff -up dhcp-3.1.0/server/confpars.c.warnings dhcp-3.1.0/server/confpars.c diff -up dhcp-3.1.0/server/failover.c.warnings dhcp-3.1.0/server/failover.c --- dhcp-3.1.0/server/failover.c.warnings 2007-06-01 18:26:58.000000000 -0400 -+++ dhcp-3.1.0/server/failover.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/server/failover.c 2007-10-23 14:33:17.000000000 -0400 @@ -64,7 +64,6 @@ void dhcp_failover_startup () { dhcp_failover_state_t *state; @@ -1209,8 +1209,8 @@ diff -up dhcp-3.1.0/server/failover.c.warnings dhcp-3.1.0/server/failover.c #define FREE_LEASES 0 #define ACTIVE_LEASES 1 diff -up dhcp-3.1.0/server/mdb.c.warnings dhcp-3.1.0/server/mdb.c ---- dhcp-3.1.0/server/mdb.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/server/mdb.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/server/mdb.c.warnings 2007-10-23 14:33:16.000000000 -0400 ++++ dhcp-3.1.0/server/mdb.c 2007-10-23 14:33:17.000000000 -0400 @@ -317,7 +317,6 @@ isc_result_t delete_host (hd, commit) struct host_decl *hp = (struct host_decl *)0; struct host_decl *np = (struct host_decl *)0; @@ -1282,8 +1282,8 @@ diff -up dhcp-3.1.0/server/mdb.c.warnings dhcp-3.1.0/server/mdb.c struct lease *l; struct lease **lptr[RESERVED_LEASES+1]; diff -up dhcp-3.1.0/dst/dst_api.c.warnings dhcp-3.1.0/dst/dst_api.c ---- dhcp-3.1.0/dst/dst_api.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/dst/dst_api.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/dst/dst_api.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/dst/dst_api.c 2007-10-23 14:33:17.000000000 -0400 @@ -475,7 +475,7 @@ dst_s_read_public_key(const char *in_nam int proto, alg, dlen; int c; @@ -1305,7 +1305,7 @@ diff -up dhcp-3.1.0/dst/dst_api.c.warnings dhcp-3.1.0/dst/dst_api.c while ((c = getc(fp)) != EOF) diff -up dhcp-3.1.0/dst/prandom.c.warnings dhcp-3.1.0/dst/prandom.c --- dhcp-3.1.0/dst/prandom.c.warnings 2001-02-22 02:22:09.000000000 -0500 -+++ dhcp-3.1.0/dst/prandom.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/dst/prandom.c 2007-10-23 14:33:17.000000000 -0400 @@ -335,7 +335,7 @@ unix_cmd(dst_work *work) cnt += do_time(work); } @@ -1316,8 +1316,8 @@ diff -up dhcp-3.1.0/dst/prandom.c.warnings dhcp-3.1.0/dst/prandom.c return (cnt); /* read how many bytes where read in */ } diff -up dhcp-3.1.0/common/conflex.c.warnings dhcp-3.1.0/common/conflex.c ---- dhcp-3.1.0/common/conflex.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/common/conflex.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/common/conflex.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/common/conflex.c 2007-10-23 14:33:17.000000000 -0400 @@ -518,13 +518,15 @@ static enum dhcp_token read_num_or_name cfile -> tokbuf [i] = 0; cfile -> tlen = i; @@ -1339,7 +1339,7 @@ diff -up dhcp-3.1.0/common/conflex.c.warnings dhcp-3.1.0/common/conflex.c diff -up dhcp-3.1.0/common/socket.c.warnings dhcp-3.1.0/common/socket.c --- dhcp-3.1.0/common/socket.c.warnings 2006-07-25 13:41:18.000000000 -0400 -+++ dhcp-3.1.0/common/socket.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/common/socket.c 2007-10-23 14:33:17.000000000 -0400 @@ -55,8 +55,6 @@ static char copyright[] = # endif #endif @@ -1351,7 +1351,7 @@ diff -up dhcp-3.1.0/common/socket.c.warnings dhcp-3.1.0/common/socket.c diff -up dhcp-3.1.0/common/parse.c.warnings dhcp-3.1.0/common/parse.c --- dhcp-3.1.0/common/parse.c.warnings 2007-05-29 13:49:44.000000000 -0400 -+++ dhcp-3.1.0/common/parse.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/common/parse.c 2007-10-23 14:33:17.000000000 -0400 @@ -311,9 +311,6 @@ int parse_ip_addr (cfile, addr) struct parse *cfile; struct iaddr *addr; @@ -1508,8 +1508,8 @@ diff -up dhcp-3.1.0/common/parse.c.warnings dhcp-3.1.0/common/parse.c cfile -> warnings_occurred = 1; diff -up dhcp-3.1.0/common/alloc.c.warnings dhcp-3.1.0/common/alloc.c ---- dhcp-3.1.0/common/alloc.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/common/alloc.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/common/alloc.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/common/alloc.c 2007-10-23 14:33:17.000000000 -0400 @@ -48,7 +48,6 @@ int option_chain_head_allocate (ptr, fil const char *file; int line; @@ -1577,8 +1577,8 @@ diff -up dhcp-3.1.0/common/alloc.c.warnings dhcp-3.1.0/common/alloc.c if (!ptr) { diff -up dhcp-3.1.0/common/lpf.c.warnings dhcp-3.1.0/common/lpf.c ---- dhcp-3.1.0/common/lpf.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/common/lpf.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/common/lpf.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/common/lpf.c 2007-10-23 14:33:17.000000000 -0400 @@ -84,8 +84,6 @@ int if_register_lpf (info) struct interface_info *info; { @@ -1598,7 +1598,7 @@ diff -up dhcp-3.1.0/common/lpf.c.warnings dhcp-3.1.0/common/lpf.c int nocsum = 0; diff -up dhcp-3.1.0/common/memory.c.warnings dhcp-3.1.0/common/memory.c --- dhcp-3.1.0/common/memory.c.warnings 2006-06-01 16:23:17.000000000 -0400 -+++ dhcp-3.1.0/common/memory.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/common/memory.c 2007-10-23 14:33:17.000000000 -0400 @@ -84,8 +84,7 @@ isc_result_t delete_group (struct group_ isc_result_t supersede_group (struct group_object *group, int writep) @@ -1619,7 +1619,7 @@ diff -up dhcp-3.1.0/common/memory.c.warnings dhcp-3.1.0/common/memory.c /* Normally gp should contain the null pointer, but for convenience diff -up dhcp-3.1.0/common/comapi.c.warnings dhcp-3.1.0/common/comapi.c --- dhcp-3.1.0/common/comapi.c.warnings 2006-02-24 18:16:28.000000000 -0500 -+++ dhcp-3.1.0/common/comapi.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/common/comapi.c 2007-10-23 14:33:17.000000000 -0400 @@ -143,7 +143,6 @@ isc_result_t dhcp_group_set_value (omap { struct group_object *group; @@ -1754,7 +1754,7 @@ diff -up dhcp-3.1.0/common/comapi.c.warnings dhcp-3.1.0/common/comapi.c /* If we get to here without finding a shared_network, no valid key was diff -up dhcp-3.1.0/common/icmp.c.warnings dhcp-3.1.0/common/icmp.c --- dhcp-3.1.0/common/icmp.c.warnings 2005-03-17 15:14:58.000000000 -0500 -+++ dhcp-3.1.0/common/icmp.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/common/icmp.c 2007-10-23 14:33:17.000000000 -0400 @@ -61,11 +61,7 @@ void icmp_startup (routep, handler) { struct protoent *proto; @@ -1777,7 +1777,7 @@ diff -up dhcp-3.1.0/common/icmp.c.warnings dhcp-3.1.0/common/icmp.c ia->len = ntohl(ia->len); diff -up dhcp-3.1.0/common/inet.c.warnings dhcp-3.1.0/common/inet.c --- dhcp-3.1.0/common/inet.c.warnings 2006-05-15 11:07:49.000000000 -0400 -+++ dhcp-3.1.0/common/inet.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/common/inet.c 2007-10-23 14:33:17.000000000 -0400 @@ -124,7 +124,7 @@ struct iaddr broadcast_addr (subnet, mas struct iaddr subnet; struct iaddr mask; @@ -1789,7 +1789,7 @@ diff -up dhcp-3.1.0/common/inet.c.warnings dhcp-3.1.0/common/inet.c if (subnet.len > sizeof(subnet.iabuf)) diff -up dhcp-3.1.0/common/dns.c.warnings dhcp-3.1.0/common/dns.c --- dhcp-3.1.0/common/dns.c.warnings 2006-07-19 13:14:55.000000000 -0400 -+++ dhcp-3.1.0/common/dns.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/common/dns.c 2007-10-23 14:33:17.000000000 -0400 @@ -127,7 +127,6 @@ dns_zone_hash_t *dns_zone_hash; isc_result_t find_tsig_key (ns_tsig_key **key, const char *zname, struct dns_zone *zone) @@ -1834,8 +1834,8 @@ diff -up dhcp-3.1.0/common/dns.c.warnings dhcp-3.1.0/common/dns.c if (!updrec) { diff -up dhcp-3.1.0/common/tree.c.warnings dhcp-3.1.0/common/tree.c ---- dhcp-3.1.0/common/tree.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/common/tree.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/common/tree.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/common/tree.c 2007-10-23 14:33:17.000000000 -0400 @@ -51,61 +51,6 @@ struct __res_state resolver_state; int resolver_inited = 0; #endif @@ -1966,8 +1966,8 @@ diff -up dhcp-3.1.0/common/tree.c.warnings dhcp-3.1.0/common/tree.c if (!ptr || !*ptr) { diff -up dhcp-3.1.0/common/print.c.warnings dhcp-3.1.0/common/print.c ---- dhcp-3.1.0/common/print.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/common/print.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/common/print.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/common/print.c 2007-10-23 14:33:17.000000000 -0400 @@ -47,7 +47,7 @@ char *quotify_string (const char *s, con const unsigned char *sp; char *buf, *nsp; @@ -2011,8 +2011,8 @@ diff -up dhcp-3.1.0/common/print.c.warnings dhcp-3.1.0/common/print.c /* See if this is just ASCII. */ diff -up dhcp-3.1.0/common/discover.c.warnings dhcp-3.1.0/common/discover.c ---- dhcp-3.1.0/common/discover.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/common/discover.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/common/discover.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/common/discover.c 2007-10-23 14:33:17.000000000 -0400 @@ -128,16 +128,14 @@ int have_setup_fallback = 0; void discover_interfaces (state) int state; @@ -2065,8 +2065,8 @@ diff -up dhcp-3.1.0/common/discover.c.warnings dhcp-3.1.0/common/discover.c if (h -> type != dhcp_type_interface) diff -up dhcp-3.1.0/common/options.c.warnings dhcp-3.1.0/common/options.c ---- dhcp-3.1.0/common/options.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/common/options.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/common/options.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/common/options.c 2007-10-23 14:50:34.000000000 -0400 @@ -43,9 +43,6 @@ static char copyright[] = struct option *vendor_cfg_option; @@ -2145,6 +2145,15 @@ diff -up dhcp-3.1.0/common/options.c.warnings dhcp-3.1.0/common/options.c p = format; while (*p != '\0') { +@@ -2161,7 +2148,7 @@ store_option(struct data_string *result, + "refers to unknown " + "option space '%.*s'.", + oc->option->code, +- end - start, start); ++ (int) (end - start), start); + break; + } + @@ -2198,12 +2185,10 @@ int option_space_encapsulate (result, pa struct binding_scope **scope; struct data_string *name; @@ -2232,7 +2241,7 @@ diff -up dhcp-3.1.0/common/options.c.warnings dhcp-3.1.0/common/options.c } diff -up dhcp-3.1.0/common/execute.c.warnings dhcp-3.1.0/common/execute.c --- dhcp-3.1.0/common/execute.c.warnings 2007-05-11 11:51:07.000000000 -0400 -+++ dhcp-3.1.0/common/execute.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/common/execute.c 2007-10-23 14:33:17.000000000 -0400 @@ -54,8 +54,6 @@ int execute_statements (result, packet, struct executable_statement *r, *e, *next; int rc; @@ -2289,7 +2298,7 @@ diff -up dhcp-3.1.0/common/execute.c.warnings dhcp-3.1.0/common/execute.c if ((*callback) (foo, vp, condp) != 0) diff -up dhcp-3.1.0/common/resolv.c.warnings dhcp-3.1.0/common/resolv.c --- dhcp-3.1.0/common/resolv.c.warnings 2006-02-24 18:16:28.000000000 -0500 -+++ dhcp-3.1.0/common/resolv.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/common/resolv.c 2007-10-23 14:33:17.000000000 -0400 @@ -50,10 +50,8 @@ void read_resolv_conf (parse_time) struct parse *cfile; const char *val; @@ -2319,8 +2328,8 @@ diff -up dhcp-3.1.0/common/resolv.c.warnings dhcp-3.1.0/common/resolv.c read_resolv_conf (rcdate); diff -up dhcp-3.1.0/minires/res_init.c.warnings dhcp-3.1.0/minires/res_init.c ---- dhcp-3.1.0/minires/res_init.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/minires/res_init.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/minires/res_init.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/minires/res_init.c 2007-10-23 14:33:17.000000000 -0400 @@ -155,7 +155,7 @@ res_ninit(res_state statp) { int minires_vinit(res_state statp, int preinit) { @@ -2332,7 +2341,7 @@ diff -up dhcp-3.1.0/minires/res_init.c.warnings dhcp-3.1.0/minires/res_init.c char buf[BUFSIZ]; diff -up dhcp-3.1.0/minires/res_query.c.warnings dhcp-3.1.0/minires/res_query.c --- dhcp-3.1.0/minires/res_query.c.warnings 2007-05-29 13:49:44.000000000 -0400 -+++ dhcp-3.1.0/minires/res_query.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/minires/res_query.c 2007-10-23 14:33:17.000000000 -0400 @@ -384,7 +384,7 @@ res_nquerydomain(res_state statp, const char * res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) { @@ -2344,7 +2353,7 @@ diff -up dhcp-3.1.0/minires/res_query.c.warnings dhcp-3.1.0/minires/res_query.c diff -up dhcp-3.1.0/minires/res_update.c.warnings dhcp-3.1.0/minires/res_update.c --- dhcp-3.1.0/minires/res_update.c.warnings 2005-03-17 15:15:20.000000000 -0500 -+++ dhcp-3.1.0/minires/res_update.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/minires/res_update.c 2007-10-23 14:33:17.000000000 -0400 @@ -88,7 +88,7 @@ res_nupdate(res_state statp, ns_updrec * double answer[PACKETSZ / sizeof (double)]; double packet[2*PACKETSZ / sizeof (double)]; @@ -2356,7 +2365,7 @@ diff -up dhcp-3.1.0/minires/res_update.c.warnings dhcp-3.1.0/minires/res_update. struct sockaddr_in nsaddrs[MAXNS]; diff -up dhcp-3.1.0/minires/ns_date.c.warnings dhcp-3.1.0/minires/ns_date.c --- dhcp-3.1.0/minires/ns_date.c.warnings 2007-05-29 13:49:44.000000000 -0400 -+++ dhcp-3.1.0/minires/ns_date.c 2007-10-23 10:09:16.000000000 -0400 ++++ dhcp-3.1.0/minires/ns_date.c 2007-10-23 14:33:17.000000000 -0400 @@ -48,7 +48,7 @@ static const char rcsid[] = "$Id: ns_dat /* Forward. */ @@ -2376,8 +2385,8 @@ diff -up dhcp-3.1.0/minires/ns_date.c.warnings dhcp-3.1.0/minires/ns_date.c int i; diff -up dhcp-3.1.0/minires/res_mkupdate.c.warnings dhcp-3.1.0/minires/res_mkupdate.c ---- dhcp-3.1.0/minires/res_mkupdate.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/minires/res_mkupdate.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/minires/res_mkupdate.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/minires/res_mkupdate.c 2007-10-23 14:33:17.000000000 -0400 @@ -112,7 +112,7 @@ res_nmkupdate(res_state statp, u_int16_t rtype, rclass; u_int32_t n1, rttl; @@ -2388,8 +2397,8 @@ diff -up dhcp-3.1.0/minires/res_mkupdate.c.warnings dhcp-3.1.0/minires/res_mkupd unsigned buflen = *blp; u_char *buf = (unsigned char *)bp; diff -up dhcp-3.1.0/client/clparse.c.warnings dhcp-3.1.0/client/clparse.c ---- dhcp-3.1.0/client/clparse.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/client/clparse.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/client/clparse.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/client/clparse.c 2007-10-23 14:33:17.000000000 -0400 @@ -39,8 +39,6 @@ static char copyright[] = #include "dhcpd.h" @@ -2446,8 +2455,8 @@ diff -up dhcp-3.1.0/client/clparse.c.warnings dhcp-3.1.0/client/clparse.c skip_to_semi (cfile); return 0; diff -up dhcp-3.1.0/client/dhclient.c.warnings dhcp-3.1.0/client/dhclient.c ---- dhcp-3.1.0/client/dhclient.c.warnings 2007-10-23 10:09:16.000000000 -0400 -+++ dhcp-3.1.0/client/dhclient.c 2007-10-23 10:09:16.000000000 -0400 +--- dhcp-3.1.0/client/dhclient.c.warnings 2007-10-23 14:33:17.000000000 -0400 ++++ dhcp-3.1.0/client/dhclient.c 2007-10-23 14:33:17.000000000 -0400 @@ -126,7 +126,9 @@ int main (argc, argv, envp) #ifdef LIBDHCP libdhcp_control = libdhcp_ctl; diff --git a/dhcp-3.1.0-xen-checksum.patch b/dhcp-3.1.0-xen-checksum.patch new file mode 100644 index 0000000..6539bdc --- /dev/null +++ b/dhcp-3.1.0-xen-checksum.patch @@ -0,0 +1,243 @@ +diff -up dhcp-3.1.0/common/nit.c.xen dhcp-3.1.0/common/nit.c +--- dhcp-3.1.0/common/nit.c.xen 2007-05-23 19:30:32.000000000 -0400 ++++ dhcp-3.1.0/common/nit.c 2007-10-22 16:12:27.000000000 -0400 +@@ -371,7 +371,7 @@ ssize_t receive_packet (interface, buf, + + /* Decode the IP and UDP headers... */ + offset = decode_udp_ip_header (interface, ibuf, bufix, +- from, length, &paylen); ++ from, length, &paylen, 0); + + /* If the IP or UDP checksum was bad, skip the packet... */ + if (offset < 0) +diff -up dhcp-3.1.0/common/dlpi.c.xen dhcp-3.1.0/common/dlpi.c +--- dhcp-3.1.0/common/dlpi.c.xen 2007-05-23 19:30:32.000000000 -0400 ++++ dhcp-3.1.0/common/dlpi.c 2007-10-22 16:12:11.000000000 -0400 +@@ -680,7 +680,7 @@ ssize_t receive_packet (interface, buf, + length -= offset; + #endif + offset = decode_udp_ip_header (interface, dbuf, bufix, +- from, length, &paylen); ++ from, length, &paylen, 0); + + /* If the IP or UDP checksum was bad, skip the packet... */ + if (offset < 0) { +diff -up dhcp-3.1.0/common/upf.c.xen dhcp-3.1.0/common/upf.c +--- dhcp-3.1.0/common/upf.c.xen 2007-05-23 19:30:32.000000000 -0400 ++++ dhcp-3.1.0/common/upf.c 2007-10-22 16:12:52.000000000 -0400 +@@ -322,7 +322,7 @@ ssize_t receive_packet (interface, buf, + + /* Decode the IP and UDP headers... */ + offset = decode_udp_ip_header (interface, ibuf, bufix, +- from, length, &paylen); ++ from, length, &paylen, 0); + + /* If the IP or UDP checksum was bad, skip the packet... */ + if (offset < 0) +diff -up dhcp-3.1.0/common/lpf.c.xen dhcp-3.1.0/common/lpf.c +--- dhcp-3.1.0/common/lpf.c.xen 2007-10-22 16:11:12.000000000 -0400 ++++ dhcp-3.1.0/common/lpf.c 2007-10-22 16:15:24.000000000 -0400 +@@ -34,16 +34,31 @@ static char copyright[] = + #include "dhcpd.h" + #if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE) + #include ++#include + #include + + #include + #include + #include ++#include + #include + #include "includes/netinet/ip.h" + #include "includes/netinet/udp.h" + #include "includes/netinet/if_ether.h" + ++#ifndef PACKET_AUXDATA ++#define PACKET_AUXDATA 8 ++ ++struct tpacket_auxdata ++{ ++ __u32 tp_status; ++ __u32 tp_len; ++ __u32 tp_snaplen; ++ __u16 tp_mac; ++ __u16 tp_net; ++}; ++#endif ++ + /* Reinitializes the specified interface after an address change. This + is not required for packet-filter APIs. */ + +@@ -71,10 +86,14 @@ int if_register_lpf (info) + int sock; + char filename[50]; + int b; +- struct sockaddr sa; ++ union { ++ struct sockaddr_ll ll; ++ struct sockaddr common; ++ } sa; ++ struct ifreq ifr; + + /* Make an LPF socket. */ +- if ((sock = socket(PF_PACKET, SOCK_PACKET, ++ if ((sock = socket(PF_PACKET, SOCK_RAW, + htons((short)ETH_P_ALL))) < 0) { + if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || + errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT || +@@ -89,11 +108,16 @@ int if_register_lpf (info) + log_fatal ("Open a socket for LPF: %m"); + } + ++ memset (&ifr, 0, sizeof ifr); ++ strncpy (ifr.ifr_name, (const char *)info -> ifp, sizeof ifr.ifr_name); ++ if (ioctl (sock, SIOCGIFINDEX, &ifr)) ++ log_fatal ("Failed to get interface index: %m"); ++ + /* Bind to the interface name */ + memset (&sa, 0, sizeof sa); +- sa.sa_family = AF_PACKET; +- strncpy (sa.sa_data, (const char *)info -> ifp, sizeof sa.sa_data); +- if (bind (sock, &sa, sizeof sa)) { ++ sa.ll.sll_family = AF_PACKET; ++ sa.ll.sll_ifindex = ifr.ifr_ifindex; ++ if (bind (sock, &sa.common, sizeof sa)) { + if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || + errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT || + errno == EAFNOSUPPORT || errno == EINVAL) { +@@ -173,9 +197,18 @@ static void lpf_gen_filter_setup (struct + void if_register_receive (info) + struct interface_info *info; + { ++ int val; ++ + /* Open a LPF device and hang it on this interface... */ + info -> rfdesc = if_register_lpf (info); + ++ val = 1; ++ if (setsockopt (info -> rfdesc, SOL_PACKET, PACKET_AUXDATA, &val, ++ sizeof val) < 0) { ++ if (errno != ENOPROTOOPT) ++ log_fatal ("Failed to set auxiliary packet data: %m"); ++ } ++ + #if defined (HAVE_TR_SUPPORT) + if (info -> hw_address.hbuf [0] == HTYPE_IEEE802) + lpf_tr_filter_setup (info); +@@ -294,7 +327,6 @@ ssize_t send_packet (interface, packet, + double hh [16]; + double ih [1536 / sizeof (double)]; + unsigned char *buf = (unsigned char *)ih; +- struct sockaddr sa; + int result; + int fudge; + +@@ -312,15 +344,7 @@ ssize_t send_packet (interface, packet, + (unsigned char *)raw, len); + memcpy (buf + ibufp, raw, len); + +- /* For some reason, SOCK_PACKET sockets can't be connected, +- so we have to do a sentdo every time. */ +- memset (&sa, 0, sizeof sa); +- sa.sa_family = AF_PACKET; +- strncpy (sa.sa_data, +- (const char *)interface -> ifp, sizeof sa.sa_data); +- +- result = sendto (interface -> wfdesc, +- buf + fudge, ibufp + len - fudge, 0, &sa, sizeof sa); ++ result = write (interface -> wfdesc, buf + fudge, ibufp + len - fudge); + if (result < 0) + log_error ("send_packet: %m"); + return result; +@@ -338,14 +362,35 @@ ssize_t receive_packet (interface, buf, + int nread; + int length = 0; + int offset = 0; ++ int nocsum = 0; + unsigned char ibuf [1536]; + unsigned bufix = 0; + unsigned paylen; ++ unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))]; ++ struct iovec iov = { ++ .iov_base = ibuf, ++ .iov_len = sizeof ibuf, ++ }; ++ struct msghdr msg = { ++ .msg_iov = &iov, ++ .msg_iovlen = 1, ++ .msg_control = cmsgbuf, ++ .msg_controllen = sizeof(cmsgbuf), ++ }; ++ struct cmsghdr *cmsg; + +- length = read (interface -> rfdesc, ibuf, sizeof ibuf); ++ length = recvmsg (interface -> rfdesc, &msg, 0); + if (length <= 0) + return length; + ++ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) { ++ if (cmsg->cmsg_level == SOL_PACKET && ++ cmsg->cmsg_type == PACKET_AUXDATA) { ++ struct tpacket_auxdata *aux = (void *)CMSG_DATA(cmsg); ++ nocsum = aux->tp_status & TP_STATUS_CSUMNOTREADY; ++ } ++ } ++ + bufix = 0; + /* Decode the physical header... */ + offset = decode_hw_header (interface, ibuf, bufix, hfrom); +@@ -362,7 +407,7 @@ ssize_t receive_packet (interface, buf, + + /* Decode the IP and UDP headers... */ + offset = decode_udp_ip_header (interface, ibuf, bufix, from, +- (unsigned)length, &paylen); ++ (unsigned)length, &paylen, nocsum); + + /* If the IP or UDP checksum was bad, skip the packet... */ + if (offset < 0) +diff -up dhcp-3.1.0/common/bpf.c.xen dhcp-3.1.0/common/bpf.c +--- dhcp-3.1.0/common/bpf.c.xen 2007-05-23 19:30:32.000000000 -0400 ++++ dhcp-3.1.0/common/bpf.c 2007-10-22 16:13:14.000000000 -0400 +@@ -478,7 +478,7 @@ ssize_t receive_packet (interface, buf, + offset = decode_udp_ip_header (interface, + interface -> rbuf, + interface -> rbuf_offset, +- from, hdr.bh_caplen, &paylen); ++ from, hdr.bh_caplen, &paylen, 0); + + /* If the IP or UDP checksum was bad, skip the packet... */ + if (offset < 0) { +diff -up dhcp-3.1.0/common/packet.c.xen dhcp-3.1.0/common/packet.c +--- dhcp-3.1.0/common/packet.c.xen 2007-10-22 16:11:12.000000000 -0400 ++++ dhcp-3.1.0/common/packet.c 2007-10-22 16:12:41.000000000 -0400 +@@ -215,7 +215,7 @@ ssize_t + decode_udp_ip_header(struct interface_info *interface, + unsigned char *buf, unsigned bufix, + struct sockaddr_in *from, unsigned buflen, +- unsigned *rbuflen) ++ unsigned *rbuflen, int nocsum) + { + unsigned char *data; + struct ip ip; +@@ -326,7 +326,7 @@ decode_udp_ip_header(struct interface_in + 8, IPPROTO_UDP + ulen)))); + + udp_packets_seen++; +- if (usum && usum != sum) { ++ if (!nocsum && usum && usum != sum) { + udp_packets_bad_checksum++; + if (udp_packets_seen > 4 && + (udp_packets_seen / udp_packets_bad_checksum) < 2) { +diff -up dhcp-3.1.0/includes/dhcpd.h.xen dhcp-3.1.0/includes/dhcpd.h +--- dhcp-3.1.0/includes/dhcpd.h.xen 2007-10-22 16:11:12.000000000 -0400 ++++ dhcp-3.1.0/includes/dhcpd.h 2007-10-22 16:13:01.000000000 -0400 +@@ -2140,7 +2140,7 @@ ssize_t decode_hw_header PROTO ((struct + unsigned, struct hardware *)); + ssize_t decode_udp_ip_header PROTO ((struct interface_info *, unsigned char *, + unsigned, struct sockaddr_in *, +- unsigned, unsigned *)); ++ unsigned, unsigned *, int)); + + /* ethernet.c */ + void assemble_ethernet_header PROTO ((struct interface_info *, unsigned char *, diff --git a/dhcp.schema b/dhcp.schema new file mode 100644 index 0000000..7cc96b0 --- /dev/null +++ b/dhcp.schema @@ -0,0 +1,344 @@ +attributetype ( 2.16.840.1.113719.1.203.4.1 + NAME 'dhcpPrimaryDN' + EQUALITY distinguishedNameMatch + DESC 'The DN of the dhcpServer which is the primary server for the configuration.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.2 + NAME 'dhcpSecondaryDN' + EQUALITY distinguishedNameMatch + DESC 'The DN of dhcpServer(s) which provide backup service for the configuration.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) + +attributetype ( 2.16.840.1.113719.1.203.4.3 + NAME 'dhcpStatements' + EQUALITY caseIgnoreIA5Match + DESC 'Flexible storage for specific data depending on what object this exists in. Like conditional statements, server parameters, etc. This allows the standard to evolve without needing to adjust the schema.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 2.16.840.1.113719.1.203.4.4 + NAME 'dhcpRange' + EQUALITY caseIgnoreIA5Match + DESC 'The starting & ending IP Addresses in the range (inclusive), separated by a hyphen; if the range only contains one address, then just the address can be specified with no hyphen. Each range is defined as a separate value.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 2.16.840.1.113719.1.203.4.5 + NAME 'dhcpPermitList' + EQUALITY caseIgnoreIA5Match + DESC 'This attribute contains the permit lists associated with a pool. Each permit list is defined as a separate value.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 2.16.840.1.113719.1.203.4.6 + NAME 'dhcpNetMask' + EQUALITY integerMatch + DESC 'The subnet mask length for the subnet. The mask can be easily computed from this length.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.7 + NAME 'dhcpOption' + EQUALITY caseIgnoreIA5Match + DESC 'Encoded option values to be sent to clients. Each value represents a single option and contains (OptionTag, Length, OptionValue) encoded in the format used by DHCP.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) + +attributetype ( 2.16.840.1.113719.1.203.4.8 + NAME 'dhcpClassData' + EQUALITY caseIgnoreIA5Match + DESC 'Encoded text string or list of bytes expressed in hexadecimal, separated by colons. Clients match subclasses based on matching the class data with the results of match or spawn with statements in the class name declarations.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.9 + NAME 'dhcpOptionsDN' + EQUALITY distinguishedNameMatch + DESC 'The distinguished name(s) of the dhcpOption objects containing the configuration options provided by the server.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) + +attributetype ( 2.16.840.1.113719.1.203.4.10 + NAME 'dhcpHostDN' + EQUALITY distinguishedNameMatch + DESC 'the distinguished name(s) of the dhcpHost objects.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) + +attributetype ( 2.16.840.1.113719.1.203.4.11 + NAME 'dhcpPoolDN' + EQUALITY distinguishedNameMatch + DESC 'The distinguished name(s) of pools.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) + +attributetype ( 2.16.840.1.113719.1.203.4.12 + NAME 'dhcpGroupDN' + EQUALITY distinguishedNameMatch + DESC 'The distinguished name(s) of the groups.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) + +attributetype ( 2.16.840.1.113719.1.203.4.13 + NAME 'dhcpSubnetDN' + EQUALITY distinguishedNameMatch + DESC 'The distinguished name(s) of the subnets.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) + +attributetype ( 2.16.840.1.113719.1.203.4.14 + NAME 'dhcpLeaseDN' + EQUALITY distinguishedNameMatch + DESC 'The distinguished name of a client address.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE) + +attributetype ( 2.16.840.1.113719.1.203.4.15 NAME 'dhcpLeasesDN' + DESC 'The distinguished name(s) client addresses.' + EQUALITY distinguishedNameMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) + +attributetype ( 2.16.840.1.113719.1.203.4.16 + NAME 'dhcpClassesDN' + EQUALITY distinguishedNameMatch + DESC 'The distinguished name(s) of a class(es) in a subclass.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) + +attributetype ( 2.16.840.1.113719.1.203.4.17 + NAME 'dhcpSubclassesDN' + EQUALITY distinguishedNameMatch + DESC 'The distinguished name(s) of subclass(es).' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) + +attributetype ( 2.16.840.1.113719.1.203.4.18 + NAME 'dhcpSharedNetworkDN' + EQUALITY distinguishedNameMatch + DESC 'The distinguished name(s) of sharedNetworks.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) + +attributetype ( 2.16.840.1.113719.1.203.4.19 + NAME 'dhcpServiceDN' + EQUALITY distinguishedNameMatch + DESC 'The DN of dhcpService object(s)which contain the configuration information. Each dhcpServer object has this attribute identifying the DHCP configuration(s) that the server is associated with.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) + +attributetype ( 2.16.840.1.113719.1.203.4.20 + NAME 'dhcpVersion' DESC 'The version attribute of this object.' + EQUALITY caseIgnoreIA5Match + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.21 + NAME 'dhcpImplementation' + EQUALITY caseIgnoreIA5Match + DESC 'Description of the DHCP Server implementation e.g. DHCP Servers vendor.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.22 + NAME 'dhcpAddressState' + EQUALITY caseIgnoreIA5Match + DESC 'This stores information about the current binding-status of an address. For dynamic addresses managed by DHCP, the values should be restricted to the following: "FREE", "ACTIVE", "EXPIRED", "RELEASED", "RESET", "ABANDONED", "BACKUP". For other addresses, it SHOULD be one of the following: "UNKNOWN", "RESERVED" (an address that is managed by DHCP that is reserved for a specific client), "RESERVED-ACTIVE" (same as reserved, but address is currently in use), "ASSIGNED" (assigned manually or by some other mechanism), "UNASSIGNED", "NOTASSIGNABLE".' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.23 + NAME 'dhcpExpirationTime' + EQUALITY integerMatch + DESC 'This is the time the current lease for an address expires.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.24 + NAME 'dhcpStartTimeOfState' + EQUALITY integerMatch + DESC 'This is the time of the last state change for a leased address.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.25 + NAME 'dhcpLastTransactionTime' + EQUALITY integerMatch + DESC 'This is the last time a valid DHCP packet was received from the client.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.26 + NAME 'dhcpBootpFlag' + EQUALITY integerMatch + DESC 'This indicates whether the address was assigned via BOOTP.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.27 + NAME 'dhcpDomainName' + EQUALITY caseIgnoreIA5Match + DESC 'This is the name of the domain sent to the client by the server. It is essentially the same as the value for DHCP option 15 sent to the client, and represents only the domain - not the full FQDN. To obtain the full FQDN assigned to the client you must prepend the "dhcpAssignedHostName" to this value with a ".".' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.28 + NAME 'dhcpDnsStatus' + EQUALITY integerMatch + DESC 'This indicates the status of updating DNS resource records on behalf of the client by the DHCP server for this address. The value is a 16-bit bitmask.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.29 + NAME 'dhcpRequestedHostName' + EQUALITY caseIgnoreIA5Match + DESC 'This is the hostname that was requested by the client.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.30 + NAME 'dhcpAssignedHostName' + EQUALITY caseIgnoreIA5Match + DESC 'This is the actual hostname that was assigned to a client. It may not be the name that was requested by the client. The fully qualified domain name can be determined by appending the value of "dhcpDomainName" (with a dot separator) to this name.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.31 + NAME 'dhcpReservedForClient' + EQUALITY distinguishedNameMatch + DESC 'The distinguished name of a "dhcpClient" that an address is reserved for. This may not be the same as the "dhcpAssignedToClient" attribute if the address is being reassigned but the current lease has not yet expired.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.32 + NAME 'dhcpAssignedToClient' + EQUALITY distinguishedNameMatch + DESC 'This is the distinguished name of a "dhcpClient" that an address is currently assigned to. This attribute is only present in the class when the address is leased.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.33 + NAME 'dhcpRelayAgentInfo' + EQUALITY caseIgnoreIA5Match + DESC 'If the client request was received via a relay agent, this contains information about the relay agent that was available from the DHCP request. This is a hex-encoded option value.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.34 + NAME 'dhcpHWAddress' + EQUALITY caseIgnoreIA5Match + DESC 'The clients hardware address that requested this IP address.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.35 + NAME 'dhcpHashBucketAssignment' + EQUALITY caseIgnoreIA5Match + DESC 'HashBucketAssignment bit map for the DHCP Server, as defined in DHC Load Balancing Algorithm [RFC 3074].' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.36 + NAME 'dhcpDelayedServiceParameter' + EQUALITY integerMatch + DESC 'Delay in seconds corresponding to Delayed Service Parameter configuration, as defined in DHC Load Balancing Algorithm [RFC 3074]. ' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.37 + NAME 'dhcpMaxClientLeadTime' + EQUALITY integerMatch + DESC 'Maximum Client Lead Time configuration in seconds, as defined in DHCP Failover Protocol [FAILOVR]' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.38 + NAME 'dhcpFailOverEndpointState' + EQUALITY integerMatch + DESC 'Server (Failover Endpoint) state, as defined in DHCP Failover Protocol [FAILOVR]' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) + +attributetype ( 2.16.840.1.113719.1.203.4.39 + NAME 'dhcpErrorLog' + EQUALITY caseIgnoreIA5Match + DESC 'Generic error log attribute that allows logging error conditions within a dhcpService or a dhcpSubnet, like no IP addresses available for lease.' + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) + +# Classes + +objectclass ( 2.16.840.1.113719.1.203.6.1 + NAME 'dhcpService' + DESC 'Service object that represents the actual DHCP Service configuration. This is a container object.' + SUP top + MUST (cn $ dhcpPrimaryDN) + MAY ( dhcpSecondaryDN $ dhcpSharedNetworkDN $ dhcpSubnetDN $ + dhcpGroupDN $ dhcpHostDN $ dhcpClassesDN $ dhcpOptionsDN $ + dhcpStatements ) ) + +objectclass ( 2.16.840.1.113719.1.203.6.2 + NAME 'dhcpSharedNetwork' + DESC 'This stores configuration information for a shared network.' + SUP top + MUST cn + MAY ( dhcpSubnetDN $ dhcpPoolDN $ dhcpOptionsDN $ dhcpStatements) + X-NDS_CONTAINMENT ('dhcpService' ) ) + +objectclass ( 2.16.840.1.113719.1.203.6.3 + NAME 'dhcpSubnet' + DESC 'This class defines a subnet. This is a container object.' + SUP top + MUST ( cn $ dhcpNetMask ) + MAY ( dhcpRange $ dhcpPoolDN $ dhcpGroupDN $ dhcpHostDN $ + dhcpClassesDN $ dhcpLeasesDN $ dhcpOptionsDN $ dhcpStatements) + X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork') ) + +objectclass ( 2.16.840.1.113719.1.203.6.4 + NAME 'dhcpPool' + DESC 'This stores configuration information about a pool.' + SUP top + MUST ( cn $ dhcpRange ) + MAY (dhcpClassesDN $ dhcpPermitList $ dhcpLeasesDN $ dhcpOptionsDN $ + dhcpStatements) + X-NDS_CONTAINMENT ('dhcpSubnet' 'dhcpSharedNetwork') ) + +objectclass ( 2.16.840.1.113719.1.203.6.5 + NAME 'dhcpGroup' + DESC 'Group object that lists host DNs and parameters. This is a container object.' + SUP top + MUST cn + MAY ( dhcpHostDN $ dhcpOptionsDN $ dhcpStatements ) + X-NDS_CONTAINMENT ('dhcpSubnet' 'dhcpService' ) ) + +objectclass ( 2.16.840.1.113719.1.203.6.6 + NAME 'dhcpHost' + DESC 'This represents information about a particular client' + SUP top + MUST cn + MAY (dhcpLeaseDN $ dhcpHWAddress $ dhcpOptionsDN $ dhcpStatements) + X-NDS_CONTAINMENT ('dhcpService' 'dhcpSubnet' 'dhcpGroup') ) + +objectclass ( 2.16.840.1.113719.1.203.6.7 + NAME 'dhcpClass' + DESC 'Represents information about a collection of related clients.' + SUP top + MUST cn + MAY (dhcpSubClassesDN $ dhcpOptionsDN $ dhcpStatements) + X-NDS_CONTAINMENT ('dhcpService' 'dhcpSubnet' ) ) + +objectclass ( 2.16.840.1.113719.1.203.6.8 + NAME 'dhcpSubClass' + DESC 'Represents information about a collection of related classes.' + SUP top + MUST cn + MAY (dhcpClassData $ dhcpOptionsDN $ dhcpStatements) + X-NDS_CONTAINMENT 'dhcpClass' ) + +objectclass ( 2.16.840.1.113719.1.203.6.9 + NAME 'dhcpOptions' + DESC 'Represents information about a collection of options defined.' + SUP top + AUXILIARY + MUST cn + MAY ( dhcpOption ) + X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet' + 'dhcpPool' 'dhcpGroup' 'dhcpHost' 'dhcpClass' ) ) + +objectclass ( 2.16.840.1.113719.1.203.6.10 + NAME 'dhcpLeases' + DESC 'This class represents an IP Address, which may or may not have been leased.' + SUP top + MUST ( cn $ dhcpAddressState ) + MAY ( dhcpExpirationTime $ dhcpStartTimeOfState $ + dhcpLastTransactionTime $ dhcpBootpFlag $ dhcpDomainName $ + dhcpDnsStatus $ dhcpRequestedHostName $ dhcpAssignedHostName $ + dhcpReservedForClient $ dhcpAssignedToClient $ + dhcpRelayAgentInfo $ dhcpHWAddress ) + X-NDS_CONTAINMENT ( 'dhcpService' 'dhcpSubnet' 'dhcpPool') ) + +objectclass ( 2.16.840.1.113719.1.203.6.11 + NAME 'dhcpLog' + DESC 'This is the object that holds past information about the IP address. The cn is the time/date stamp when the address was assigned or released, the address state at the time, if the address was assigned or released.' + SUP top + MUST ( cn ) + MAY ( dhcpAddressState $ dhcpExpirationTime $ dhcpStartTimeOfState $ + dhcpLastTransactionTime $ dhcpBootpFlag $ dhcpDomainName $ + dhcpDnsStatus $ dhcpRequestedHostName $ dhcpAssignedHostName $ + dhcpReservedForClient $ dhcpAssignedToClient $ + dhcpRelayAgentInfo $ dhcpHWAddress $ dhcpErrorLog) + X-NDS_CONTAINMENT ('dhcpLeases' 'dhcpPool' 'dhcpSubnet' + 'dhcpSharedNetwork' 'dhcpService' ) ) + +objectclass ( 2.16.840.1.113719.1.203.6.12 + NAME 'dhcpServer' + DESC 'DHCP Server Object' + SUP top + MUST (cn $ dhcpServiceDN) + MAY (dhcpVersion $ dhcpImplementation $ dhcpHashBucketAssignment $ dhcpDelayedServiceParameter $ dhcpMaxClientLeadTime $ dhcpFailOverEndpointState $ dhcpStatements) + X-NDS_CONTAINMENT ('o' 'ou' 'dc') ) + diff --git a/dhcp.spec b/dhcp.spec index bd60f82..11cf4e4 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -12,8 +12,11 @@ Summary: DHCP (Dynamic Host Configuration Protocol) server and relay agent Name: dhcp -Version: 3.0.6 -Release: 8%{?dist} +Version: 3.1.0 +Release: 1%{?dist} +# NEVER CHANGE THE EPOCH on this package. The previous maintainer made +# incorrect use of the epoch and that's why it is at 12 now. It should have +# never been used, but it was. So we are stuck with it. Epoch: 12 License: ISC Group: System Environment/Daemons @@ -31,28 +34,29 @@ Source9: linux Source10: Makefile.dist Source11: dhcp4client.h Source12: libdhcp_control.h +Source13: dhcp.schema Patch0: %{name}-3.0.5-Makefile.patch -Patch1: %{name}-3.0.5-warnings.patch -Patch2: %{name}-3.0.5-errwarn-message.patch -Patch3: %{name}-3.0.5-ldap-configuration.patch -Patch4: %{name}-3.0.6-memory.patch -Patch5: %{name}-3.0.6-options.patch -Patch6: %{name}-3.0.5-release-by-ifup.patch -Patch7: %{name}-3.0.5-dhclient-decline-backoff.patch -Patch8: %{name}-3.0.5-enable-timeout-functions.patch -Patch9: %{name}-3.0.5-inherit-leases.patch -Patch10: %{name}-3.0.5-unicast-bootp.patch -Patch11: %{name}-3.0.5-fast-timeout.patch -Patch12: %{name}-3.0.5-failover-ports.patch -Patch13: %{name}-3.0.6-dhclient-usage.patch -Patch14: %{name}-3.0.5-default-requested-options.patch -Patch15: %{name}-3.0.5-prototypes.patch -Patch16: %{name}-3.0.6-manpages.patch -Patch17: %{name}-3.0.6-libdhcp4client.patch -Patch18: %{name}-3.0.6-xen-checksum.patch -Patch19: %{name}-3.0.5-dhclient-anycast.patch -Patch20: %{name}-3.0.6-ignore-hyphen-x.patch +Patch1: %{name}-3.0.5-errwarn-message.patch +Patch2: %{name}-3.1.0-ldap-configuration.patch +Patch3: %{name}-3.0.6-memory.patch +Patch4: %{name}-3.1.0-options.patch +Patch5: %{name}-3.0.5-release-by-ifup.patch +Patch6: %{name}-3.0.5-dhclient-decline-backoff.patch +Patch7: %{name}-3.0.5-enable-timeout-functions.patch +Patch8: %{name}-3.0.5-inherit-leases.patch +Patch9: %{name}-3.0.5-unicast-bootp.patch +Patch10: %{name}-3.0.5-fast-timeout.patch +Patch11: %{name}-3.0.5-failover-ports.patch +Patch12: %{name}-3.1.0-dhclient-usage.patch +Patch13: %{name}-3.0.5-default-requested-options.patch +Patch14: %{name}-3.0.5-prototypes.patch +Patch15: %{name}-3.0.6-manpages.patch +Patch16: %{name}-3.1.0-libdhcp4client.patch +Patch17: %{name}-3.1.0-xen-checksum.patch +Patch18: %{name}-3.1.0-dhclient-anycast.patch +Patch19: %{name}-3.0.6-ignore-hyphen-x.patch +Patch20: %{name}-3.1.0-warnings.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: groff openldap-devel @@ -148,61 +152,58 @@ libdhcp4client. # Use $(MAKE) and $(CC) in the Makefiles %patch0 -p1 -b .Makefile -# Fix up anything that fails -Wall -Werror -%patch1 -p1 -b .warnings - # Replace the standard ISC warning message about requesting help with an # explanation that this is a patched build of ISC DHCP and bugs should be # reported through bugzilla.redhat.com -%patch2 -p1 -b .message +%patch1 -p1 -b .message # Add support for dhcpd.conf data in LDAP -%patch3 -p1 -b .ldap +%patch2 -p1 -b .ldap # Fix memory alignment and initialization problems in common/packet.c # Fix buffer overflow in minires library # Init struct sock_prog in common/lpf.c to NULL -%patch4 -p1 -b .memory +%patch3 -p1 -b .memory # Add more dhclient options (-I, -B, -H, -F, -T, -V, and -R) -%patch5 -p1 -b .options +%patch4 -p1 -b .options # Handle releasing interfaces requested by /sbin/ifup # pid file is assumed to be /var/run/dhclient-$interface.pid -%patch6 -p1 -b .release +%patch5 -p1 -b .release # If we receive a DHCP offer in dhclient and it's DECLINEd in dhclient-script, # backoff for an amount of time before trying again -%patch7 -p1 -b .decline +%patch6 -p1 -b .decline # Enable cancel_all_timeouts() and relinquish_timeouts() regardless of # the DEBUG_MEMORY_LEAKAGE_ON_EXIT macro -%patch8 -p1 -b .etf +%patch7 -p1 -b .etf # Inherit active leases -%patch9 -p1 -b .inherit +%patch8 -p1 -b .inherit # Support unicast BOOTP for IBM pSeries systems (and maybe others) -%patch10 -p1 -b .unicast +%patch9 -p1 -b .unicast # Fast timeout for dhclient -%patch11 -p1 -b .fast +%patch10 -p1 -b .fast # Use the following IANA-registered failover ports: # dhcp-failover 647/tcp # dhcp-failover 647/udp # dhcp-failover 847/tcp # dhcp-failover 847/udp -%patch12 -p1 -b .failover +%patch11 -p1 -b .failover # Update the usage screen for dhclient(8) indicating new options # Use printf() rather than log_info() to display the information # Also, return EXIT_FAILURE when the usage() screen is displayed (stop parsing) -%patch13 -p1 -b .usage +%patch12 -p1 -b .usage # Add NIS domain, NIS servers, and NTP servers to the list of default # requested DHCP options -%patch14 -p1 -b .dho +%patch13 -p1 -b .dho # Add missing prototypes to take care of gcc warnings # in dst/dst_api.c: add b64_pton() and b64_ntop() @@ -211,7 +212,7 @@ libdhcp4client. # in minires/res_comp.c: add ns_name_uncompress(), ns_name_compress(), and # ns_name_skip() # in minires/res_init.c: add res_randomid() -%patch15 -p1 -b .prototypes +%patch14 -p1 -b .prototypes # Man page updates explaining new features added from the above patches. # Normally these man page changes would be included in the feature patch, @@ -221,19 +222,22 @@ libdhcp4client. # and not affect the code changes in the other patches. It's actually # pretty common to update or alter these man pages independent of the code # changes. -%patch16 -p1 -b .manpages +%patch15 -p1 -b .manpages # Add the libdhcp4client target (library version of dhclient) -%patch17 -p1 -b .libdhcp4client +%patch16 -p1 -b .libdhcp4client # Handle Xen partial UDP checksums -%patch18 -p1 -b .xen +%patch17 -p1 -b .xen # Add anycast support to dhclient (for OLPC) -%patch19 -p1 -b .anycast +%patch18 -p1 -b .anycast # Ignore the old extended new option info command line switch (-x) -%patch20 -p1 -b .enoi +%patch19 -p1 -b .enoi + +# Fix up anything that fails -Wall -Werror +%patch20 -p1 -b .warnings # Copy in documentation and example scripts for LDAP patch to dhcpd %{__install} -p -m 0644 %SOURCE6 . @@ -325,6 +329,10 @@ EOF # Install default (empty) dhcpd.conf: %{__cp} -fp %SOURCE4 %{buildroot}%{_sysconfdir} +# Install dhcp.schema for LDAP configuration +%{__mkdir} -p %{buildroot}%{_sysconfdir}/openldap +%{__install} -p -m 0644 -D %SOURCE13 %{buildroot}%{_sysconfdir}/openldap + %{__install} -p -m 0644 -D libdhcp4client.pc %{buildroot}%{_libdir}/pkgconfig/libdhcp4client.pc # Sources files can't be symlinks for debuginfo package generation @@ -371,6 +379,7 @@ fi %config(noreplace) %{_sysconfdir}/sysconfig/dhcpd %config(noreplace) %{_sysconfdir}/sysconfig/dhcrelay %config(noreplace) %{_sysconfdir}/dhcpd.conf +%config(noreplace) %{_sysconfdir}/openldap/dhcp.schema %{_initrddir}/dhcpd %{_initrddir}/dhcrelay %{_bindir}/omshell @@ -426,6 +435,12 @@ fi %{_libdir}/libdhcp4client.a %changelog +* Tue Oct 23 2007 David Cantrell - 12:3.1.0-1 +- Upgrade to ISC dhcp-3.1.0 +- Remove unnecessary /usr/include/dhcp4client/isc_dhcp headers +- Make sure restorecon is run on /var/lib/dhcpd/dhcpd.leases (#251688) +- Install dhcp.schema to /etc/openldap/dhcp.schema (#330471) + * Mon Oct 08 2007 David Cantrell - 12:3.0.6-8 - Init script fixes (#320761) - Removed linux.dbus-example script since we aren't using dhcdbd now diff --git a/dhcpd.init b/dhcpd.init index 8d50d03..97c6da6 100644 --- a/dhcpd.init +++ b/dhcpd.init @@ -53,7 +53,7 @@ conf="$(findConfig "$DHCPDARGS")" if [ ! -f /var/lib/dhcpd/dhcpd.leases ] ; then mkdir -p /var/lib/dhcpd touch /var/lib/dhcpd/dhcpd.leases - [ -x /sbin/restorecon ] && [ -d /selinux ] && /sbin/restorecon /var/lib/dhcp/dhcpd.leases >/dev/null 2>&1 + [ -x /sbin/restorecon ] && [ -d /selinux ] && /sbin/restorecon /var/lib/dhcpd/dhcpd.leases >/dev/null 2>&1 fi configtest() { diff --git a/sources b/sources index b9ed0bb..5df1c2c 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -724bad21ad8b638abadd5fcc07df1a0f dhcp-3.0.6.tar.gz +27d179a3c3fbef576566b456a1168246 dhcp-3.1.0.tar.gz