diff --git a/dhcp-3.0.5-fast-timeout.patch b/dhcp-3.0.5-fast-timeout.patch new file mode 100644 index 0000000..ae23b97 --- /dev/null +++ b/dhcp-3.0.5-fast-timeout.patch @@ -0,0 +1,14 @@ +--- dhcp-3.0.5/client/dhclient.c.fast 2007-03-30 16:22:54.000000000 -0400 ++++ dhcp-3.0.5/client/dhclient.c 2007-03-30 16:26:11.000000000 -0400 +@@ -766,10 +766,7 @@ + do_release (client); + else { + client -> state = S_INIT; +- /* Set up a timeout to start the initialization +- process. */ +- add_timeout (cur_time + random () % 5, +- state_reboot, client, 0, 0); ++ add_timeout (cur_time, state_reboot, client, 0, 0); + } + } + } diff --git a/dhcp-3.0.5-inherit-leases.patch b/dhcp-3.0.5-inherit-leases.patch new file mode 100644 index 0000000..276b150 --- /dev/null +++ b/dhcp-3.0.5-inherit-leases.patch @@ -0,0 +1,17 @@ +--- dhcp-3.0.5/client/dhclient.c.inherit 2007-03-30 16:06:30.000000000 -0400 ++++ dhcp-3.0.5/client/dhclient.c 2007-03-30 16:09:06.000000000 -0400 +@@ -720,6 +720,14 @@ + continue; + script_init (ip -> client, + "PREINIT", (struct string_list *)0); ++ /* Has an active lease */ ++ if (ip->client->active && ++ !ip->client->active->is_bootp && ++ ip->client->active->expiry > cur_time && ++ ip->primary_address.s_addr != 0 && ++ ip->client->active->address.len == 4 && ++ memcmp(ip->client->active->address.iabuf, &ip->primary_address, 4) == 0) ++ client_envadd(ip->client, "", "keep_old_ip", "%s", "yes"); + if (ip -> client -> alias) + script_write_params (ip -> client, "alias_", + ip -> client -> alias); diff --git a/dhcp-3.0.5-prototypes.patch b/dhcp-3.0.5-prototypes.patch new file mode 100644 index 0000000..4896e6d --- /dev/null +++ b/dhcp-3.0.5-prototypes.patch @@ -0,0 +1,73 @@ +--- dhcp-3.0.5/dst/dst_api.c.prototypes 2007-04-01 16:29:10.000000000 -0400 ++++ dhcp-3.0.5/dst/dst_api.c 2007-04-01 16:29:10.000000000 -0400 +@@ -58,6 +58,10 @@ + + #include "dst_internal.h" + ++/* prototypes */ ++extern int b64_pton(char const *src, u_char *target, size_t targsize); ++extern int b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize); ++ + /* static variables */ + static int done_init = 0; + dst_func *dst_t_func[DST_MAX_ALGS]; +--- dhcp-3.0.5/dst/dst_support.c.prototypes 2001-02-22 02:22:08.000000000 -0500 ++++ dhcp-3.0.5/dst/dst_support.c 2007-04-01 16:29:10.000000000 -0400 +@@ -32,6 +32,10 @@ + + #include "dst_internal.h" + ++/* prototypes */ ++extern int b64_pton(char const *src, u_char *target, size_t targsize); ++extern int b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize); ++ + /* + * dst_s_conv_bignum_u8_to_b64 + * This function converts binary data stored as a u_char[] to a +--- dhcp-3.0.5/includes/minires/minires.h.prototypes 2004-06-10 13:59:37.000000000 -0400 ++++ dhcp-3.0.5/includes/minires/minires.h 2007-04-01 16:29:10.000000000 -0400 +@@ -65,7 +65,6 @@ + #define res_protocolname MRres_protocolname + #define res_servicename MRres_servicename + #define ns_datetosecs MRns_datetosecs +-#define b64_pton MRb64_pton + #define res_ninit minires_ninit + #define res_randomid MRres_randomid + #define res_findzonecut MRres_findzonecut +--- dhcp-3.0.5/minires/res_mkupdate.c.prototypes 2007-04-01 16:29:10.000000000 -0400 ++++ dhcp-3.0.5/minires/res_mkupdate.c 2007-04-01 16:30:12.000000000 -0400 +@@ -49,6 +49,10 @@ + #include "minires/minires.h" + #include "arpa/nameser.h" + ++/* prototypes */ ++extern int b64_pton(char const *src, u_char *target, size_t targsize); ++int dn_comp(const char *src, u_char *dst, unsigned dstsiz, u_char **dnptrs, u_char **lastdnptr); ++ + /* Options. Leave them on. */ + #define DEBUG + #define MAXPORT 1024 +--- dhcp-3.0.5/minires/res_comp.c.prototypes 2004-06-10 13:59:42.000000000 -0400 ++++ dhcp-3.0.5/minires/res_comp.c 2007-04-01 16:31:02.000000000 -0400 +@@ -91,6 +91,11 @@ + #include "minires/minires.h" + #include "arpa/nameser.h" + ++/* prototypes */ ++int ns_name_uncompress(const u_char *msg, const u_char *eom, const u_char *src, char *dst, size_t dstsiz); ++int ns_name_compress(const char *src, u_char *dst, size_t dstsiz, const u_char **dnptrs, const u_char **lastdnptr); ++int ns_name_skip(const u_char **ptrptr, const u_char *eom); ++ + /* + * Expand compressed domain name 'comp_dn' to full domain name. + * 'msg' is a pointer to the begining of the message, +--- dhcp-3.0.5/minires/res_init.c.prototypes 2004-06-10 13:59:43.000000000 -0400 ++++ dhcp-3.0.5/minires/res_init.c 2007-04-01 16:31:38.000000000 -0400 +@@ -102,6 +102,7 @@ + #define DEBUG + + static void res_setoptions (res_state, const char *, const char *); ++u_int res_randomid(void); + + #ifdef RESOLVSORT + static const char sort_mask[] = "/&"; diff --git a/dhcp-3.0.5-release-by-ifup.patch b/dhcp-3.0.5-release-by-ifup.patch new file mode 100644 index 0000000..2091b42 --- /dev/null +++ b/dhcp-3.0.5-release-by-ifup.patch @@ -0,0 +1,84 @@ +--- dhcp-3.0.5/client/dhclient.c.release 2007-03-30 15:30:14.000000000 -0400 ++++ dhcp-3.0.5/client/dhclient.c 2007-03-30 15:29:58.000000000 -0400 +@@ -366,9 +366,81 @@ + } + } + fclose(pidfd); ++ } else { ++ /* handle release for interfaces requested with Red Hat ++ * /sbin/ifup - pidfile will be /var/run/dhclient-$interface.pid ++ */ ++ ++ if ((path_dhclient_pid == NULL) || (*path_dhclient_pid == '\0')) ++ path_dhclient_pid = "/var/run/dhclient.pid"; ++ ++ char *new_path_dhclient_pid; ++ struct interface_info *ip; ++ int pdp_len = strlen(path_dhclient_pid), pfx, dpfx; ++ ++ /* find append point: beginning of any trailing '.pid' ++ * or '-$IF.pid' */ ++ for (pfx=pdp_len; (pfx >= 0) && (path_dhclient_pid[pfx] != '.') && (path_dhclient_pid[pfx] != '/'); pfx--); ++ if (pfx == -1) ++ pfx = pdp_len; ++ ++ if (path_dhclient_pid[pfx] == '/') ++ pfx += 1; ++ ++ for (dpfx=pfx; (dpfx >= 0) && (path_dhclient_pid[dpfx] != '-') && (path_dhclient_pid[dpfx] != '/'); dpfx--); ++ if ((dpfx > -1) && (path_dhclient_pid[dpfx] != '/')) ++ pfx = dpfx; ++ ++ for (ip = interfaces; ip; ip = ip->next) { ++ if (interfaces_requested && (ip->flags & (INTERFACE_REQUESTED)) && (ip->name != NULL)) { ++ int n_len = strlen(ip->name); ++ ++ new_path_dhclient_pid = (char*) malloc(pfx + n_len + 6); ++ strncpy(new_path_dhclient_pid, path_dhclient_pid, pfx); ++ sprintf(new_path_dhclient_pid + pfx, "-%s.pid", ip->name); ++ ++ if ((pidfd = fopen(new_path_dhclient_pid, "r")) != NULL) { ++ e = fscanf(pidfd, "%ld\n", &temp); ++ oldpid = (pid_t)temp; ++ ++ if (e != 0 && e != EOF) { ++ if (oldpid) { ++ if (kill(oldpid, SIGTERM) == 0) ++ unlink(path_dhclient_pid); ++ } ++ } ++ ++ fclose(pidfd); ++ } ++ ++ free(new_path_dhclient_pid); ++ } ++ } ++ } ++ } else { ++ FILE *pidfp = NULL; ++ long temp = 0; ++ pid_t dhcpid = 0; ++ int dhc_running = 0; ++ char procfn[256] = ""; ++ ++ if ((pidfp = fopen(path_dhclient_pid, "r")) != NULL) { ++ if ((fscanf(pidfp, "%ld", &temp)==1) && ((dhcpid=(pid_t)temp) > 0)) { ++ snprintf(procfn,256,"/proc/%u",dhcpid); ++ dhc_running = (access(procfn, F_OK) == 0); ++ } ++ ++ fclose(pidfp); ++ } ++ ++ if (dhc_running) { ++ log_fatal("dhclient(%u) is already running - exiting. ", dhcpid); ++ return(1); + } + } + ++ write_client_pid_file(); ++ + if (!quiet) { + log_info ("%s %s", message, DHCP_VERSION); + log_info (copyright); diff --git a/dhcp-3.0.5-selinux.patch b/dhcp-3.0.5-selinux.patch new file mode 100644 index 0000000..f412b25 --- /dev/null +++ b/dhcp-3.0.5-selinux.patch @@ -0,0 +1,11 @@ +--- dhcp-3.0.5/client/dhclient.c.selinux 2007-03-30 16:11:54.000000000 -0400 ++++ dhcp-3.0.5/client/dhclient.c 2007-03-30 16:12:27.000000000 -0400 +@@ -3009,6 +3009,8 @@ + wstatus = 0; + } + } else { ++ if (leaseFile) ++ fclose(leaseFile); + execve (scriptName, argv, envp); + log_error ("execve (%s, ...): %m", scriptName); + exit (0); diff --git a/dhcp-3.0.5-unicast-bootp.patch b/dhcp-3.0.5-unicast-bootp.patch new file mode 100644 index 0000000..dada189 --- /dev/null +++ b/dhcp-3.0.5-unicast-bootp.patch @@ -0,0 +1,97 @@ +--- dhcp-3.0.5/server/bootp.c.unicast 2005-05-18 15:54:17.000000000 -0400 ++++ dhcp-3.0.5/server/bootp.c 2007-03-30 16:16:00.000000000 -0400 +@@ -62,6 +62,7 @@ + char msgbuf [1024]; + int ignorep; + int peer_has_leases = 0; ++ int norelay = 0; + + if (packet -> raw -> op != BOOTREQUEST) + return; +@@ -77,7 +78,7 @@ + ? inet_ntoa (packet -> raw -> giaddr) + : packet -> interface -> name); + +- if (!locate_network (packet)) { ++ if ((norelay = locate_network (packet)) == 0) { + log_info ("%s: network unknown", msgbuf); + return; + } +@@ -357,6 +358,13 @@ + from, &to, &hto); + goto out; + } ++ } else if (norelay == 2) { ++ to.sin_addr = raw.ciaddr; ++ to.sin_port = remote_port; ++ if (fallback_interface) { ++ result = send_packet (fallback_interface, (struct packet *)0, &raw, outgoing.packet_length, from, &to, &hto); ++ goto out; ++ } + + /* If it comes from a client that already knows its address + and is not requesting a broadcast response, and we can +--- dhcp-3.0.5/server/dhcp.c.unicast 2007-03-30 16:13:36.000000000 -0400 ++++ dhcp-3.0.5/server/dhcp.c 2007-03-30 16:19:35.000000000 -0400 +@@ -3817,6 +3817,7 @@ + struct data_string data; + struct subnet *subnet = (struct subnet *)0; + struct option_cache *oc; ++ int norelay = 0; + + /* See if there's a subnet selection option. */ + oc = lookup_option (&dhcp_universe, packet -> options, +@@ -3826,12 +3827,24 @@ + from the interface, if there is one. If not, fail. */ + if (!oc && !packet -> raw -> giaddr.s_addr) { + if (packet -> interface -> shared_network) { +- shared_network_reference +- (&packet -> shared_network, +- packet -> interface -> shared_network, MDL); +- return 1; ++ struct in_addr any_addr; ++ any_addr.s_addr = INADDR_ANY; ++ ++ if (!packet -> packet_type && memcmp(&packet -> raw -> ciaddr, &any_addr, 4)) { ++ struct iaddr cip; ++ memcpy(cip.iabuf, &packet -> raw -> ciaddr, 4); ++ cip.len = 4; ++ if (!find_grouped_subnet(&subnet, packet->interface->shared_network, cip, MDL)) ++ norelay = 2; ++ } ++ ++ if (!norelay) { ++ shared_network_reference(&packet -> shared_network, packet -> interface -> shared_network, MDL); ++ return 1; ++ } ++ } else { ++ return 0; + } +- return 0; + } + + /* If there's an SSO, and it's valid, use it to figure out the +@@ -3853,7 +3866,10 @@ + data_string_forget (&data, MDL); + } else { + ia.len = 4; +- memcpy (ia.iabuf, &packet -> raw -> giaddr, 4); ++ if (norelay) ++ memcpy (ia.iabuf, &packet->raw->ciaddr, 4); ++ else ++ memcpy (ia.iabuf, &packet->raw->giaddr, 4); + } + + /* If we know the subnet on which the IP address lives, use it. */ +@@ -3861,7 +3877,10 @@ + shared_network_reference (&packet -> shared_network, + subnet -> shared_network, MDL); + subnet_dereference (&subnet, MDL); +- return 1; ++ if (norelay) ++ return norelay; ++ else ++ return 1; + } + + /* Otherwise, fail. */ diff --git a/dhcp-3.0.6-ignore-hyphen-x.patch b/dhcp-3.0.6-ignore-hyphen-x.patch new file mode 100644 index 0000000..a8f5168 --- /dev/null +++ b/dhcp-3.0.6-ignore-hyphen-x.patch @@ -0,0 +1,13 @@ +diff -up dhcp-3.0.6/client/dhclient.c.enoi dhcp-3.0.6/client/dhclient.c +--- dhcp-3.0.6/client/dhclient.c.enoi 2007-08-15 16:14:32.000000000 -0400 ++++ dhcp-3.0.6/client/dhclient.c 2007-08-15 16:17:17.000000000 -0400 +@@ -259,6 +259,9 @@ 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], "-x")) { ++ /* ignored for compatibility */ ++ continue; + } else if (!strcmp (argv [i], "-I")) { + if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) { + usage (); diff --git a/dhcp-3.0.6-memory.patch b/dhcp-3.0.6-memory.patch new file mode 100644 index 0000000..c08a429 --- /dev/null +++ b/dhcp-3.0.6-memory.patch @@ -0,0 +1,37 @@ +diff -up dhcp-3.0.6/minires/ns_name.c.memory dhcp-3.0.6/minires/ns_name.c +--- dhcp-3.0.6/minires/ns_name.c.memory 2004-06-10 13:59:40.000000000 -0400 ++++ dhcp-3.0.6/minires/ns_name.c 2007-07-10 11:43:29.000000000 -0400 +@@ -71,6 +71,11 @@ ns_name_ntop(const u_char *src, char *ds + dn = dst; + eom = dst + dstsiz; + ++ if (dn >= eom) { ++ errno = EMSGSIZE; ++ return (-1); ++ } ++ + while ((n = *cp++) != 0) { + if ((n & NS_CMPRSFLGS) != 0) { + /* Some kind of compression pointer. */ +diff -up dhcp-3.0.6/common/packet.c.memory dhcp-3.0.6/common/packet.c +--- dhcp-3.0.6/common/packet.c.memory 2007-05-01 16:42:55.000000000 -0400 ++++ dhcp-3.0.6/common/packet.c 2007-07-10 11:43:29.000000000 -0400 +@@ -140,6 +140,7 @@ void assemble_udp_ip_header (interface, + struct ip ip; + struct udphdr udp; + ++ memset( &ip, '\0', sizeof ip); + /* Fill out the IP header */ + IP_V_SET (&ip, 4); + IP_HL_SET (&ip, 20); +diff -up dhcp-3.0.6/common/lpf.c.memory dhcp-3.0.6/common/lpf.c +--- dhcp-3.0.6/common/lpf.c.memory 2007-07-10 11:43:29.000000000 -0400 ++++ dhcp-3.0.6/common/lpf.c 2007-07-10 11:43:29.000000000 -0400 +@@ -246,6 +246,7 @@ static void lpf_tr_filter_setup (info) + struct interface_info *info; + { + struct sock_fprog p; ++ memset(&p,'\0', sizeof(struct sock_fprog)); + + /* Set up the bpf filter program structure. This is defined in + bpf.c */ 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..137a8fc --- /dev/null +++ b/dhcp-3.1.0-ldap-configuration.patch @@ -0,0 +1,2724 @@ +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-11-12 15:41:15.000000000 -0500 +@@ -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 /dev/null dhcp-3.1.0/server/ldap_casa.c +--- /dev/null 2007-11-12 10:55:50.854093917 -0500 ++++ dhcp-3.1.0/server/ldap_casa.c 2007-11-12 15:41:15.000000000 -0500 +@@ -0,0 +1,138 @@ ++/* ldap_casa.c ++ ++ CASA routines for DHCPD... */ ++ ++/* Copyright (c) 2004 Internet Systems Consorium, Inc. ("ISC") ++ * Copyright (c) 1995-2003 Internet Software Consortium. ++ * Copyright (c) 2006 Novell, 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 ISC, ISC DHCP, 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 INTERNET SYSTEMS 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 ISC 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 file was written by S Kalyanasundaram ++ */ ++ ++#if defined(LDAP_CASA_AUTH) ++#include "ldap_casa.h" ++#include "dhcpd.h" ++ ++int ++load_casa (void) ++{ ++ if( !(casaIDK = dlopen(MICASA_LIB,RTLD_LAZY))) ++ return 0; ++ p_miCASAGetCredential = (CASA_GetCredential_T) dlsym(casaIDK, "miCASAGetCredential"); ++ p_miCASASetCredential = (CASA_SetCredential_T) dlsym(casaIDK, "miCASASetCredential"); ++ p_miCASARemoveCredential = (CASA_RemoveCredential_T) dlsym(casaIDK, "miCASARemoveCredential"); ++ ++ if((p_miCASAGetCredential == NULL) || ++ (p_miCASASetCredential == NULL) || ++ (p_miCASARemoveCredential == NULL)) ++ { ++ if(casaIDK) ++ dlclose(casaIDK); ++ casaIDK = NULL; ++ p_miCASAGetCredential = NULL; ++ p_miCASASetCredential = NULL; ++ p_miCASARemoveCredential = NULL; ++ return 0; ++ } ++ else ++ return 1; ++} ++ ++static void ++release_casa(void) ++{ ++ if(casaIDK) ++ { ++ dlclose(casaIDK); ++ casaIDK = NULL; ++ } ++ ++ p_miCASAGetCredential = NULL; ++ p_miCASASetCredential = NULL; ++ p_miCASARemoveCredential = NULL; ++ ++} ++ ++int ++load_uname_pwd_from_miCASA (char **ldap_username, char **ldap_password) ++ { ++ int result = 0; ++ uint32_t credentialtype = SSCS_CRED_TYPE_SERVER_F; ++ SSCS_BASIC_CREDENTIAL credential; ++ SSCS_SECRET_ID_T applicationSecretId; ++ char *tempVar = NULL; ++ ++ const char applicationName[10] = "dhcp-ldap"; ++ ++ if ( load_casa() ) ++ { ++ memset(&credential, 0, sizeof(SSCS_BASIC_CREDENTIAL)); ++ memset(&applicationSecretId, 0, sizeof(SSCS_SECRET_ID_T)); ++ ++ applicationSecretId.len = strlen(applicationName) + 1; ++ memcpy (applicationSecretId.id, applicationName, applicationSecretId.len); ++ ++ credential.unFlags = USERNAME_TYPE_CN_F; ++ ++ result = p_miCASAGetCredential (0, ++ &applicationSecretId,NULL,&credentialtype, ++ &credential,NULL); ++ ++ if(credential.unLen) ++ { ++ tempVar = dmalloc (credential.unLen + 1, MDL); ++ if (!tempVar) ++ log_fatal ("no memory for ldap_username"); ++ memcpy(tempVar , credential.username, credential.unLen); ++ *ldap_username = tempVar; ++ ++ tempVar = dmalloc (credential.pwordLen + 1, MDL); ++ if (!tempVar) ++ log_fatal ("no memory for ldap_password"); ++ memcpy(tempVar, credential.password, credential.pwordLen); ++ *ldap_password = tempVar; ++ ++#if defined (DEBUG_LDAP) ++ log_info ("Authentication credential taken from CASA"); ++#endif ++ ++ release_casa(); ++ return 1; ++ ++ } ++ else ++ { ++ release_casa(); ++ return 0; ++ } ++ } ++ else ++ return 0; //casa libraries not loaded ++ } ++ ++#endif /* LDAP_CASA_AUTH */ ++ +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-11-12 15:41:15.000000000 -0500 +@@ -25,14 +25,14 @@ + 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 ldap_casa.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 ldap_casa.o + PROG = dhcpd + MAN = dhcpd.8 dhcpd.conf.5 dhcpd.leases.5 + + INCLUDES = -I$(TOP) $(BINDINC) -I$(TOP)/includes +-DHCPLIB = ../common/libdhcp.a $(BINDLIB) ../omapip/libomapi.a ../dst/libdst.a ++DHCPLIB = ../common/libdhcp.a $(BINDLIB) ../omapip/libomapi.a ../dst/libdst-nomd5.a + CFLAGS = $(DEBUG) $(PREDEFINES) $(INCLUDES) $(COPTS) + + all: $(PROG) $(CATMANPAGES) +@@ -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-11-12 15:41:15.000000000 -0500 +@@ -440,6 +440,14 @@ 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); ++#if defined (USE_SSL) ++ add_enumeration (&ldap_ssl_usage_enum); ++ add_enumeration (&ldap_tls_reqcert_enum); ++ add_enumeration (&ldap_tls_crlcheck_enum); ++#endif ++#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-11-12 10:55:50.854093917 -0500 ++++ dhcp-3.1.0/server/ldap.c 2007-11-12 17:31:46.000000000 -0500 +@@ -0,0 +1,2003 @@ ++/* ldap.c ++ ++ Routines for reading the configuration from LDAP */ ++ ++/* ++ * Copyright (c) 2003-2006 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 . Its ++ * development was sponsored by Ntelos, Inc. (www.ntelos.com). ++ */ ++ ++#include "dhcpd.h" ++#include ++ ++#if defined(LDAP_CONFIGURATION) ++ ++#if defined(LDAP_CASA_AUTH) ++#include "ldap_casa.h" ++#endif ++ ++static LDAP * ld = NULL; ++static char *ldap_server = NULL, ++ *ldap_username = NULL, ++ *ldap_password = NULL, ++ *ldap_base_dn = NULL, ++ *ldap_dhcp_server_cn = NULL, ++ *ldap_debug_file = NULL; ++static int ldap_port = LDAP_PORT, ++ ldap_method = LDAP_METHOD_DYNAMIC, ++ ldap_referrals = -1, ++ ldap_debug_fd = -1; ++#if defined (USE_SSL) ++static int ldap_use_ssl = -1, /* try TLS if possible */ ++ ldap_tls_reqcert = -1, ++ ldap_tls_crlcheck = -1; ++static char *ldap_tls_ca_file = NULL, ++ *ldap_tls_ca_dir = NULL, ++ *ldap_tls_cert = NULL, ++ *ldap_tls_key = NULL, ++ *ldap_tls_ciphers = NULL, ++ *ldap_tls_randfile = NULL; ++#endif ++static struct ldap_config_stack *ldap_stack = NULL; ++ ++typedef struct ldap_dn_node { ++ struct ldap_dn_node *next; ++ size_t refs; ++ char *dn; ++} ldap_dn_node; ++ ++static ldap_dn_node *ldap_service_dn_head = NULL; ++static ldap_dn_node *ldap_service_dn_tail = NULL; ++ ++ ++static char * ++x_strncat(char *dst, const char *src, size_t dst_size) ++{ ++ size_t len = strlen(dst); ++ return strncat(dst, src, dst_size > len ? dst_size - len - 1: 0); ++} ++ ++static void ++ldap_parse_class (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **tempbv; ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || ++ tempbv[0] == NULL) ++ { ++ if (tempbv != NULL) ++ ldap_value_free_len (tempbv); ++ ++ return; ++ } ++ ++ x_strncat (cfile->inbuf, "class \"", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, "\" {\n", LDAP_BUFFER_SIZE); ++ ++ item->close_brace = 1; ++ ldap_value_free_len (tempbv); ++} ++ ++ ++static void ++ldap_parse_subclass (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **tempbv, **classdata; ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || ++ tempbv[0] == NULL) ++ { ++ if (tempbv != NULL) ++ ldap_value_free_len (tempbv); ++ ++ return; ++ } ++ ++ if ((classdata = ldap_get_values_len (ld, item->ldent, ++ "dhcpClassData")) == NULL || ++ classdata[0] == NULL) ++ { ++ if (classdata != NULL) ++ ldap_value_free_len (classdata); ++ ldap_value_free_len (tempbv); ++ ++ return; ++ } ++ ++ x_strncat (cfile->inbuf, "subclass ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, classdata[0]->bv_val, LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE); ++ ++ item->close_brace = 1; ++ ldap_value_free_len (tempbv); ++ ldap_value_free_len (classdata); ++} ++ ++ ++static void ++ldap_parse_host (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **tempbv, **hwaddr; ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || ++ tempbv[0] == NULL) ++ { ++ if (tempbv != NULL) ++ ldap_value_free_len (tempbv); ++ ++ return; ++ } ++ ++ hwaddr = ldap_get_values_len (ld, item->ldent, "dhcpHWAddress"); ++ ++ x_strncat (cfile->inbuf, "host ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE); ++ ++ if (hwaddr != NULL && hwaddr[0] != NULL) ++ { ++ x_strncat (cfile->inbuf, " {\nhardware ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, hwaddr[0]->bv_val, LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ ldap_value_free_len (hwaddr); ++ } ++ ++ item->close_brace = 1; ++ ldap_value_free_len (tempbv); ++} ++ ++ ++static void ++ldap_parse_shared_network (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **tempbv; ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || ++ tempbv[0] == NULL) ++ { ++ if (tempbv != NULL) ++ ldap_value_free_len (tempbv); ++ ++ return; ++ } ++ ++ x_strncat (cfile->inbuf, "shared-network \"", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, "\" {\n", LDAP_BUFFER_SIZE); ++ ++ item->close_brace = 1; ++ ldap_value_free_len (tempbv); ++} ++ ++ ++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 **tempbv, **netmaskstr; ++ char netmaskbuf[16]; ++ int i; ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "cn")) == NULL || ++ tempbv[0] == NULL) ++ { ++ if (tempbv != NULL) ++ ldap_value_free_len (tempbv); ++ ++ return; ++ } ++ ++ if ((netmaskstr = ldap_get_values_len (ld, item->ldent, ++ "dhcpNetmask")) == NULL || ++ netmaskstr[0] == NULL) ++ { ++ if (netmaskstr != NULL) ++ ldap_value_free_len (netmaskstr); ++ ldap_value_free_len (tempbv); ++ ++ return; ++ } ++ ++ x_strncat (cfile->inbuf, "subnet ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE); ++ ++ x_strncat (cfile->inbuf, " netmask ", LDAP_BUFFER_SIZE); ++ parse_netmask (strtol (netmaskstr[0]->bv_val, NULL, 10), netmaskbuf); ++ x_strncat (cfile->inbuf, netmaskbuf, LDAP_BUFFER_SIZE); ++ ++ x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE); ++ ++ ldap_value_free_len (tempbv); ++ ldap_value_free_len (netmaskstr); ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "dhcpRange")) != NULL) ++ { ++ for (i=0; tempbv[i] != NULL; i++) ++ { ++ x_strncat (cfile->inbuf, "range", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, tempbv[i]->bv_val, LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ } ++ } ++ ++ item->close_brace = 1; ++} ++ ++ ++static void ++ldap_parse_pool (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **tempbv; ++ int i; ++ ++ x_strncat (cfile->inbuf, "pool {\n", LDAP_BUFFER_SIZE); ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "dhcpRange")) != NULL) ++ { ++ x_strncat (cfile->inbuf, "range", LDAP_BUFFER_SIZE); ++ for (i=0; tempbv[i] != NULL; i++) ++ { ++ x_strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, tempbv[i]->bv_val, LDAP_BUFFER_SIZE); ++ } ++ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ ldap_value_free_len (tempbv); ++ } ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "dhcpPermitList")) != NULL) ++ { ++ for (i=0; tempbv[i] != NULL; i++) ++ { ++ x_strncat (cfile->inbuf, tempbv[i]->bv_val, LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ } ++ ldap_value_free_len (tempbv); ++ } ++ ++ item->close_brace = 1; ++} ++ ++ ++static void ++ldap_parse_group (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ x_strncat (cfile->inbuf, "group {\n", LDAP_BUFFER_SIZE); ++ item->close_brace = 1; ++} ++ ++ ++static void ++ldap_parse_key (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ struct berval **tempbv; ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "cn")) != NULL) ++ { ++ x_strncat (cfile->inbuf, "key ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE); ++ ldap_value_free_len (tempbv); ++ } ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "dhcpKeyAlgorithm")) != NULL) ++ { ++ x_strncat (cfile->inbuf, "algorithm ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ ldap_value_free_len (tempbv); ++ } ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "dhcpKeySecret")) != NULL) ++ { ++ x_strncat (cfile->inbuf, "secret ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ ldap_value_free_len (tempbv); ++ } ++ ++ item->close_brace = 1; ++} ++ ++ ++static void ++ldap_parse_zone (struct ldap_config_stack *item, struct parse *cfile) ++{ ++ char *cnFindStart, *cnFindEnd; ++ struct berval **tempbv; ++ char *keyCn; ++ size_t len; ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "cn")) != NULL) ++ { ++ x_strncat (cfile->inbuf, "zone ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE); ++ ldap_value_free_len (tempbv); ++ } ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "dhcpDnsZoneServer")) != NULL) ++ { ++ x_strncat (cfile->inbuf, "primary ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, tempbv[0]->bv_val, LDAP_BUFFER_SIZE); ++ ++ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ ldap_value_free_len (tempbv); ++ } ++ ++ if ((tempbv = ldap_get_values_len (ld, item->ldent, "dhcpKeyDN")) != NULL) ++ { ++ cnFindStart = strchr(tempbv[0]->bv_val,'='); ++ if (cnFindStart != NULL) ++ cnFindEnd = strchr(++cnFindStart,','); ++ else ++ cnFindEnd = NULL; ++ ++ if (cnFindEnd != NULL && cnFindEnd > cnFindStart) ++ { ++ len = cnFindEnd - cnFindStart; ++ keyCn = dmalloc (len + 1, MDL); ++ } ++ else ++ { ++ len = 0; ++ keyCn = NULL; ++ } ++ ++ if (keyCn != NULL) ++ { ++ strncpy (keyCn, cnFindStart, len); ++ keyCn[len] = '\0'; ++ ++ x_strncat (cfile->inbuf, "key ", LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, keyCn, LDAP_BUFFER_SIZE); ++ x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE); ++ ++ dfree (keyCn, MDL); ++ } ++ ++ ldap_value_free_len (tempbv); ++ } ++ ++ item->close_brace = 1; ++} ++ ++ ++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->next = ldap_stack; ++ ldap_stack = ns; ++} ++ ++ ++static void ++ldap_stop() ++{ ++ struct sigaction old, new; ++ ++ if (ld == NULL) ++ return; ++ ++ /* ++ ** ldap_unbind after a LDAP_SERVER_DOWN result ++ ** causes a SIGPIPE and dhcpd gets terminated, ++ ** since it doesn't handle it... ++ */ ++ ++ new.sa_flags = 0; ++ new.sa_handler = SIG_IGN; ++ sigemptyset (&new.sa_mask); ++ sigaction (SIGPIPE, &new, &old); ++ ++ ldap_unbind_ext_s (ld, NULL, NULL); ++ ld = NULL; ++ ++ sigaction (SIGPIPE, &old, &new); ++} ++ ++ ++static char * ++_do_lookup_dhcp_string_option (struct option_state *options, int option_name) ++{ ++ struct option_cache *oc; ++ struct data_string db; ++ char *ret; ++ ++ memset (&db, 0, sizeof (db)); ++ oc = lookup_option (&server_universe, options, option_name); ++ 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) && ++ db.data != NULL && *db.data != '\0') ++ ++ { ++ ret = dmalloc (db.len + 1, MDL); ++ if (ret == NULL) ++ log_fatal ("no memory for ldap option %d value", option_name); ++ ++ memcpy (ret, db.data, db.len); ++ ret[db.len] = 0; ++ data_string_forget (&db, MDL); ++ } ++ else ++ ret = NULL; ++ ++ return (ret); ++} ++ ++ ++static int ++_do_lookup_dhcp_int_option (struct option_state *options, int option_name) ++{ ++ struct option_cache *oc; ++ struct data_string db; ++ int ret; ++ ++ memset (&db, 0, sizeof (db)); ++ oc = lookup_option (&server_universe, options, option_name); ++ 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) && ++ db.data != NULL && *db.data != '\0') ++ { ++ ret = strtol ((const char *) db.data, NULL, 10); ++ data_string_forget (&db, MDL); ++ } ++ else ++ ret = 0; ++ ++ return (ret); ++} ++ ++ ++static int ++_do_lookup_dhcp_enum_option (struct option_state *options, int option_name) ++{ ++ struct option_cache *oc; ++ struct data_string db; ++ int ret = -1; ++ ++ memset (&db, 0, sizeof (db)); ++ oc = lookup_option (&server_universe, options, option_name); ++ 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) && ++ db.data != NULL && *db.data != '\0') ++ { ++ if (db.len == 1) ++ ret = db.data [0]; ++ else ++ log_fatal ("invalid option name %d", option_name); ++ ++ data_string_forget (&db, MDL); ++ } ++ else ++ ret = 0; ++ ++ return (ret); ++} ++ ++int ++ldap_rebind_cb (LDAP *ld, LDAP_CONST char *url, ber_tag_t request, ber_int_t msgid, void *parms) ++{ ++ int ret; ++ LDAPURLDesc *ldapurl = NULL; ++ char *who = NULL; ++ struct berval creds; ++ ++ log_info("LDAP rebind to '%s'", url); ++ if ((ret = ldap_url_parse(url, &ldapurl)) != LDAP_SUCCESS) ++ { ++ log_error ("Error: Can not parse ldap rebind url '%s': %s", ++ url, ldap_err2string(ret)); ++ return ret; ++ } ++ ++ ++#if defined (USE_SSL) ++ if (strcasecmp(ldapurl->lud_scheme, "ldaps") == 0) ++ { ++ int opt = LDAP_OPT_X_TLS_HARD; ++ if ((ret = ldap_set_option (ld, LDAP_OPT_X_TLS, &opt)) != LDAP_SUCCESS) ++ { ++ log_error ("Error: Cannot init LDAPS session to %s:%d: %s", ++ ldapurl->lud_host, ldapurl->lud_port, ldap_err2string (ret)); ++ return ret; ++ } ++ else ++ { ++ log_info ("LDAPS session successfully enabled to %s", ldap_server); ++ } ++ } ++ else ++ if (strcasecmp(ldapurl->lud_scheme, "ldap") == 0 && ++ ldap_use_ssl != LDAP_SSL_OFF) ++ { ++ if ((ret = ldap_start_tls_s (ld, NULL, NULL)) != LDAP_SUCCESS) ++ { ++ log_error ("Error: Cannot start TLS session to %s:%d: %s", ++ ldapurl->lud_host, ldapurl->lud_port, ldap_err2string (ret)); ++ return ret; ++ } ++ else ++ { ++ log_info ("TLS session successfully started to %s:%d", ++ ldapurl->lud_host, ldapurl->lud_port); ++ } ++ } ++#endif ++ ++ ++ if (ldap_username != NULL || *ldap_username != '\0') ++ { ++ who = ldap_username; ++ creds.bv_val = strdup(ldap_password); ++ creds.bv_len = strlen(ldap_password); ++ } ++ ++ if ((ret = ldap_sasl_bind_s (ld, who, LDAP_SASL_SIMPLE, &creds, ++ NULL, NULL, NULL)) != LDAP_SUCCESS) ++ { ++ log_error ("Error: Cannot login into ldap server %s:%d: %s", ++ ldapurl->lud_host, ldapurl->lud_port, ldap_err2string (ret)); ++ } ++ return ret; ++} ++ ++static void ++ldap_start (void) ++{ ++ struct option_state *options; ++ int ret, version; ++ char *uri = NULL; ++ struct berval creds; ++ ++ 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); ++ ++ ldap_server = _do_lookup_dhcp_string_option (options, SV_LDAP_SERVER); ++ ldap_dhcp_server_cn = _do_lookup_dhcp_string_option (options, ++ SV_LDAP_DHCP_SERVER_CN); ++ ldap_port = _do_lookup_dhcp_int_option (options, SV_LDAP_PORT); ++ ldap_base_dn = _do_lookup_dhcp_string_option (options, SV_LDAP_BASE_DN); ++ ldap_method = _do_lookup_dhcp_enum_option (options, SV_LDAP_METHOD); ++ ldap_debug_file = _do_lookup_dhcp_string_option (options, ++ SV_LDAP_DEBUG_FILE); ++ ldap_referrals = _do_lookup_dhcp_enum_option (options, SV_LDAP_REFERRALS); ++ ++#if defined (USE_SSL) ++ ldap_use_ssl = _do_lookup_dhcp_enum_option (options, SV_LDAP_SSL); ++ if( ldap_use_ssl != LDAP_SSL_OFF) ++ { ++ ldap_tls_reqcert = _do_lookup_dhcp_enum_option (options, SV_LDAP_TLS_REQCERT); ++ ldap_tls_ca_file = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_CA_FILE); ++ ldap_tls_ca_dir = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_CA_DIR); ++ ldap_tls_cert = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_CERT); ++ ldap_tls_key = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_KEY); ++ ldap_tls_crlcheck = _do_lookup_dhcp_enum_option (options, SV_LDAP_TLS_CRLCHECK); ++ ldap_tls_ciphers = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_CIPHERS); ++ ldap_tls_randfile = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_RANDFILE); ++ } ++#endif ++ ++#if defined (LDAP_CASA_AUTH) ++ if (!load_uname_pwd_from_miCASA(&ldap_username,&ldap_password)) ++ { ++#if defined (DEBUG_LDAP) ++ log_info ("Authentication credential taken from file"); ++#endif ++#endif ++ ++ ldap_username = _do_lookup_dhcp_string_option (options, SV_LDAP_USERNAME); ++ ldap_password = _do_lookup_dhcp_string_option (options, SV_LDAP_PASSWORD); ++ ++#if defined (LDAP_CASA_AUTH) ++ } ++#endif ++ ++ option_state_dereference (&options, MDL); ++ } ++ ++ if (ldap_server == NULL || ldap_base_dn == NULL) ++ { ++ log_info ("Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file"); ++ ldap_method = LDAP_METHOD_STATIC; ++ return; ++ } ++ ++ if (ldap_debug_file != NULL && ldap_debug_fd == -1) ++ { ++ if ((ldap_debug_fd = open (ldap_debug_file, O_CREAT | O_TRUNC | O_WRONLY, ++ S_IRUSR | S_IWUSR)) < 0) ++ log_error ("Error opening debug LDAP log file %s: %s", ldap_debug_file, ++ strerror (errno)); ++ } ++ ++#if defined (DEBUG_LDAP) ++ log_info ("Connecting to LDAP server %s:%d", ldap_server, ldap_port); ++#endif ++ ++#if defined (USE_SSL) ++ if (ldap_use_ssl == -1) ++ { ++ /* ++ ** There was no "ldap-ssl" option in dhcpd.conf (also not "off"). ++ ** Let's try, if we can use an anonymous TLS session without to ++ ** verify the server certificate -- if not continue without TLS. ++ */ ++ int opt = LDAP_OPT_X_TLS_ALLOW; ++ if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, ++ &opt)) != LDAP_SUCCESS) ++ { ++ log_error ("Warning: Cannot set LDAP TLS require cert option to 'allow': %s", ++ ldap_err2string (ret)); ++ } ++ } ++ ++ if (ldap_use_ssl != LDAP_SSL_OFF) ++ { ++ if (ldap_tls_reqcert != -1) ++ { ++ if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, ++ &ldap_tls_reqcert)) != LDAP_SUCCESS) ++ { ++ log_error ("Cannot set LDAP TLS require cert option: %s", ++ ldap_err2string (ret)); ++ } ++ } ++ ++ if( ldap_tls_ca_file != NULL) ++ { ++ if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CACERTFILE, ++ ldap_tls_ca_file)) != LDAP_SUCCESS) ++ { ++ log_error ("Cannot set LDAP TLS CA certificate file %s: %s", ++ ldap_tls_ca_file, ldap_err2string (ret)); ++ } ++ } ++ if( ldap_tls_ca_dir != NULL) ++ { ++ if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CACERTDIR, ++ ldap_tls_ca_dir)) != LDAP_SUCCESS) ++ { ++ log_error ("Cannot set LDAP TLS CA certificate dir %s: %s", ++ ldap_tls_ca_dir, ldap_err2string (ret)); ++ } ++ } ++ if( ldap_tls_cert != NULL) ++ { ++ if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CERTFILE, ++ ldap_tls_cert)) != LDAP_SUCCESS) ++ { ++ log_error ("Cannot set LDAP TLS client certificate file %s: %s", ++ ldap_tls_cert, ldap_err2string (ret)); ++ } ++ } ++ if( ldap_tls_key != NULL) ++ { ++ if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_KEYFILE, ++ ldap_tls_key)) != LDAP_SUCCESS) ++ { ++ log_error ("Cannot set LDAP TLS certificate key file %s: %s", ++ ldap_tls_key, ldap_err2string (ret)); ++ } ++ } ++ if( ldap_tls_crlcheck != -1) ++ { ++ int opt = ldap_tls_crlcheck; ++ if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CRLCHECK, ++ &opt)) != LDAP_SUCCESS) ++ { ++ log_error ("Cannot set LDAP TLS crl check option: %s", ++ ldap_err2string (ret)); ++ } ++ } ++ if( ldap_tls_ciphers != NULL) ++ { ++ if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CIPHER_SUITE, ++ ldap_tls_ciphers)) != LDAP_SUCCESS) ++ { ++ log_error ("Cannot set LDAP TLS cipher suite %s: %s", ++ ldap_tls_ciphers, ldap_err2string (ret)); ++ } ++ } ++ if( ldap_tls_randfile != NULL) ++ { ++ if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_RANDOM_FILE, ++ ldap_tls_randfile)) != LDAP_SUCCESS) ++ { ++ log_error ("Cannot set LDAP TLS random file %s: %s", ++ ldap_tls_randfile, ldap_err2string (ret)); ++ } ++ } ++ } ++#endif ++ ++ /* enough for 'ldap://+ + hostname + ':' + port number */ ++ uri = malloc(strlen(ldap_server) + 16); ++ if (uri == NULL) ++ { ++ log_error ("Cannot build ldap init URI %s:%d", ldap_server, ldap_port); ++ return; ++ } ++ ++ sprintf("ldap://%s:%d", ldap_server, ldap_port); ++ ldap_initialize(&ld, uri); ++ ++ if (ld == NULL) ++ { ++ log_error ("Cannot init ldap session to %s:%d", ldap_server, ldap_port); ++ return; ++ } ++ ++ free(uri); ++ ++ version = LDAP_VERSION3; ++ if ((ret = ldap_set_option (ld, LDAP_OPT_PROTOCOL_VERSION, &version)) != LDAP_OPT_SUCCESS) ++ { ++ log_error ("Cannot set LDAP version to %d: %s", version, ++ ldap_err2string (ret)); ++ } ++ ++ if (ldap_referrals != -1) ++ { ++ if ((ret = ldap_set_option (ld, LDAP_OPT_REFERRALS, ldap_referrals ? ++ LDAP_OPT_ON : LDAP_OPT_OFF)) != LDAP_OPT_SUCCESS) ++ { ++ log_error ("Cannot %s LDAP referrals option: %s", ++ (ldap_referrals ? "enable" : "disable"), ++ ldap_err2string (ret)); ++ } ++ } ++ ++ if ((ret = ldap_set_rebind_proc(ld, ldap_rebind_cb, NULL)) != LDAP_SUCCESS) ++ { ++ log_error ("Warning: Cannot set ldap rebind procedure: %s", ++ ldap_err2string (ret)); ++ } ++ ++#if defined (USE_SSL) ++ if (ldap_use_ssl == LDAP_SSL_LDAPS || ++ (ldap_use_ssl == LDAP_SSL_ON && ldap_port == LDAPS_PORT)) ++ { ++ int opt = LDAP_OPT_X_TLS_HARD; ++ if ((ret = ldap_set_option (ld, LDAP_OPT_X_TLS, &opt)) != LDAP_SUCCESS) ++ { ++ log_error ("Error: Cannot init LDAPS session to %s:%d: %s", ++ ldap_server, ldap_port, ldap_err2string (ret)); ++ ldap_stop(); ++ return; ++ } ++ else ++ { ++ log_info ("LDAPS session successfully enabled to %s:%d", ++ ldap_server, ldap_port); ++ } ++ } ++ else if (ldap_use_ssl != LDAP_SSL_OFF) ++ { ++ if ((ret = ldap_start_tls_s (ld, NULL, NULL)) != LDAP_SUCCESS) ++ { ++ log_error ("Error: Cannot start TLS session to %s:%d: %s", ++ ldap_server, ldap_port, ldap_err2string (ret)); ++ ldap_stop(); ++ return; ++ } ++ else ++ { ++ log_info ("TLS session successfully started to %s:%d", ++ ldap_server, ldap_port); ++ } ++ } ++#endif ++ ++ if (ldap_username != NULL && *ldap_username != '\0') ++ { ++ creds.bv_val = strdup(ldap_password); ++ creds.bv_len = strlen(ldap_password); ++ ++ if ((ret == ldap_sasl_bind_s (ld, ldap_username, LDAP_SASL_SIMPLE, ++ &creds, NULL, NULL, NULL)) != LDAP_SUCCESS) ++ { ++ log_error ("Error: Cannot login into ldap server %s:%d: %s", ++ ldap_server, ldap_port, ldap_err2string (ret)); ++ ldap_stop(); ++ return; ++ } ++ } ++ ++#if defined (DEBUG_LDAP) ++ log_info ("Successfully logged into LDAP server %s", ldap_server); ++#endif ++} ++ ++ ++static void ++parse_external_dns (LDAPMessage * ent) ++{ ++ char *search[] = {"dhcpOptionsDN", "dhcpSharedNetworkDN", "dhcpSubnetDN", ++ "dhcpGroupDN", "dhcpHostDN", "dhcpClassesDN", ++ "dhcpPoolDN", NULL}; ++ LDAPMessage * newres, * newent; ++ struct berval **tempbv; ++ int i, j, ret; ++#if defined (DEBUG_LDAP) ++ char *dn; ++ ++ dn = ldap_get_dn (ld, ent); ++ if (dn != NULL) ++ { ++ log_info ("Parsing external DNs for '%s'", dn); ++ ldap_memfree (dn); ++ } ++#endif ++ ++ if (ld == NULL) ++ ldap_start (); ++ if (ld == NULL) ++ return; ++ ++ for (i=0; search[i] != NULL; i++) ++ { ++ if ((tempbv = ldap_get_values_len (ld, ent, search[i])) == NULL) ++ continue; ++ ++ for (j=0; tempbv[j] != NULL; j++) ++ { ++ if (*tempbv[j]->bv_val == '\0') ++ continue; ++ ++ if ((ret = ldap_search_ext_s(ld, tempbv[j]->bv_val, LDAP_SCOPE_BASE, ++ "objectClass=*", NULL, 0, NULL, ++ NULL, NULL, 0, &newres)) != LDAP_SUCCESS) ++ { ++ ldap_value_free_len (tempbv); ++ ldap_stop(); ++ return; ++ } ++ ++#if defined (DEBUG_LDAP) ++ log_info ("Adding contents of subtree '%s' to config stack from '%s' reference", tempbv[j], search[i]); ++#endif ++ for (newent = ldap_first_entry (ld, newres); ++ newent != NULL; ++ newent = ldap_next_entry (ld, newent)) ++ { ++#if defined (DEBUG_LDAP) ++ dn = ldap_get_dn (ld, newent); ++ if (dn != NULL) ++ { ++ log_info ("Adding LDAP result set starting with '%s' to config stack", dn); ++ ldap_memfree (dn); ++ } ++#endif ++ ++ add_to_config_stack (newres, newent); ++ /* don't free newres here */ ++ } ++ } ++ ++ ldap_value_free_len (tempbv); ++ } ++} ++ ++ ++static void ++free_stack_entry (struct ldap_config_stack *item) ++{ ++ struct ldap_config_stack *look_ahead_pointer = item; ++ int may_free_msg = 1; ++ ++ while (look_ahead_pointer->next != NULL) ++ { ++ look_ahead_pointer = look_ahead_pointer->next; ++ if (look_ahead_pointer->res == item->res) ++ { ++ may_free_msg = 0; ++ break; ++ } ++ } ++ ++ if (may_free_msg) ++ ldap_msgfree (item->res); ++ ++ dfree (item, MDL); ++} ++ ++ ++static void ++next_ldap_entry (struct parse *cfile) ++{ ++ struct ldap_config_stack *temp_stack; ++ ++ if (ldap_stack != NULL && ldap_stack->close_brace) ++ { ++ x_strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE); ++ ldap_stack->close_brace = 0; ++ } ++ ++ while (ldap_stack != NULL && ++ (ldap_stack->ldent == NULL || ++ (ldap_stack->ldent = ldap_next_entry (ld, ldap_stack->ldent)) == NULL)) ++ { ++ if (ldap_stack->close_brace) ++ { ++ x_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->close_brace) ++ { ++ x_strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE); ++ ldap_stack->close_brace = 0; ++ } ++} ++ ++ ++static char ++check_statement_end (const char *statement) ++{ ++ char *ptr; ++ ++ if (statement == NULL || *statement == '\0') ++ return ('\0'); ++ ++ /* ++ ** check if it ends with "}", e.g.: ++ ** "zone my.domain. { ... }" ++ ** optionally followed by spaces ++ */ ++ ptr = strrchr (statement, '}'); ++ if (ptr != NULL) ++ { ++ /* skip following white-spaces */ ++ for (++ptr; isspace ((int)*ptr); ptr++); ++ ++ /* check if we reached the end */ ++ if (*ptr == '\0') ++ return ('}'); /* yes, block end */ ++ else ++ return (*ptr); ++ } ++ ++ /* ++ ** this should not happen, but... ++ ** check if it ends with ";", e.g.: ++ ** "authoritative;" ++ ** optionally followed by spaces ++ */ ++ ptr = strrchr (statement, ';'); ++ if (ptr != NULL) ++ { ++ /* skip following white-spaces */ ++ for (++ptr; isspace ((int)*ptr); ptr++); ++ ++ /* check if we reached the end */ ++ if (*ptr == '\0') ++ return (';'); /* ends with a ; */ ++ else ++ return (*ptr); ++ } ++ ++ return ('\0'); ++} ++ ++ ++static isc_result_t ++ldap_parse_entry_options (LDAPMessage *ent, char *buffer, size_t size, ++ int *lease_limit) ++{ ++ struct berval **tempbv; ++ int i; ++ ++ if (ent == NULL || buffer == NULL || size == 0) ++ return (ISC_R_FAILURE); ++ ++ if ((tempbv = ldap_get_values_len (ld, ent, "dhcpStatements")) != NULL) ++ { ++ for (i=0; tempbv[i] != NULL; i++) ++ { ++ if (lease_limit != NULL && ++ strncasecmp ("lease limit ", tempbv[i]->bv_val, 12) == 0) ++ { ++ *lease_limit = (int) strtol ((tempbv[i]->bv_val) + 12, NULL, 10); ++ continue; ++ } ++ ++ x_strncat (buffer, tempbv[i]->bv_val, size); ++ ++ switch((int) check_statement_end (tempbv[i]->bv_val)) ++ { ++ case '}': ++ case ';': ++ x_strncat (buffer, "\n", size); ++ break; ++ default: ++ x_strncat (buffer, ";\n", size); ++ break; ++ } ++ } ++ ldap_value_free_len (tempbv); ++ } ++ ++ if ((tempbv = ldap_get_values_len (ld, ent, "dhcpOption")) != NULL) ++ { ++ for (i=0; tempbv[i] != NULL; i++) ++ { ++ x_strncat (buffer, "option ", size); ++ x_strncat (buffer, tempbv[i]->bv_val, size); ++ switch ((int) check_statement_end (tempbv[i]->bv_val)) ++ { ++ case ';': ++ x_strncat (buffer, "\n", size); ++ break; ++ default: ++ x_strncat (buffer, ";\n", size); ++ break; ++ } ++ } ++ ldap_value_free_len (tempbv); ++ } ++ ++ return (ISC_R_SUCCESS); ++} ++ ++ ++static void ++ldap_generate_config_string (struct parse *cfile) ++{ ++ struct berval **objectClass; ++ char *dn; ++ struct ldap_config_stack *entry; ++ LDAPMessage * ent, * res; ++ int i, ignore, found; ++ int ret; ++ ++ if (ld == NULL) ++ ldap_start (); ++ if (ld == NULL) ++ return; ++ ++ entry = ldap_stack; ++ if ((objectClass = ldap_get_values_len (ld, entry->ldent, ++ "objectClass")) == NULL) ++ return; ++ ++ ignore = 0; ++ found = 1; ++ for (i=0; objectClass[i] != NULL; i++) ++ { ++ if (strcasecmp (objectClass[i]->bv_val, "dhcpSharedNetwork") == 0) ++ ldap_parse_shared_network (entry, cfile); ++ else if (strcasecmp (objectClass[i]->bv_val, "dhcpClass") == 0) ++ ldap_parse_class (entry, cfile); ++ else if (strcasecmp (objectClass[i]->bv_val, "dhcpSubnet") == 0) ++ ldap_parse_subnet (entry, cfile); ++ else if (strcasecmp (objectClass[i]->bv_val, "dhcpPool") == 0) ++ ldap_parse_pool (entry, cfile); ++ else if (strcasecmp (objectClass[i]->bv_val, "dhcpGroup") == 0) ++ ldap_parse_group (entry, cfile); ++ else if (strcasecmp (objectClass[i]->bv_val, "dhcpTSigKey") == 0) ++ ldap_parse_key (entry, cfile); ++ else if (strcasecmp (objectClass[i]->bv_val, "dhcpDnsZone") == 0) ++ ldap_parse_zone (entry, cfile); ++ else if (strcasecmp (objectClass[i]->bv_val, "dhcpHost") == 0) ++ { ++ if (ldap_method == LDAP_METHOD_STATIC) ++ ldap_parse_host (entry, cfile); ++ else ++ { ++ ignore = 1; ++ break; ++ } ++ } ++ else if (strcasecmp (objectClass[i]->bv_val, "dhcpSubClass") == 0) ++ { ++ if (ldap_method == LDAP_METHOD_STATIC) ++ ldap_parse_subclass (entry, cfile); ++ else ++ { ++ ignore = 1; ++ break; ++ } ++ } ++ else ++ found = 0; ++ ++ if (found && cfile->inbuf[0] == '\0') ++ { ++ ignore = 1; ++ break; ++ } ++ } ++ ++ ldap_value_free_len (objectClass); ++ ++ if (ignore) ++ { ++ next_ldap_entry (cfile); ++ return; ++ } ++ ++ ldap_parse_entry_options(entry->ldent, cfile->inbuf, ++ LDAP_BUFFER_SIZE-1, NULL); ++ ++ dn = ldap_get_dn (ld, entry->ldent); ++ ++#if defined(DEBUG_LDAP) ++ if (dn != NULL) ++ log_info ("Found LDAP entry '%s'", dn); ++#endif ++ ++ if (dn == NULL || ++ (ret = ldap_search_ext_s (ld, dn, LDAP_SCOPE_ONELEVEL, ++ "objectClass=*", NULL, 0, NULL, NULL, ++ NULL, 0, &res)) != LDAP_SUCCESS) ++ { ++ if (dn) ++ ldap_memfree (dn); ++ ++ ldap_stop(); ++ return; ++ } ++ ++ ldap_memfree (dn); ++ ++ if ((ent = ldap_first_entry (ld, res)) != NULL) ++ { ++ add_to_config_stack (res, ent); ++ parse_external_dns (entry->ldent); ++ } ++ else ++ { ++ ldap_msgfree (res); ++ parse_external_dns (entry->ldent); ++ next_ldap_entry (cfile); ++ } ++} ++ ++ ++static void ++ldap_close_debug_fd() ++{ ++ if (ldap_debug_fd != -1) ++ { ++ close (ldap_debug_fd); ++ ldap_debug_fd = -1; ++ } ++} ++ ++ ++static void ++ldap_write_debug (const void *buff, size_t size) ++{ ++ if (ldap_debug_fd != -1) ++ { ++ if (write (ldap_debug_fd, buff, size) < 0) ++ { ++ log_error ("Error writing to LDAP debug file %s: %s." ++ " Disabling log file.", ldap_debug_file, ++ strerror (errno)); ++ ldap_close_debug_fd(); ++ } ++ } ++} ++ ++static int ++ldap_read_function (struct parse *cfile) ++{ ++ cfile->inbuf[0] = '\0'; ++ cfile->buflen = 0; ++ ++ while (ldap_stack != NULL && *cfile->inbuf == '\0') ++ ldap_generate_config_string (cfile); ++ ++ if (ldap_stack == NULL && *cfile->inbuf == '\0') ++ return (EOF); ++ ++ cfile->bufix = 1; ++ cfile->buflen = strlen (cfile->inbuf); ++ if (cfile->buflen > 0) ++ ldap_write_debug (cfile->inbuf, cfile->buflen); ++ ++#if defined (DEBUG_LDAP) ++ log_info ("Sending config line '%s'", cfile->inbuf); ++#endif ++ ++ 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) ++ ret = ldap_get_dn (ld, ent); ++ if (ret != NULL) ++ { ++ log_info ("Cannot get cn attribute for LDAP entry %s", ret); ++ ldap_memfree(ret); ++ } ++#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); ++} ++ ++ ++static int ++getfqhostname(char *fqhost, size_t size) ++{ ++#if defined(MAXHOSTNAMELEN) ++ char hname[MAXHOSTNAMELEN]; ++#else ++ char hname[65]; ++#endif ++ struct hostent *hp; ++ ++ if(NULL == fqhost || 1 >= size) ++ return -1; ++ ++ memset(hname, 0, sizeof(hname)); ++ if( gethostname(hname, sizeof(hname)-1)) ++ return -1; ++ ++ if(NULL == (hp = gethostbyname(hname))) ++ return -1; ++ ++ strncpy(fqhost, hp->h_name, size-1); ++ fqhost[size-1] = '\0'; ++ return 0; ++} ++ ++ ++isc_result_t ++ldap_read_config (void) ++{ ++ LDAPMessage * ldres, * hostres, * ent, * hostent; ++ char hfilter[1024], sfilter[1024], fqdn[257]; ++ char *buffer, *hostdn; ++ ldap_dn_node *curr = NULL; ++ struct parse *cfile; ++ struct utsname unme; ++ isc_result_t res; ++ size_t length; ++ int ret, cnt; ++ struct berval **tempbv = NULL; ++ ++ if (ld == NULL) ++ ldap_start (); ++ if (ld == NULL) ++ return (ldap_server == NULL ? ISC_R_SUCCESS : ISC_R_FAILURE); ++ ++ buffer = dmalloc (LDAP_BUFFER_SIZE+1, MDL); ++ if (buffer == NULL) ++ return (ISC_R_FAILURE); ++ ++ cfile = (struct parse *) NULL; ++ res = new_parse (&cfile, -1, buffer, LDAP_BUFFER_SIZE, "LDAP", 0); ++ if (res != ISC_R_SUCCESS) ++ return (res); ++ ++ uname (&unme); ++ if (ldap_dhcp_server_cn != NULL) ++ { ++ snprintf (hfilter, sizeof (hfilter), ++ "(&(objectClass=dhcpServer)(cn=%s))", ldap_dhcp_server_cn); ++ } ++ else ++ { ++ if(0 == getfqhostname(fqdn, sizeof(fqdn))) ++ { ++ snprintf (hfilter, sizeof (hfilter), ++ "(&(objectClass=dhcpServer)(|(cn=%s)(cn=%s)))", ++ unme.nodename, fqdn); ++ } ++ else ++ { ++ snprintf (hfilter, sizeof (hfilter), ++ "(&(objectClass=dhcpServer)(cn=%s))", unme.nodename); ++ } ++ ++ } ++ hostres = NULL; ++ if ((ret = ldap_search_ext_s (ld, ldap_base_dn, LDAP_SCOPE_SUBTREE, ++ hfilter, NULL, 0, NULL, NULL, NULL, 0, ++ &hostres)) != LDAP_SUCCESS) ++ { ++ log_error ("Cannot find host LDAP entry %s %s", ++ ((ldap_dhcp_server_cn == NULL)?(unme.nodename):(ldap_dhcp_server_cn)), hfilter); ++ if(NULL != hostres) ++ ldap_msgfree (hostres); ++ ldap_stop(); ++ return (ISC_R_FAILURE); ++ } ++ ++ if ((hostent = ldap_first_entry (ld, hostres)) == NULL) ++ { ++ log_error ("Error: Cannot find LDAP entry matching %s", hfilter); ++ ldap_msgfree (hostres); ++ ldap_stop(); ++ return (ISC_R_FAILURE); ++ } ++ ++ hostdn = ldap_get_dn (ld, hostent); ++#if defined(DEBUG_LDAP) ++ if (hostdn != NULL) ++ log_info ("Found dhcpServer LDAP entry '%s'", hostdn); ++#endif ++ ++ if (hostdn == NULL || ++ (tempbv = ldap_get_values_len (ld, hostent, "dhcpServiceDN")) == NULL || ++ tempbv[0] == NULL) ++ { ++ log_error ("Error: Cannot find LDAP entry matching %s", hfilter); ++ ++ if (tempbv != NULL) ++ ldap_value_free_len (tempbv); ++ ++ if (hostdn) ++ ldap_memfree (hostdn); ++ ldap_msgfree (hostres); ++ ldap_stop(); ++ return (ISC_R_FAILURE); ++ } ++ ++#if defined(DEBUG_LDAP) ++ log_info ("LDAP: Parsing dhcpServer options '%s' ...", hostdn); ++#endif ++ ++ cfile->inbuf[0] = '\0'; ++ ldap_parse_entry_options(hostent, cfile->inbuf, LDAP_BUFFER_SIZE, NULL); ++ cfile->buflen = strlen (cfile->inbuf); ++ if(cfile->buflen > 0) ++ { ++ ldap_write_debug (cfile->inbuf, cfile->buflen); ++ ++ res = conf_file_subparse (cfile, root_group, ROOT_GROUP); ++ if (res != ISC_R_SUCCESS) ++ { ++ log_error ("LDAP: cannot parse dhcpServer entry '%s'", hostdn); ++ ldap_memfree (hostdn); ++ ldap_stop(); ++ return res; ++ } ++ cfile->inbuf[0] = '\0'; ++ } ++ ldap_msgfree (hostres); ++ ++ /* ++ ** attach ldap (tree) read function now ++ */ ++ cfile->bufix = cfile->buflen = 0; ++ cfile->read_function = ldap_read_function; ++ ++ res = ISC_R_SUCCESS; ++ for (cnt=0; tempbv[cnt] != NULL; cnt++) ++ { ++ snprintf(sfilter, sizeof(sfilter), "(&(objectClass=dhcpService)" ++ "(|(dhcpPrimaryDN=%s)(dhcpSecondaryDN=%s)))", ++ hostdn, hostdn); ++ ldres = NULL; ++ if ((ret = ldap_search_ext_s (ld, tempbv[cnt]->bv_val, LDAP_SCOPE_BASE, ++ sfilter, NULL, 0, NULL, NULL, NULL, ++ 0, &ldres)) != LDAP_SUCCESS) ++ { ++ log_error ("Error searching for dhcpServiceDN '%s': %s. Please update the LDAP entry '%s'", ++ tempbv[cnt]->bv_val, ldap_err2string (ret), hostdn); ++ if(NULL != ldres) ++ ldap_msgfree(ldres); ++ res = ISC_R_FAILURE; ++ break; ++ } ++ ++ if ((ent = ldap_first_entry (ld, ldres)) == NULL) ++ { ++ log_error ("Error: Cannot find dhcpService DN '%s' with primary or secondary server reference. Please update the LDAP server entry '%s'", ++ tempbv[cnt]->bv_val, hostdn); ++ ++ ldap_msgfree(ldres); ++ res = ISC_R_FAILURE; ++ break; ++ } ++ ++ /* ++ ** FIXME: how to free the remembered dn's on exit? ++ ** This should be OK if dmalloc registers the ++ ** memory it allocated and frees it on exit.. ++ */ ++ ++ curr = dmalloc (sizeof (*curr), MDL); ++ if (curr != NULL) ++ { ++ length = strlen (tempbv[cnt]->bv_val); ++ curr->dn = dmalloc (length + 1, MDL); ++ if (curr->dn == NULL) ++ { ++ dfree (curr, MDL); ++ curr = NULL; ++ } ++ else ++ strcpy (curr->dn, tempbv[cnt]->bv_val); ++ } ++ ++ if (curr != NULL) ++ { ++ curr->refs++; ++ ++ /* append to service-dn list */ ++ if (ldap_service_dn_tail != NULL) ++ ldap_service_dn_tail->next = curr; ++ else ++ ldap_service_dn_head = curr; ++ ++ ldap_service_dn_tail = curr; ++ } ++ else ++ log_fatal ("no memory to remember ldap service dn"); ++ ++#if defined (DEBUG_LDAP) ++ log_info ("LDAP: Parsing dhcpService DN '%s' ...", tempbv[cnt]); ++#endif ++ add_to_config_stack (ldres, ent); ++ res = conf_file_subparse (cfile, root_group, ROOT_GROUP); ++ if (res != ISC_R_SUCCESS) ++ { ++ log_error ("LDAP: cannot parse dhcpService entry '%s'", tempbv[cnt]->bv_val); ++ break; ++ } ++ } ++ ++ end_parse (&cfile); ++ ldap_close_debug_fd(); ++ ++ ldap_memfree (hostdn); ++ ldap_value_free_len (tempbv); ++ ++ if (res != ISC_R_SUCCESS) ++ { ++ struct ldap_config_stack *temp_stack; ++ ++ while ((curr = ldap_service_dn_head) != NULL) ++ { ++ ldap_service_dn_head = curr->next; ++ dfree (curr->dn, MDL); ++ dfree (curr, MDL); ++ } ++ ++ ldap_service_dn_tail = NULL; ++ ++ while ((temp_stack = ldap_stack) != NULL) ++ { ++ ldap_stack = temp_stack->next; ++ free_stack_entry (temp_stack); ++ } ++ ++ ldap_stop(); ++ } ++ ++ /* Unbind from ldap immediately after reading config in static mode. */ ++ if (ldap_method == LDAP_METHOD_STATIC) ++ ldap_stop(); ++ ++ 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) ++{ ++ int declaration, lease_limit; ++ char option_buffer[8192]; ++ enum dhcp_token token; ++ struct parse *cfile; ++ isc_result_t res; ++ const char *val; ++ ++ lease_limit = 0; ++ *option_buffer = '\0'; ++ ++ /* This block of code will try to find the parent of the host, and ++ if it is a group object, fetch the options and apply to the host. */ ++ if (type == HOST_DECL) ++ { ++ char *hostdn, *basedn, *temp1, *temp2, filter[1024]; ++ LDAPMessage *groupdn, *entry; ++ int ret; ++ ++ hostdn = ldap_get_dn (ld, ent); ++ if( hostdn != NULL) ++ { ++ basedn = NULL; ++ ++ temp1 = strchr (hostdn, '='); ++ if (temp1 != NULL) ++ temp1 = strchr (++temp1, '='); ++ if (temp1 != NULL) ++ temp2 = strchr (++temp1, ','); ++ else ++ temp2 = NULL; ++ ++ if (temp2 != NULL) ++ { ++ snprintf (filter, sizeof(filter), ++ "(&(cn=%.*s)(objectClass=dhcpGroup))", ++ (int)(temp2 - temp1), temp1); ++ ++ basedn = strchr (temp1, ','); ++ if (basedn != NULL) ++ ++basedn; ++ } ++ ++ if (basedn != NULL && *basedn != '\0') ++ { ++ ret = ldap_search_ext_s (ld, basedn, LDAP_SCOPE_SUBTREE, filter, ++ NULL, 0, NULL, NULL, NULL, 0, &groupdn); ++ if (ret == LDAP_SUCCESS) ++ { ++ if ((entry = ldap_first_entry (ld, groupdn)) != NULL) ++ { ++ res = ldap_parse_entry_options (entry, option_buffer, ++ sizeof(option_buffer) - 1, ++ &lease_limit); ++ if (res != ISC_R_SUCCESS) ++ { ++ /* reset option buffer discarding any results */ ++ *option_buffer = '\0'; ++ lease_limit = 0; ++ } ++ } ++ ldap_msgfree( groupdn); ++ } ++ } ++ ldap_memfree( hostdn); ++ } ++ } ++ ++ res = ldap_parse_entry_options (ent, option_buffer, sizeof(option_buffer) - 1, ++ &lease_limit); ++ if (res != ISC_R_SUCCESS) ++ return (lease_limit); ++ ++ option_buffer[sizeof(option_buffer) - 1] = '\0'; ++ 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[128], *type_str; ++ LDAPMessage * res, *ent; ++ struct host_decl * host; ++ isc_result_t status; ++ ldap_dn_node *curr; ++ int ret; ++ ++ if (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); ++ } ++ ++ /* ++ ** FIXME: It is not guaranteed, that the dhcpHWAddress attribute ++ ** contains _exactly_ "type addr" with one space between! ++ */ ++ snprintf (buf, sizeof (buf), ++ "(&(objectClass=dhcpHost)(dhcpHWAddress=%s %s))", ++ type_str, print_hw_addr (htype, hlen, haddr)); ++ ++ res = ent = NULL; ++ for (curr = ldap_service_dn_head; ++ curr != NULL && *curr->dn != '\0'; ++ curr = curr->next) ++ { ++#if defined (DEBUG_LDAP) ++ log_info ("Searching for %s in LDAP tree %s", buf, curr->dn); ++#endif ++ ret = ldap_search_ext_s (ld, curr->dn, LDAP_SCOPE_SUBTREE, buf, NULL, 0, ++ NULL, NULL, NULL, 0, &res); ++ ++ if(ret == LDAP_SERVER_DOWN) ++ { ++ log_info ("LDAP server was down, trying to reconnect..."); ++ ++ ldap_stop(); ++ ldap_start(); ++ if(ld == NULL) ++ { ++ log_info ("LDAP reconnect failed - try again later..."); ++ return (0); ++ } ++ ++ ret = ldap_search_ext_s (ld, curr->dn, LDAP_SCOPE_SUBTREE, buf, NULL, ++ 0, NULL, NULL, NULL, 0, &res); ++ } ++ ++ if (ret == LDAP_SUCCESS) ++ { ++ if( (ent = ldap_first_entry (ld, res)) != NULL) ++ break; /* search OK and have entry */ ++ ++#if defined (DEBUG_LDAP) ++ log_info ("No host entry for %s in LDAP tree %s", ++ buf, curr->dn); ++#endif ++ if(res) ++ { ++ ldap_msgfree (res); ++ res = NULL; ++ } ++ } ++ else ++ { ++ if(res) ++ { ++ ldap_msgfree (res); ++ res = NULL; ++ } ++ ++ if (ret != LDAP_NO_SUCH_OBJECT && ret != LDAP_SUCCESS) ++ { ++ log_error ("Cannot search for %s in LDAP tree %s: %s", buf, ++ curr->dn, ldap_err2string (ret)); ++ ldap_stop(); ++ return (0); ++ } ++#if defined (DEBUG_LDAP) ++ else ++ { ++ log_info ("ldap_search_ext_s returned %s when searching for %s in %s", ++ ldap_err2string (ret), buf, curr->dn); ++ } ++#endif ++ } ++ } ++ ++ if (res && ent) ++ { ++#if defined (DEBUG_LDAP) ++ char *dn = ldap_get_dn (ld, ent); ++ if (dn != NULL) ++ { ++ log_info ("Found dhcpHWAddress LDAP entry %s", dn); ++ ldap_memfree(dn); ++ } ++#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)); ++ ldap_msgfree (res); ++ 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); ++ ldap_msgfree (res); ++ return (0); ++ } ++ ++ ldap_parse_options (ent, host->group, HOST_DECL, host, NULL); ++ ++ *hp = host; ++ ldap_msgfree (res); ++ return (1); ++ } ++ ++ ++ if(res) 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; ++ ldap_dn_node *curr; ++ char buf[1024]; ++ ++ if (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), (u_int8_t *) class->name, 60)); ++#if defined (DEBUG_LDAP) ++ log_info ("Searching LDAP for %s", buf); ++#endif ++ ++ res = ent = NULL; ++ for (curr = ldap_service_dn_head; ++ curr != NULL && *curr->dn != '\0'; ++ curr = curr->next) ++ { ++#if defined (DEBUG_LDAP) ++ log_info ("Searching for %s in LDAP tree %s", buf, curr->dn); ++#endif ++ ret = ldap_search_ext_s (ld, curr->dn, LDAP_SCOPE_SUBTREE, buf, NULL, 0, ++ NULL, NULL, NULL, 0, &res); ++ ++ if(ret == LDAP_SERVER_DOWN) ++ { ++ log_info ("LDAP server was down, trying to reconnect..."); ++ ++ ldap_stop(); ++ ldap_start(); ++ ++ if(ld == NULL) ++ { ++ log_info ("LDAP reconnect failed - try again later..."); ++ return (0); ++ } ++ ++ ret = ldap_search_ext_s (ld, curr->dn, LDAP_SCOPE_SUBTREE, buf, ++ NULL, 0, NULL, NULL, NULL, 0, &res); ++ } ++ ++ if (ret == LDAP_SUCCESS) ++ { ++ if( (ent = ldap_first_entry (ld, res)) != NULL) ++ break; /* search OK and have entry */ ++ ++#if defined (DEBUG_LDAP) ++ log_info ("No subclass entry for %s in LDAP tree %s", ++ buf, curr->dn); ++#endif ++ if(res) ++ { ++ ldap_msgfree (res); ++ res = NULL; ++ } ++ } ++ else ++ { ++ if(res) ++ { ++ ldap_msgfree (res); ++ res = NULL; ++ } ++ ++ if (ret != LDAP_NO_SUCH_OBJECT && ret != LDAP_SUCCESS) ++ { ++ log_error ("Cannot search for %s in LDAP tree %s: %s", buf, ++ curr->dn, ldap_err2string (ret)); ++ ldap_stop(); ++ return (0); ++ } ++#if defined (DEBUG_LDAP) ++ else ++ { ++ log_info ("ldap_search_ext_s returned %s when searching for %s in %s", ++ ldap_err2string (ret), buf, curr->dn); ++ } ++#endif ++ } ++ } ++ ++ if (res && ent) ++ { ++#if defined (DEBUG_LDAP) ++ char *dn = ldap_get_dn (ld, ent); ++ if (dn != NULL) ++ { ++ log_info ("Found subclass LDAP entry %s", dn); ++ ldap_memfree(dn); ++ } ++#endif ++ ++ status = class_allocate (newclass, MDL); ++ if (status != ISC_R_SUCCESS) ++ { ++ log_error ("Cannot allocate memory for a new class"); ++ ldap_msgfree (res); ++ 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); ++ ldap_msgfree (res); ++ 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); ++ } ++ ++ if(res) 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-11-12 15:41:15.000000000 -0500 +@@ -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-11-12 15:41:15.000000000 -0500 +@@ -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-11-12 15:41:15.000000000 -0500 +@@ -238,9 +238,107 @@ 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 }, ++ { "ldap-debug-file", "t", &server_universe, 59 }, ++ { "ldap-dhcp-server-cn", "t", &server_universe, 60 }, ++ { "ldap-referrals", "f", &server_universe, 61 }, ++#if defined(USE_SSL) ++ { "ldap-ssl", "Nldap-ssl-usage.", &server_universe, 62 }, ++ { "ldap-tls-reqcert", "Nldap-tls-reqcert.", &server_universe, 63 }, ++ { "ldap-tls-ca-file", "t", &server_universe, 64 }, ++ { "ldap-tls-ca-dir", "t", &server_universe, 65 }, ++ { "ldap-tls-cert", "t", &server_universe, 66 }, ++ { "ldap-tls-key", "t", &server_universe, 67 }, ++ { "ldap-tls-crlcheck", "Nldap-tls-crlcheck.", &server_universe, 68 }, ++ { "ldap-tls-ciphers", "t", &server_universe, 69 }, ++ { "ldap-tls-randfile", "t", &server_universe, 70 }, ++#else ++ { "unknown-62", "X", &server_universe, 62 }, ++ { "unknown-63", "X", &server_universe, 63 }, ++ { "unknown-64", "X", &server_universe, 64 }, ++ { "unknown-65", "X", &server_universe, 65 }, ++ { "unknown-66", "X", &server_universe, 66 }, ++ { "unknown-67", "X", &server_universe, 67 }, ++ { "unknown-68", "X", &server_universe, 68 }, ++ { "unknown-69", "X", &server_universe, 69 }, ++ { "unknown-70", "X", &server_universe, 70 }, ++#endif ++#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 }, ++ { "unknown-59", "X", &server_universe, 59 }, ++ { "unknown-60", "X", &server_universe, 60 }, ++ { "unknown-61", "X", &server_universe, 61 }, ++#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 ++}; ++ ++#if defined(USE_SSL) ++struct enumeration_value ldap_ssl_usage_values [] = { ++ { "off", LDAP_SSL_OFF }, ++ { "on",LDAP_SSL_ON }, ++ { "ldaps", LDAP_SSL_LDAPS }, ++ { "start_tls", LDAP_SSL_TLS }, ++ { (char *) 0, 0 } ++}; ++ ++struct enumeration ldap_ssl_usage_enum = { ++ (struct enumeration *)0, ++ "ldap-ssl-usage", ++ ldap_ssl_usage_values ++}; ++ ++struct enumeration_value ldap_tls_reqcert_values [] = { ++ { "never", LDAP_OPT_X_TLS_NEVER }, ++ { "hard", LDAP_OPT_X_TLS_HARD }, ++ { "demand", LDAP_OPT_X_TLS_DEMAND}, ++ { "allow", LDAP_OPT_X_TLS_ALLOW }, ++ { "try", LDAP_OPT_X_TLS_TRY }, ++ { (char *) 0, 0 } ++}; ++struct enumeration ldap_tls_reqcert_enum = { ++ (struct enumeration *)0, ++ "ldap-tls-reqcert", ++ ldap_tls_reqcert_values ++}; ++ ++struct enumeration_value ldap_tls_crlcheck_values [] = { ++ { "none", LDAP_OPT_X_TLS_CRL_NONE}, ++ { "peer", LDAP_OPT_X_TLS_CRL_PEER}, ++ { "all", LDAP_OPT_X_TLS_CRL_ALL }, ++ { (char *) 0, 0 } ++}; ++struct enumeration ldap_tls_crlcheck_enum = { ++ (struct enumeration *)0, ++ "ldap-tls-crlcheck", ++ ldap_tls_crlcheck_values ++}; ++#endif ++#endif ++ + struct enumeration_value ddns_styles_values [] = { + { "none", 0 }, + { "ad-hoc", 1 }, +diff -up dhcp-3.1.0/dst/Makefile.dist.ldap dhcp-3.1.0/dst/Makefile.dist +--- dhcp-3.1.0/dst/Makefile.dist.ldap 2005-03-17 15:15:06.000000000 -0500 ++++ dhcp-3.1.0/dst/Makefile.dist 2007-11-12 15:41:15.000000000 -0500 +@@ -23,12 +23,13 @@ + + SRC = dst_support.c dst_api.c hmac_link.c md5_dgst.c base64.c prandom.c + OBJ = dst_support.o dst_api.o hmac_link.o md5_dgst.o base64.o prandom.o ++OBJ_NM5= dst_support.o dst_api.o hmac_link.o base64.o prandom.o + HDRS = dst_internal.h md5.h md5_locl.h + + INCLUDES = $(BINDINC) -I$(TOP)/includes + CFLAGS = $(DEBUG) $(PREDEFINES) $(INCLUDES) $(COPTS) -DHMAC_MD5 -DMINIRES_LIB + +-all: libdst.a ++all: libdst.a libdst-nomd5.a + + install: + +@@ -37,11 +38,16 @@ libdst.a: $(OBJ) + ar cruv libdst.a $(OBJ) + $(RANLIB) libdst.a + ++libdst-nomd5.a: $(OBJ_NM5) ++ rm -f libdst-nomd5.a ++ ar cruv libdst-nomd5.a $(OBJ_NM5) ++ $(RANLIB) libdst-nomd5.a ++ + depend: + $(MKDEP) $(INCLUDES) $(PREDEFINES) $(SRC) + + clean: +- -rm -f $(OBJ) libdst.a ++ -rm -f $(OBJ) libdst.a libdst-nomd5.a + + realclean: clean + -rm -f *~ $(CATMANPAGES) $(SEDMANPAGES) +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-11-12 15:41:15.000000000 -0500 +@@ -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-11-12 15:41:15.000000000 -0500 +@@ -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-11-12 15:41:15.000000000 -0500 +@@ -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,32 @@ 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 ++#if defined (USE_SSL) ++# define LDAP_SSL_OFF 0 ++# define LDAP_SSL_ON 1 ++# define LDAP_SSL_TLS 2 ++# define LDAP_SSL_LDAPS 3 ++#endif ++ ++/* 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 +591,29 @@ 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 ++# define SV_LDAP_DEBUG_FILE 53 ++# define SV_LDAP_DHCP_SERVER_CN 54 ++# define SV_LDAP_REFERRALS 55 ++#if defined (USE_SSL) ++# define SV_LDAP_SSL 56 ++# define SV_LDAP_TLS_REQCERT 57 ++# define SV_LDAP_TLS_CA_FILE 58 ++# define SV_LDAP_TLS_CA_DIR 59 ++# define SV_LDAP_TLS_CERT 60 ++# define SV_LDAP_TLS_KEY 61 ++# define SV_LDAP_TLS_CRLCHECK 62 ++# define SV_LDAP_TLS_CIPHERS 63 ++# define SV_LDAP_TLS_RANDFILE 64 ++#endif ++#endif ++ + #if !defined (DEFAULT_DEFAULT_LEASE_TIME) + # define DEFAULT_DEFAULT_LEASE_TIME 43200 + #endif +@@ -1702,7 +1758,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 +2868,18 @@ 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; ++#if defined (USE_SSL) ++extern struct enumeration ldap_ssl_usage_enum; ++extern struct enumeration ldap_tls_reqcert_enum; ++extern struct enumeration ldap_tls_crlcheck_enum; ++#endif ++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-11-12 15:41:15.000000000 -0500 +@@ -183,3 +183,18 @@ + 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 this if you want to enable LDAP over a SSL connection. You will need ++ to add -lcrypto -lssl to the LIBS= line of server/Makefile */ ++ ++#define USE_SSL ++ ++#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 -up /dev/null dhcp-3.1.0/includes/ldap_casa.h +--- /dev/null 2007-11-12 10:55:50.854093917 -0500 ++++ dhcp-3.1.0/includes/ldap_casa.h 2007-11-12 15:41:15.000000000 -0500 +@@ -0,0 +1,83 @@ ++/* ldap_casa.h ++ ++ Definition for CASA modules... */ ++ ++/* Copyright (c) 2004 Internet Systems Consorium, Inc. ("ISC") ++ * Copyright (c) 1995-2003 Internet Software Consortium. ++ * Copyright (c) 2006 Novell, 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 ISC, ISC DHCP, 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 INTERNET SYSTEMS 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 ISC 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 file was written by S Kalyanasundaram ++ */ ++ ++#if defined(LDAP_CASA_AUTH) ++#ifndef __LDAP_CASA_H__ ++#define __LDAP_CASA_H__ ++ ++#include ++#include ++#include ++ ++#define MICASA_LIB "libmicasa.so.1" ++ ++SSCS_TYPEDEF_LIBCALL(int, CASA_GetCredential_T) ++( ++ uint32_t ssFlags, ++ SSCS_SECRET_ID_T *appSecretID, ++ SSCS_SECRET_ID_T *sharedSecretID, ++ uint32_t *credentialType, ++ void *credential, ++ SSCS_EXT_T *ext ++); ++SSCS_TYPEDEF_LIBCALL(int, CASA_SetCredential_T) ++( ++ uint32_t ssFlags, ++ SSCS_SECRET_ID_T *appSecretID, ++ SSCS_SECRET_ID_T *sharedSecretID, ++ uint32_t credentialType, ++ void *credential, ++ SSCS_EXT_T *ext ++); ++ ++SSCS_TYPEDEF_LIBCALL(int, CASA_RemoveCredential_T) ++( ++ uint32_t ssFlags, ++ SSCS_SECRET_ID_T *appSecretID, ++ SSCS_SECRET_ID_T *sharedSecretID, ++ SSCS_EXT_T *ext ++); ++static CASA_GetCredential_T p_miCASAGetCredential = NULL; ++static CASA_SetCredential_T p_miCASASetCredential = NULL; ++static CASA_RemoveCredential_T p_miCASARemoveCredential = NULL; ++static void *casaIDK = NULL; ++ ++int load_casa(void); ++static void release_casa(void); ++int load_uname_pwd_from_miCASA(char **, char **); ++ ++#endif /* __LDAP_CASA_H__ */ ++#endif /* LDAP_CASA_AUTH */ ++ 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 new file mode 100644 index 0000000..13b6f7f --- /dev/null +++ b/dhcp-3.1.0-warnings.patch @@ -0,0 +1,2631 @@ +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 14:33:17.000000000 -0400 +@@ -739,7 +739,7 @@ int add_relay_agent_options (ip, packet, + 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; + +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 14:33:17.000000000 -0400 +@@ -101,7 +101,6 @@ dhcpctl_status dhcpctl_connect (dhcpctl_ + 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 @@ dhcpctl_status dhcpctl_get_value (dhcpct + { + 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 @@ dhcpctl_status dhcpctl_set_value (dhcpct + 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 @@ dhcpctl_status dhcpctl_set_string_value + 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 @@ dhcpctl_status dhcpctl_set_boolean_value + 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 @@ dhcpctl_status dhcpctl_set_int_value (dh + 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) +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 14:33:17.000000000 -0400 +@@ -60,9 +60,8 @@ int main (argc, argv) + 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; +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 14:33:17.000000000 -0400 +@@ -354,8 +354,6 @@ isc_result_t dhcpctl_remote_stuff_values + omapi_object_t *id, + omapi_object_t *p) + { +- int i; +- + if (p -> type != dhcpctl_remote_type) + return ISC_R_INVALIDARG; + +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 14:33:17.000000000 -0400 +@@ -59,7 +59,6 @@ dhcpctl_status dhcpctl_set_callback (dhc + { + dhcpctl_callback_object_t *callback; + omapi_object_t *inner; +- isc_result_t status; + + callback = dmalloc (sizeof *callback, MDL); + if (!callback) +@@ -162,8 +161,6 @@ isc_result_t dhcpctl_callback_stuff_valu + omapi_object_t *id, + omapi_object_t *p) + { +- int i; +- + if (p -> type != dhcpctl_callback_type) + return ISC_R_INVALIDARG; + +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 14:33:17.000000000 -0400 +@@ -82,11 +82,9 @@ int main (int argc, char **argv, char ** + 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 @@ int main (int argc, char **argv, char ** + val = buf; + do { + int intval = atoi (val); +- dotiszero: + if (intval > 255) { + parse_warn (cfile, + "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 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) + { +- int i; +- + omapi_message_object_t *m; + if (h -> type != omapi_type_message) + return ISC_R_INVALIDARG; +@@ -261,8 +259,6 @@ isc_result_t omapi_message_stuff_values + omapi_object_t *id, + omapi_object_t *m) + { +- int i; +- + if (m -> type != omapi_type_message) + 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 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; + unsigned len; +- int i; + VOIDPTR *bar; + #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \ + 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 14:33:17.000000000 -0400 +@@ -111,10 +111,6 @@ isc_result_t omapi_connect_list (omapi_o + 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 @@ isc_result_t omapi_connection_stuff_valu + omapi_object_t *id, + omapi_object_t *m) + { +- int i; +- + if (m -> type != omapi_type_connection) + return ISC_R_INVALIDARG; + +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 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; + isc_result_t status; +- u_int32_t foo; + unsigned auth_len; + + if (po -> type != omapi_type_protocol || +@@ -944,8 +943,6 @@ isc_result_t omapi_protocol_stuff_values + omapi_object_t *id, + omapi_object_t *p) + { +- int i; +- + if (p -> type != omapi_type_protocol) + return ISC_R_INVALIDARG; + +@@ -1132,8 +1129,6 @@ isc_result_t omapi_protocol_listener_stu + omapi_object_t *id, + omapi_object_t *p) + { +- int i; +- + if (p -> type != omapi_type_protocol_listener) + return ISC_R_INVALIDARG; + +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 14:33:17.000000000 -0400 +@@ -68,12 +68,9 @@ isc_result_t omapi_listen_addr (omapi_ob + 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 @@ isc_result_t omapi_accept (omapi_object_ + 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 @@ isc_result_t omapi_accept (omapi_object_ + /* 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 @@ isc_result_t omapi_listener_stuff_values + omapi_object_t *id, + omapi_object_t *l) + { +- int i; +- + if (l -> type != omapi_type_listener) + return ISC_R_INVALIDARG; + +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 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) + { +- int tabix; + isc_result_t status; + + if (o -> handle) { +@@ -285,7 +284,6 @@ static isc_result_t omapi_handle_lookup_ + 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) +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 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) + { +- trace_type_t *ttmp, *tptr; ++ trace_type_t *ttmp; + unsigned slen = strlen (name); + isc_result_t status; + +@@ -518,7 +518,6 @@ isc_result_t trace_get_next_packet (trac + trace_type_t *ttype; + unsigned paylen; + int status; +- int len; + fpos_t curpos; + + status = fgetpos (traceinfile, &curpos); +@@ -644,7 +643,6 @@ time_t trace_snoop_time (trace_type_t ** + unsigned bufmax = 0; + unsigned buflen = 0; + char *buf = (char *)0; +- isc_result_t status; + time_t result; + trace_type_t *ttp; + +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 14:33:17.000000000 -0400 +@@ -438,7 +438,6 @@ isc_result_t omapi_connection_writer (om + 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 @@ isc_result_t omapi_connection_put_uint32 + u_int32_t value) + { + u_int32_t inbuf; +- isc_result_t status; + + inbuf = htonl (value); + +@@ -602,7 +600,6 @@ isc_result_t omapi_connection_put_uint16 + u_int32_t value) + { + u_int16_t inbuf; +- isc_result_t status; + + inbuf = htons (value); + +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 14:33:17.000000000 -0400 +@@ -53,7 +53,6 @@ omapi_object_type_t *omapi_type_auth_key + + 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 (omapi_object_ + 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 @@ isc_result_t omapi_set_value_str (omapi_ + 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 omapi_set_boolean_value (om + 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 omapi_set_int_value (omapi_ + 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 omapi_set_object_value (oma + 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 omapi_set_string_value (oma + 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) +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 14:33:17.000000000 -0400 +@@ -103,8 +103,6 @@ void free_hash_table (tp, file, line) + 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) || \ +@@ -197,7 +195,6 @@ void free_hash_bucket (ptr, file, line) + 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) { +@@ -349,7 +346,7 @@ hash_report(struct hash_table *table) + struct hash_bucket *bp; + + if (table->hash_count == 0) +- return (char *) "Invalid hash table."; ++ return (unsigned char *) "Invalid hash table."; + + for (i = 0 ; i < table->hash_count ; i++) { + curlen = 0; +@@ -378,9 +375,9 @@ hash_report(struct hash_table *table) + pct > 2147483647 || + minlen > 2147483647 || + maxlen > 2147483647) +- return (char *) "Report out of range for display."; ++ return (unsigned char *) "Report out of range for display."; + +- sprintf(retbuf, "Contents/Size (%%): %u/%u (%u%%). Min/max: %u/%u", ++ sprintf((char *)retbuf, "Contents/Size (%%): %u/%u (%u%%). Min/max: %u/%u", + contents, table->hash_count, pct, minlen, maxlen); + + 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 14:33:17.000000000 -0400 +@@ -85,7 +85,6 @@ void trace_mr_statp_setup (res_state sta + unsigned buflen = 0; + char *buf = (char *)0; + isc_result_t status; +- u_int32_t id; + int i; + + if (trace_playback ()) { +@@ -412,7 +411,6 @@ unsigned int trace_mr_res_randomid (unsi + 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."); +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 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; + + do_percentm (fbuf, fmt); +- ++ + #ifdef LIBDHCP + if (libdhcp_control && (libdhcp_control->eh)) { + va_start (list, fmt); +@@ -75,6 +75,7 @@ void log_fatal (const char * fmt, ... ) + return; + } + #else ++ int r; + + /* %Audit% This is log output. %2004.06.17,Safe% + * If we truncate we hope the user can get a hint from the log. +@@ -89,8 +90,8 @@ void log_fatal (const char * fmt, ... ) + + /* Also log it to stderr? */ + if (log_perror) { +- write (STDERR_FILENO, mbuf, strlen (mbuf)); +- write (STDERR_FILENO, "\n", 1); ++ r = write (STDERR_FILENO, mbuf, strlen (mbuf)); ++ r = write (STDERR_FILENO, "\n", 1); + } + + #if !defined (NOMINUM) +@@ -126,6 +127,8 @@ int log_error (const char * fmt, ...) + va_end(list); + } + #else ++ int r; ++ + /* %Audit% This is log output. %2004.06.17,Safe% + * If we truncate we hope the user can get a hint from the log. + */ +@@ -138,8 +141,8 @@ int log_error (const char * fmt, ...) + #endif + + if (log_perror) { +- write (STDERR_FILENO, mbuf, strlen (mbuf)); +- write (STDERR_FILENO, "\n", 1); ++ r = write (STDERR_FILENO, mbuf, strlen (mbuf)); ++ r = write (STDERR_FILENO, "\n", 1); + } + #endif + return 0; +@@ -160,6 +163,8 @@ int log_info (const char *fmt, ...) + va_end(list); + } + #else ++ int r; ++ + /* %Audit% This is log output. %2004.06.17,Safe% + * If we truncate we hope the user can get a hint from the log. + */ +@@ -172,8 +177,8 @@ int log_info (const char *fmt, ...) + #endif + + if (log_perror) { +- write (STDERR_FILENO, mbuf, strlen (mbuf)); +- write (STDERR_FILENO, "\n", 1); ++ r = write (STDERR_FILENO, mbuf, strlen (mbuf)); ++ r = write (STDERR_FILENO, "\n", 1); + } + #endif + return 0; +@@ -193,6 +198,8 @@ int log_debug (const char *fmt, ...) + va_end(list); + } + #else ++ int r; ++ + /* %Audit% This is log output. %2004.06.17,Safe% + * If we truncate we hope the user can get a hint from the log. + */ +@@ -205,8 +212,8 @@ int log_debug (const char *fmt, ...) + #endif + + if (log_perror) { +- write (STDERR_FILENO, mbuf, strlen (mbuf)); +- write (STDERR_FILENO, "\n", 1); ++ r = write (STDERR_FILENO, mbuf, strlen (mbuf)); ++ r = write (STDERR_FILENO, "\n", 1); + } + #endif + 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 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) + { +- isc_result_t status; + omapi_array_t *aptr; + + if (!array || *array) +@@ -63,7 +62,6 @@ isc_result_t omapi_array_allocate (omapi + 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; + +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 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) + { + int i; +- isc_result_t status; + omapi_generic_object_t *g; + + 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 14:33:17.000000000 -0400 +@@ -165,7 +165,7 @@ int binary_to_ascii (outbuf, inbuf, base + 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; +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 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) { + if ((strlen (lease -> client_hostname) <= 64) && +- db_printable (lease -> client_hostname)) ++ db_printable ((unsigned char *) lease -> client_hostname)) + s = lease -> client_hostname; + else + s = "Hostname Unsuitable for Printing"; +@@ -391,7 +391,6 @@ void dhcprequest (packet, ms_nulltp, ip_ + int ours = 0; + struct option_cache *oc; + struct data_string data; +- int status; + char msgbuf [1024]; /* XXX */ + const char *s; + char smbuf [19]; +@@ -430,7 +429,7 @@ void dhcprequest (packet, ms_nulltp, ip_ + + if (lease && lease -> client_hostname) { + if ((strlen (lease -> client_hostname) <= 64) && +- db_printable (lease -> client_hostname)) ++ db_printable ((unsigned char *) lease -> client_hostname)) + s = lease -> client_hostname; + else + s = "Hostname Unsuitable for Printing"; +@@ -733,7 +732,7 @@ void dhcprelease (packet, ms_nulltp) + + if (lease && lease -> client_hostname) { + if ((strlen (lease -> client_hostname) <= 64) && +- db_printable (lease -> client_hostname)) ++ db_printable ((unsigned char *) lease -> client_hostname)) + s = lease -> client_hostname; + else + s = "Hostname Unsuitable for Printing"; +@@ -829,7 +828,7 @@ void dhcpdecline (packet, ms_nulltp) + + if (lease && lease -> client_hostname) { + if ((strlen (lease -> client_hostname) <= 64) && +- db_printable (lease -> client_hostname)) ++ db_printable ((unsigned char *) lease -> client_hostname)) + s = lease -> client_hostname; + else + s = "Hostname Unsuitable for Printing"; +@@ -927,14 +926,13 @@ void dhcpinform (packet, ms_nulltp) + 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; +@@ -1278,9 +1276,7 @@ void nak_lease (packet, cip) + struct packet outgoing; + struct hardware hto; + 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; + + option_state_allocate (&options, MDL); +@@ -1453,17 +1449,13 @@ void ack_lease (packet, lease, offer, wh + 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; + TIME lease_cltt; + struct in_addr from; + + unsigned i, j; +- int s1, s2; +- int val; ++ int s1; + int ignorep; + + /* If we're already acking this lease, don't do it again. */ +@@ -2769,12 +2761,9 @@ void dhcp_reply (lease) + 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) +@@ -2851,7 +2840,7 @@ void dhcp_reply (lease) + + if (lease -> client_hostname) { + if ((strlen (lease -> client_hostname) <= 64) && +- db_printable (lease -> client_hostname)) ++ db_printable ((unsigned char *) lease -> client_hostname)) + s = lease -> client_hostname; + else + s = "Hostname Unsuitable for Printing"; +@@ -2994,7 +2983,6 @@ int find_lease (struct lease **lp, + 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. */ +@@ -3975,7 +3963,7 @@ get_server_source_address(struct in_addr + if (option_cache_allocate(&oc, MDL)) { + a = &packet->interface->primary_address; + if (make_const_data(&oc->expression, +- (char *)a, sizeof(*a), ++ (unsigned char *)a, sizeof(*a), + 0, 0, MDL)) { + 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 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; + struct servent *ent; +- unsigned char *s; ++ char *s; + int cftest = 0; + int lftest = 0; + #ifndef DEBUG +@@ -216,9 +216,6 @@ int main (argc, argv, envp) + 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; +@@ -558,7 +555,8 @@ int main (argc, argv, envp) + if ((i = open (path_dhcpd_pid, + O_WRONLY | O_CREAT, 0644)) >= 0) { + sprintf (pbuf, "%d\n", (int)getpid ()); +- write (i, pbuf, strlen (pbuf)); ++ int r; ++ r = write (i, pbuf, strlen (pbuf)); + close (i); + pidfilewritten = 1; + } +@@ -599,7 +597,8 @@ int main (argc, argv, envp) + if ((i = open (path_dhcpd_pid, + O_WRONLY | O_CREAT, 0644)) >= 0) { + sprintf (pbuf, "%d\n", (int)getpid ()); +- write (i, pbuf, strlen (pbuf)); ++ int r; ++ r = write (i, pbuf, strlen (pbuf)); + close (i); + pidfilewritten = 1; + } +@@ -989,7 +988,6 @@ int dhcpd_interface_setup_hook (struct i + 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", +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 14:33:17.000000000 -0400 +@@ -212,7 +212,6 @@ isc_result_t dhcp_lease_set_value (omap + { + struct lease *lease; + isc_result_t status; +- int foo; + + if (h -> type != dhcp_type_lease) + return ISC_R_INVALIDARG; +@@ -399,8 +398,6 @@ isc_result_t dhcp_lease_get_value (omapi + isc_result_t dhcp_lease_destroy (omapi_object_t *h, const char *file, int line) + { + struct lease *lease; +- isc_result_t status; +- u_int8_t flagbuf; + + if (h -> type != dhcp_type_lease) + return ISC_R_INVALIDARG; +@@ -477,7 +474,6 @@ isc_result_t dhcp_lease_signal_handler ( + { + struct lease *lease; + isc_result_t status; +- int updatep = 0; + + if (h -> type != dhcp_type_lease) + return ISC_R_INVALIDARG; +@@ -911,9 +907,8 @@ isc_result_t dhcp_host_set_value (omapi + 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; +@@ -1172,7 +1167,6 @@ isc_result_t dhcp_host_get_value (omapi_ + 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; +@@ -1593,7 +1587,6 @@ isc_result_t dhcp_pool_set_value (omapi + { + struct pool *pool; + isc_result_t status; +- int foo; + + if (h -> type != dhcp_type_pool) + return ISC_R_INVALIDARG; +@@ -1639,8 +1632,6 @@ isc_result_t dhcp_pool_get_value (omapi_ + 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; +@@ -1737,10 +1728,6 @@ isc_result_t dhcp_pool_stuff_values (oma + 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 +@@ -1914,11 +1901,6 @@ isc_result_t dhcp_class_set_value (omap + omapi_data_string_t *name, + omapi_typed_data_t *value) + { +- struct class *class; +- struct class *superclass = 0; +- isc_result_t status; +- int foo; +- + if (h -> type != dhcp_type_class) + return ISC_R_INVALIDARG; + +@@ -1953,8 +1935,6 @@ isc_result_t dhcp_class_get_value (omapi + 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; +@@ -2231,11 +2211,6 @@ isc_result_t dhcp_subclass_set_value (o + omapi_data_string_t *name, + omapi_typed_data_t *value) + { +- struct class *subclass = 0; +- struct class *superclass = 0; +- isc_result_t status; +- int foo; +- + if (h -> type != dhcp_type_subclass) + return ISC_R_INVALIDARG; + +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 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; + struct data_string ddns_dhcid; +- unsigned len; + struct data_string d1; + struct option_cache *oc; + int s1, s2; +@@ -772,7 +771,6 @@ int ddns_removals (struct lease *lease) + 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 -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 14:33:17.000000000 -0400 +@@ -54,7 +54,6 @@ int write_lease (lease) + struct lease *lease; + { + int errors = 0; +- int i; + struct binding *b; + char *s; + const char *tval; +@@ -148,7 +147,6 @@ int write_lease (lease) + ++errors; + } + if (lease -> uid_len) { +- int i; + s = quotify_buf (lease -> uid, lease -> uid_len, MDL); + if (s) { + errno = 0; +@@ -222,7 +220,7 @@ int write_lease (lease) + } + } + if (lease -> client_hostname && +- db_printable (lease -> client_hostname)) { ++ db_printable ((unsigned char *) lease -> client_hostname)) { + s = quotify_string (lease -> client_hostname, MDL); + if (s) { + errno = 0; +@@ -281,7 +279,7 @@ int write_host (host) + if (!new_lease_file ()) + return 0; + +- if (!db_printable (host -> name)) ++ if (!db_printable ((unsigned char *) host -> name)) + return 0; + + if (counting) +@@ -419,7 +417,6 @@ int write_group (group) + 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. */ +@@ -427,7 +424,7 @@ int write_group (group) + if (!new_lease_file ()) + return 0; + +- if (!db_printable (group -> name)) ++ if (!db_printable ((unsigned char *) group -> name)) + return 0; + + if (counting) +@@ -484,7 +481,6 @@ int write_group (group) + #if defined (FAILOVER_PROTOCOL) + int write_failover_state (dhcp_failover_state_t *state) + { +- struct tm *t; + int errors = 0; + const char *tval; + +@@ -696,8 +692,6 @@ void write_billing_classes () + { + 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) { +@@ -714,7 +708,6 @@ int write_billing_class (class) + struct class *class; + { + int errors = 0; +- int i; + + 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 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" + +-static TIME parsed_time; + static unsigned char global_host_once = 1; + + #if defined (TRACING) +@@ -344,15 +343,12 @@ int parse_statement (cfile, group, type, + 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 = NULL; + struct option_cache *cache; + int lose; +- struct data_string key_id; + int known; + isc_result_t status; + unsigned code; +@@ -961,7 +957,6 @@ void parse_failover_peer (cfile, group, + "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 +1526,6 @@ void parse_pool_statement (cfile, group, + + /* 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 +1836,6 @@ int parse_class_declaration (cp, cfile, + 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; + int matchedonce = 0; +@@ -2298,7 +2290,6 @@ void parse_subnet_declaration (cfile, sh + unsigned char addr [4]; + unsigned len = sizeof addr; + int declaration = 0; +- struct interface_info *ip; + isc_result_t status; + + subnet = (struct subnet *)0; +@@ -2577,8 +2568,6 @@ int parse_lease_declaration (struct leas + char tbuf [32]; + struct lease *lease; + struct executable_statement *on; +- struct expression *exp; +- struct data_string ds; + int lose; + TIME t; + char *s; +@@ -3011,7 +3000,6 @@ int parse_lease_declaration (struct leas + + 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; +@@ -3168,7 +3156,6 @@ void parse_address_range (cfile, group, + int dynamic = 0; + struct subnet *subnet; + struct shared_network *share; +- struct pool *p; + struct pool *pool; + isc_result_t status; + +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 14:33:17.000000000 -0400 +@@ -64,7 +64,6 @@ void dhcp_failover_startup () + { + 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"); +@@ -181,7 +180,6 @@ isc_result_t dhcp_failover_link_initiate + { + 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; +@@ -283,8 +281,6 @@ isc_result_t dhcp_failover_link_signal ( + 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) { +@@ -598,7 +594,6 @@ static isc_result_t do_a_failover_option + 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."); +@@ -1128,8 +1123,6 @@ isc_result_t dhcp_failover_listener_stuf + omapi_object_t *id, + omapi_object_t *p) + { +- int i; +- + if (p -> type != dhcp_type_failover_listener) + return ISC_R_INVALIDARG; + +@@ -1189,11 +1182,8 @@ isc_result_t dhcp_failover_state_signal + 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; +@@ -1844,7 +1834,6 @@ isc_result_t dhcp_failover_peer_state_ch + 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_SERVER_STARTUP) ? 1 : 0; +@@ -2287,7 +2276,6 @@ static int dhcp_failover_pool_dobalance( + 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; +@@ -2515,7 +2503,6 @@ dhcp_failover_pool_check(struct pool *po + + int dhcp_failover_state_pool_check (dhcp_failover_state_t *state) + { +- struct lease *lp; + struct shared_network *s; + struct pool *p; + +@@ -2844,7 +2831,7 @@ isc_result_t dhcp_failover_state_set_val + + void dhcp_failover_keepalive (void *vs) + { +- dhcp_failover_state_t *state = vs; ++ return; + } + + void dhcp_failover_reconnect (void *vs) +@@ -2878,7 +2865,6 @@ void dhcp_failover_reconnect (void *vs) + 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"); +@@ -2890,7 +2876,6 @@ void dhcp_failover_startup_timeout (void + 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) +@@ -3369,7 +3354,6 @@ isc_result_t dhcp_failover_state_remove + 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; + +@@ -3949,7 +3933,6 @@ isc_result_t dhcp_failover_put_message ( + omapi_object_t *connection, + int msg_type, u_int32_t xid, ...) + { +- unsigned count = 0; + unsigned size = 0; + int bad_option = 0; + int opix = 0; +@@ -4062,7 +4045,6 @@ void dhcp_failover_timeout (void *vstate + { + 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"); +@@ -4182,7 +4164,6 @@ isc_result_t dhcp_failover_send_connect + 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; +@@ -5189,7 +5170,7 @@ isc_result_t dhcp_failover_generate_upda + { + struct shared_network *s; + struct pool *p; +- struct lease *l, *n; ++ struct lease *l; + int i; + #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 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; + struct host_decl *foo; +- struct executable_statement *esp; + int hw_head = 0, uid_head = 1; + + /* Don't need to do it twice. */ +@@ -452,7 +451,6 @@ int find_hosts_by_haddr (struct host_dec + const unsigned char *haddr, unsigned hlen, + const char *file, int line) + { +- struct host_decl *foo; + struct hardware h; + int ret; + +@@ -488,7 +486,6 @@ int find_host_for_network (struct subnet + 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; +@@ -538,12 +535,11 @@ void new_address_range (cfile, low, high + 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. */ +@@ -832,7 +828,6 @@ void enter_lease (lease) + 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) { +@@ -879,7 +874,6 @@ int supersede_lease (comp, lease, commit + int pimmediate; + { + struct lease *lp, **lq, *prev; +- TIME lp_next_state; + #if defined (FAILOVER_PROTOCOL) + int do_pool_check = 0; + +@@ -1571,7 +1565,6 @@ void pool_timer (vpool) + void *vpool; + { + struct pool *pool; +- struct lease *lt = (struct lease *)0; + struct lease *next = (struct lease *)0; + struct lease *lease = (struct lease *)0; + #define FREE_LEASES 0 +@@ -2295,7 +2288,6 @@ void expire_all_pools () + { + struct shared_network *s; + struct pool *p; +- struct hash_bucket *hb; + int i; + 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 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; + char name[PATH_MAX], enckey[RAW_KEY_SIZE]; +- unsigned char *notspace; ++ char *notspace; + u_char deckey[RAW_KEY_SIZE]; + FILE *fp; + +@@ -548,7 +548,8 @@ dst_s_read_public_key(const char *in_nam + return (NULL); + } + /* read in the key string */ +- fgets(enckey, sizeof(enckey), fp); ++ char *r; ++ r = fgets(enckey, sizeof(enckey), fp); + + /* If we aren't at end-of-file, something is wrong. */ + 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 14:33:17.000000000 -0400 +@@ -335,7 +335,7 @@ unix_cmd(dst_work *work) + 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 */ + } +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 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; + cfile -> tval = cfile -> tokbuf; +- return intern (cfile -> tval, rv); ++ return intern ((unsigned char *)cfile -> tval, rv); + } + +-static enum dhcp_token intern (atom, dfv) +- unsigned char *atom; ++static enum dhcp_token intern (inatom, dfv) ++ unsigned char *inatom; + enum dhcp_token dfv; + { ++ char *atom = (char *) inatom; ++ + if (!isascii (atom [0])) + return dfv; + +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 14:33:17.000000000 -0400 +@@ -55,8 +55,6 @@ static char copyright[] = + # endif + #endif + +-static int once = 0; +- + /* Reinitializes the specified interface after an address change. This + is not required for packet-filter APIs. */ + +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 14:33:17.000000000 -0400 +@@ -311,9 +311,6 @@ int parse_ip_addr (cfile, addr) + 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)) +@@ -614,7 +611,7 @@ void convert_num (cfile, buf, str, base, + int base; + unsigned size; + { +- const unsigned char *ptr = str; ++ const unsigned char *ptr = (const unsigned char *) str; + int negative = 0; + u_int32_t val = 0; + int tval; +@@ -742,7 +739,6 @@ void convert_num (cfile, buf, str, base, + TIME parse_date (cfile) + struct parse *cfile; + { +- struct tm tm; + int guess; + int tzoff, wday, year, mon, mday, hour, min, sec; + const char *val; +@@ -1306,7 +1302,6 @@ int parse_option_code_definition (cfile, + char tokbuf [128]; + unsigned tokix = 0; + char type; +- int code; + int is_signed; + char *s; + int has_encapsulation = 0; +@@ -1807,7 +1802,6 @@ int parse_executable_statement (result, + enum dhcp_token token; + const char *val; + unsigned len; +- struct executable_statement base; + struct class *cta; + struct option *option=NULL; + struct option_cache *cache; +@@ -2147,7 +2141,6 @@ int parse_executable_statement (result, + 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; +@@ -3198,16 +3191,13 @@ int parse_non_binary (expr, cfile, lose, + 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; ++ isc_result_t status; + unsigned len; + + token = peek_token (&val, (unsigned *)0, cfile); +@@ -3735,7 +3725,6 @@ int parse_non_binary (expr, cfile, lose, + parse_warn + (cfile, + "expecting dns expression."); +- badnstrans: + expression_dereference (expr, MDL); + *lose = 1; + return 0; +@@ -4646,8 +4635,6 @@ int parse_option_statement (result, cfil + 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) { +@@ -4764,9 +4751,7 @@ int parse_option_token (rv, cfile, fmt, + 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; + +@@ -5019,8 +5004,6 @@ int parse_option_decl (oc, cfile) + /* 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; +@@ -5221,7 +5204,6 @@ int parse_X (cfile, buf, max) + 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) { +@@ -5265,6 +5247,7 @@ int parse_X (cfile, buf, max) + + int parse_warn (struct parse *cfile, const char *fmt, ...) + { ++ int l; + va_list list; + char lexbuf [256]; + char mbuf [1024]; +@@ -5288,9 +5271,10 @@ int parse_warn (struct parse *cfile, con + 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; +@@ -5303,14 +5287,14 @@ int parse_warn (struct parse *cfile, con + #endif + + if (log_perror) { +- write (STDERR_FILENO, mbuf, strlen (mbuf)); +- write (STDERR_FILENO, "\n", 1); +- write (STDERR_FILENO, cfile -> token_line, ++ l = write (STDERR_FILENO, mbuf, strlen (mbuf)); ++ l = write (STDERR_FILENO, "\n", 1); ++ l = write (STDERR_FILENO, cfile -> token_line, + strlen (cfile -> token_line)); +- write (STDERR_FILENO, "\n", 1); ++ l = write (STDERR_FILENO, "\n", 1); + if (cfile -> lexchar < 81) +- write (STDERR_FILENO, lexbuf, lix); +- write (STDERR_FILENO, "^\n", 2); ++ l = write (STDERR_FILENO, lexbuf, lix); ++ l = write (STDERR_FILENO, "^\n", 2); + } + + 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 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; + { +- int size; + struct option_chain_head *h; + + if (!ptr) { +@@ -109,7 +108,6 @@ int option_chain_head_dereference (ptr, + const char *file; + int line; + { +- int i; + struct option_chain_head *option_chain_head; + pair car, cdr; + +@@ -161,7 +159,6 @@ int group_allocate (ptr, file, line) + const char *file; + int line; + { +- int size; + struct group *g; + + if (!ptr) { +@@ -222,7 +219,6 @@ int group_dereference (ptr, file, line) + const char *file; + int line; + { +- int i; + struct group *group; + + if (!ptr || !*ptr) { +@@ -741,8 +737,6 @@ int buffer_dereference (ptr, file, line) + const char *file; + int line; + { +- struct buffer *bp; +- + if (!ptr) { + log_error ("%s(%d): null pointer", file, line); + #if defined (POINTER_DEBUG) +@@ -830,8 +824,6 @@ int dns_host_entry_dereference (ptr, fil + 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 @@ int packet_allocate (ptr, file, line) + const char *file; + int line; + { +- int size; + struct packet *p; + + if (!ptr) { +@@ -1157,7 +1148,6 @@ int dns_zone_allocate (ptr, file, line) + const char *file; + int line; + { +- int size; + struct dns_zone *d; + + 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 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; + { + int sock; +- char filename[50]; +- int b; + union { + struct sockaddr_ll ll; + struct sockaddr common; +@@ -362,7 +360,6 @@ ssize_t receive_packet (interface, buf, + struct sockaddr_in *from; + struct hardware *hfrom; + { +- int nread; + int length = 0; + int offset = 0; + 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 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) + { +- 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 @@ isc_result_t supersede_group (struct gro + 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 +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 14:33:17.000000000 -0400 +@@ -143,7 +143,6 @@ isc_result_t dhcp_group_set_value (omap + { + struct group_object *group; + isc_result_t status; +- int foo; + + if (h -> type != dhcp_type_group) + return ISC_R_INVALIDARG; +@@ -217,7 +216,6 @@ isc_result_t dhcp_group_get_value (omapi + { + 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_get_value (omapi + 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_destroy (omapi_o + 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 @@ isc_result_t dhcp_control_set_value (om + { + dhcp_control_object_t *control; + isc_result_t status; +- int foo; + unsigned long newstate; + + if (h -> type != dhcp_type_control) +@@ -488,7 +484,6 @@ isc_result_t dhcp_control_get_value (oma + { + 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_get_value (oma + 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_destroy (omapi + 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 @@ isc_result_t dhcp_control_lookup (omapi_ + { + 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 @@ isc_result_t dhcp_subnet_set_value (oma + { + 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_get_value (omap + 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 @@ isc_result_t dhcp_subnet_lookup (omapi_o + 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 @@ isc_result_t dhcp_shared_network_set_val + { + 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 @@ isc_result_t dhcp_shared_network_destroy + 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 @@ isc_result_t dhcp_shared_network_lookup + 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 +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 14:33:17.000000000 -0400 +@@ -61,11 +61,7 @@ void icmp_startup (routep, handler) + { + 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 @@ isc_result_t icmp_echoreply (h) + 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); +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 14:33:17.000000000 -0400 +@@ -124,7 +124,7 @@ struct iaddr broadcast_addr (subnet, mas + struct iaddr subnet; + struct iaddr mask; + { +- int i, j, k; ++ int i; + struct iaddr rv; + + 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 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) + { +- isc_result_t status; + ns_tsig_key *tkey; + + if (!zone) +@@ -201,7 +200,6 @@ isc_result_t enter_dns_zone (struct dns_ + + 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 @@ int dns_zone_dereference (ptr, file, lin + const char *file; + int line; + { +- int i; + struct dns_zone *dns_zone; + + if (!ptr || !*ptr) { +@@ -397,9 +394,7 @@ void repudiate_zone (struct dns_zone **z + 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] == '.') +@@ -678,7 +673,7 @@ ddns_update_a(struct data_string *ddns_f + /* + * Conflict detection override: delete DHCID RRs. + */ +- updrec = minires_mkupdrec(S_UPDATE, ddns_fwd_name->data, ++ updrec = minires_mkupdrec(S_UPDATE, (char *)ddns_fwd_name->data, + C_IN, T_DHCID, 0); + + 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 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 + +-static void +-append_to_ary(char **ary_ptr, int *ary_size, int ary_capacity, +- char *new_element) +-{ +- /* INSIST(ary_ptr != NULL); */ +- /* INSIST(ary_size != NULL); */ +- /* INSIST(ary_capacity > 1); */ +- +- if (new_element == NULL) +- return; +- +- if (*ary_size >= ary_capacity) { +- log_fatal("Improbable error at %s:%d.", MDL); +- return; +- } +- +- ary_ptr[(*ary_size)++] = new_element; +-} +- +-static char * +-data_string_to_char_string(struct data_string *d) +-{ +- char *str, *start, *end; +- const unsigned char *pos; +- int len; +- +- if (d == NULL); +- return NULL; +- +- pos = d->data; +- +- if (pos == NULL) +- return NULL; +- +- /* Per byte could be "\777" at worst, plus null terminator. */ +- len = (d->len * 4) + 1; +- str = dmalloc(len, MDL); +- if (!str) +- return NULL; +- +- start = str; +- end = start + len; +- +- if (pretty_escape(&start, end, &pos, pos + d->len) < 0) { +- dfree(str, MDL); +- return NULL; +- } +- +- /* dmalloc() sets the buffer to zero - there is no need to null +- * terminate. +- */ +- +- return str; +-} +- + pair cons (car, cdr) + caddr_t car; + pair cdr; +@@ -305,8 +250,6 @@ int make_limit (new, expr, limit) + 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"); +@@ -700,11 +643,10 @@ int evaluate_dns_expression (result, pac + 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", +@@ -961,10 +903,7 @@ int evaluate_boolean_expression (result, + 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; +@@ -1957,7 +1896,6 @@ int evaluate_data_expression (result, pa + MDL); + + if (s0 && s1) { +- char *upper; + int i; + + /* The buffer must be a multiple of the number's +@@ -3280,8 +3218,6 @@ static int op_val (op) + int op_precedence (op1, op2) + enum expr_op op1, op2; + { +- int ov1, ov2; +- + return op_val (op1) - op_val (op2); + } + +@@ -3382,7 +3318,6 @@ int write_expression (file, expr, col, i + int firstp; + { + struct expression *e; +- struct expression *next_arg; + const char *s; + char obuf [65]; + int scol; +@@ -3913,7 +3848,6 @@ int binding_scope_dereference (ptr, file + const char *file; + int line; + { +- int i; + struct binding_scope *binding_scope; + + 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 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; + +- for (sp = s; sp && *sp; sp++) { ++ for (sp = (unsigned char *)s; sp && *sp; sp++) { + if (*sp == ' ') + len++; + else if (!isascii (*sp) || !isprint (*sp)) +@@ -61,7 +61,7 @@ char *quotify_string (const char *s, con + buf = dmalloc (len + 1, file, line); + if (buf) { + nsp = buf; +- for (sp = s; sp && *sp; sp++) { ++ for (sp = (unsigned char *)s; sp && *sp; sp++) { + if (*sp == ' ') + *nsp++ = ' '; + else if (!isascii (*sp) || !isprint (*sp)) { +@@ -461,7 +461,6 @@ static unsigned print_subexpression (exp + { + unsigned rv, left; + const char *s; +- struct expression *next_arg; + + switch (expr -> op) { + case expr_none: +@@ -1076,7 +1075,6 @@ int token_print_indent_concat (FILE *fil + const char *suffix, ...) + { + va_list list; +- char *buf; + unsigned len; + char *s, *t, *u; + +@@ -1114,7 +1112,6 @@ int token_indent_data_string (FILE *file + struct data_string *data) + { + int i; +- char *buf; + char obuf [3]; + + /* 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 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; + { +- 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; +@@ -441,7 +439,6 @@ void discover_interfaces (state) + for (tmp = interfaces; tmp; tmp = tmp -> next) { + struct ifreq ifr; + struct sockaddr sa; +- int b, sk; + + if (!tmp -> ifp) { + /* Make up an ifreq structure. */ +@@ -828,7 +825,6 @@ isc_result_t dhcp_interface_set_value ( + { + struct interface_info *interface; + isc_result_t status; +- int foo; + + if (h -> type != dhcp_type_interface) + return ISC_R_INVALIDARG; +@@ -871,7 +867,6 @@ isc_result_t dhcp_interface_destroy (oma + const char *file, int line) + { + struct interface_info *interface; +- isc_result_t status; + + if (h -> type != dhcp_type_interface) + return ISC_R_INVALIDARG; +@@ -901,8 +896,6 @@ isc_result_t dhcp_interface_signal_handl + 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) +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 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; + +-static void do_option_set PROTO ((pair *, +- struct option_cache *, +- enum statement_op)); + static int pretty_text(char **, char *, const unsigned char **, + const unsigned char *, int); + static int pretty_domain(char **, char *, const unsigned char **, +@@ -56,7 +53,6 @@ static int pretty_domain(char **, char * + int parse_options (packet) + struct packet *packet; + { +- int i; + struct option_cache *op = (struct option_cache *)0; + + /* Allocate a new option state. */ +@@ -136,8 +132,6 @@ int parse_option_buffer (options, buffer + unsigned length; + struct universe *universe; + { +- unsigned char *t; +- const unsigned char *end = buffer + length; + unsigned len, offset; + unsigned code; + struct option_cache *op = (struct option_cache *)0; +@@ -313,7 +307,6 @@ int fqdn_universe_decode (struct option_ + 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. */ +@@ -500,9 +493,7 @@ int cons_options (inpacket, outpacket, l + 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; +@@ -510,7 +501,6 @@ int cons_options (inpacket, outpacket, l + struct data_string ds; + pair pp, *hash; + int need_endopt = 0; +- int have_sso = 0; + int ocount = 0; + int ofbuf1=0, ofbuf2=0; + +@@ -881,7 +871,6 @@ int store_options (ocount, buffer, bufle + if ((option != NULL) && + (((oc == NULL) && (option->format[0] == 'E')) || + ((oc != NULL) && (option->format[0] == 'e')))) { +- int uix; + static char *s, *t; + struct option_cache *tmp; + struct data_string name; +@@ -1020,7 +1009,6 @@ int store_options (ocount, buffer, bufle + toptstart = tix; + while (length) { + unsigned incr = length; +- int consumed = 0; + int *pix; + unsigned char *base; + +@@ -1136,7 +1124,6 @@ format_has_text(format) + const char *format; + { + const char *p; +- int retval = 0; + + 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; + { +- struct data_string sub; +- struct universe *u = NULL, *subu = NULL; ++ struct universe *u = NULL; + int status = 0; +- int i; + +- universe_hash_lookup(&u, universe_hash, name->data, name->len, MDL); ++ universe_hash_lookup(&u, universe_hash, (char *)name->data, name->len, MDL); + if (u == NULL) { + log_error("option_space_encapsulate: option space %.*s does " + "not exist, but is configured.", +@@ -2332,7 +2317,6 @@ int nwip_option_space_encapsulate (resul + { + pair ocp; + int status; +- int i; + static struct option_cache *no_nwip; + struct data_string ds; + struct option_chain_head *head; +@@ -2346,7 +2330,6 @@ int nwip_option_space_encapsulate (resul + + 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, +@@ -2539,7 +2522,6 @@ void suboption_foreach (struct packet *p + { + struct universe *universe = find_option_universe (oc -> option, + vsname); +- int i; + + if (universe -> foreach) + (*universe -> foreach) (packet, lease, client_state, +@@ -2589,7 +2571,6 @@ void save_linked_option (universe, optio + struct option_cache *oc; + { + pair *tail; +- pair np = (pair )0; + struct option_chain_head *head; + + if (universe -> index >= options -> universe_count) +@@ -2764,7 +2745,6 @@ void do_packet (interface, packet, len, + struct iaddr from; + struct hardware *hfrom; + { +- int i; + struct option_cache *op; + struct packet *decoded_packet; + #if defined (DEBUG_MEMORY_LEAKAGE) +@@ -2942,7 +2922,6 @@ pretty_domain(char **dst, char *dend, co + return -1; + + **dst = '"'; +- *dst++; + + do { + /* Continue loop until end of src buffer. */ +@@ -2951,7 +2930,6 @@ pretty_domain(char **dst, char *dend, co + + /* Consume tag size. */ + tsiz = **src; +- *src++; + + /* At root, finis. */ + if (tsiz == 0) +@@ -2973,13 +2951,11 @@ pretty_domain(char **dst, char *dend, co + return -1; + + **dst = '.'; +- *dst++; + count += status + 1; + } + while(1); + + **dst = '"'; +- *dst++; + + return count; + } +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 14:33:17.000000000 -0400 +@@ -54,8 +54,6 @@ int execute_statements (result, packet, + 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; +@@ -363,7 +361,6 @@ int execute_statements (result, packet, + binding -> next = (*scope) -> bindings; + (*scope) -> bindings = binding; + } else { +- badalloc: + dfree (binding, MDL); + binding = (struct binding *)0; + } +@@ -606,8 +603,6 @@ int executable_statement_dereference (pt + const char *file; + int line; + { +- struct executable_statement *bp; +- + if (!ptr || !*ptr) { + log_error ("%s(%d): null pointer", file, line); + #if defined (POINTER_DEBUG) +@@ -739,8 +734,6 @@ void write_statements (file, statements, + { + struct executable_statement *r, *x; + struct expression *expr; +- int result; +- int status; + const char *s, *t, *dot; + int col; + +@@ -1014,10 +1007,8 @@ int find_matching_case (struct executabl + { + 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); +@@ -1091,7 +1082,6 @@ int executable_statement_foreach (struct + { + struct executable_statement *foo; + int ok = 0; +- int result; + + for (foo = stmt; foo; foo = foo -> next) { + 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 14:33:17.000000000 -0400 +@@ -50,10 +50,8 @@ void read_resolv_conf (parse_time) + 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 @@ void read_resolv_conf (parse_time) + + struct name_server *first_name_server () + { +- FILE *rc; + static TIME rcdate; + struct stat st; + +@@ -190,8 +187,6 @@ struct name_server *first_name_server () + 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); +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 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) { + register FILE *fp; +- register unsigned char *cp; ++ char *cp; + register char **pp; + register int n; + 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 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) { + char *file; +- unsigned char *cp1, *cp2; ++ char *cp1, *cp2; + char buf[BUFSIZ]; + FILE *fp; + +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 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)]; + struct zonegrp *zptr, tgrp; +- int nzones = 0, nscount = 0; ++ int nscount = 0; + unsigned n; + unsigned rval; + 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 14:33:17.000000000 -0400 +@@ -48,7 +48,7 @@ static const char rcsid[] = "$Id: ns_dat + + /* Forward. */ + +-static int datepart(const unsigned char *, int, int, int, int *); ++static int datepart(const char *, int, int, int, int *); + + /* Public. */ + +@@ -118,7 +118,7 @@ ns_datetosecs(const char *cp, int *errp) + * Don't reset the flag if there is no error. + */ + static int +-datepart(const unsigned char *buf, int size, int min, int max, int *errp) { ++datepart(const char *buf, int size, int min, int max, int *errp) { + int result = 0; + 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 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; + u_char *dnptrs[20], **dpp, **lastdnptr; +- unsigned siglen, certlen; ++ unsigned certlen; + int keylen; + 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 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" + +-static TIME parsed_time; +- + struct client_config top_level_config; + + u_int32_t default_requested_options [] = { +@@ -65,7 +63,6 @@ u_int32_t default_requested_options [] = + isc_result_t read_client_conf () + { + struct client_config *config; +- struct client_state *state; + struct interface_info *ip; + isc_result_t status; + +@@ -245,11 +242,9 @@ void parse_client_statement (cfile, ip, + int token; + const char *val; + struct option *option = NULL; +- 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; +@@ -992,11 +987,9 @@ void parse_client_lease_declaration (cfi + { + 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: +@@ -1212,12 +1205,6 @@ int parse_allow_deny (oc, cfile, flag) + struct parse *cfile; + int flag; + { +- enum dhcp_token token; +- const char *val; +- unsigned char rf = flag; +- struct expression *data = (struct expression *)0; +- int status; +- + parse_warn (cfile, "allow/deny/ignore not permitted here."); + skip_to_semi (cfile); + return 0; +diff -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 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; + #endif ++#ifndef LIBDHCP + int fd; ++#endif + int i; + struct servent *ent; + struct interface_info *ip; +@@ -140,7 +142,6 @@ int main (argc, argv, envp) + 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; +@@ -1171,7 +1172,6 @@ void state_selecting (cpp) + picked = lp; + picked -> next = (struct client_lease *)0; + } else { +- freeit: + destroy_client_lease (lp); + } + } +@@ -1230,7 +1230,6 @@ void dhcpack (packet) + 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. */ +@@ -1395,8 +1394,6 @@ void dhcpack (packet) + void bind_lease (client) + struct client_state *client; + { +- struct interface_info *ip = client -> interface; +- + /* Remember the medium. */ + client -> new -> medium = client -> medium; + +@@ -1465,7 +1462,6 @@ void state_bound (cpp) + void *cpp; + { + struct client_state *client = cpp; +- int i; + struct option_cache *oc; + struct data_string ds; + +@@ -1508,7 +1504,6 @@ void state_stop (cpp) + void *cpp; + { + struct client_state *client = cpp; +- int i; + + /* Cancel all timeouts. */ + cancel_timeout (state_selecting, client); +@@ -1643,8 +1638,6 @@ void dhcpoffer (packet) + 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 +@@ -2493,7 +2486,6 @@ void make_discover (client, lease) + 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)); +@@ -2558,9 +2550,6 @@ void make_request (client, lease) + 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)); +@@ -2650,7 +2639,6 @@ void make_decline (client, lease) + struct client_lease *lease; + { + unsigned char decline = DHCPDECLINE; +- int i; + struct option_cache *oc; + + struct option_state *options = (struct option_state *)0; +@@ -2707,7 +2695,6 @@ void make_release (client, lease) + struct client_lease *lease; + { + unsigned char request = DHCPRELEASE; +- int i; + struct option_cache *oc; + + struct option_state *options = (struct option_state *)0; +@@ -2764,8 +2751,6 @@ void make_release (client, lease) + void destroy_client_lease (lease) + struct client_lease *lease; + { +- int i; +- + if (lease -> server_name) + dfree (lease -> server_name, MDL); + if (lease -> filename) +@@ -2830,8 +2815,6 @@ void write_lease_option (struct option_c + { + const char *name, *dot; + struct data_string ds; +- int status; +- struct client_state *client; + + memset (&ds, 0, sizeof ds); + +@@ -2860,11 +2843,8 @@ int write_client_lease (client, lease, r + int makesure; + { + int i; +- struct tm *t; + static int leases_written; +- struct option_cache *oc; + struct data_string ds; +- pair *hash; + int errors = 0; + char *s; + const char *tval; +@@ -3079,8 +3059,6 @@ void script_write_params (client, prefix + int i; + struct data_string data; + struct option_cache *oc; +- pair *hash; +- char *s, *t; + struct envadd_state es; + + es.client = client; +@@ -3205,11 +3183,9 @@ int script_go (client) + + return 0; + #else +- int rval; + char *scriptName; + char *argv [2]; + char **envp; +- char *epp [3]; + char reason [] = "REASON=NBI"; + static char client_path [] = CLIENT_PATH; + int i; +@@ -3291,7 +3267,7 @@ void client_envadd (struct client_state + { + char spbuf [1024]; + char *s; +- unsigned len, i; ++ unsigned len; + struct string_list *val; + va_list list; + +@@ -3720,8 +3696,7 @@ void client_dns_update_timeout (void *cp + + 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; 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/dhcpd-conf-to-ldap b/dhcpd-conf-to-ldap new file mode 100755 index 0000000..d3b80f3 --- /dev/null +++ b/dhcpd-conf-to-ldap @@ -0,0 +1,760 @@ +#!/usr/bin/perl -w + +# Brian Masney +# To use this script, set your base DN below. Then run +# ./dhcpd-conf-to-ldap.pl < /path-to-dhcpd-conf/dhcpd.conf > output-file +# The output of this script will generate entries in LDIF format. You can use +# the slapadd command to add these entries into your LDAP server. You will +# definately want to double check that your LDAP entries are correct before +# you load them into LDAP. + +# This script does not do much error checking. Make sure before you run this +# that the DHCP server doesn't give any errors about your config file + +# FailOver notes: +# Failover is disabled by default, since it may need manually intervention. +# You can try the '--use=failover' option to see what happens :-) +# +# If enabled, the failover pool references will be written to LDIF output. +# The failover configs itself will be added to the dhcpServer statements +# and not to the dhcpService object (since this script uses only one and +# it may be usefull to have multiple service containers in failover mode). +# Further, this script does not check if primary or secondary makes sense, +# it simply converts what it gets... + +use Net::Domain qw(hostname hostfqdn hostdomain); +use Getopt::Long; + +my $domain = hostdomain(); # your.domain +my $basedn = "dc=".$domain; + $basedn =~ s/\./,dc=/g; # dc=your,dc=domain +my $server = hostname(); # hostname (nodename) +my $dhcpcn = 'DHCP Config'; # CN of DHCP config tree +my $dhcpdn = "cn=$dhcpcn, $basedn"; # DHCP config tree DN +my $second = ''; # secondary server DN / hostname +my $i_conf = ''; # dhcp.conf file to read or stdin +my $o_ldif = ''; # output ldif file name or stdout +my @use = (); # extended flags (failover) + +sub usage($;$) +{ + my $rc = shift; + my $err= shift; + + print STDERR "Error: $err\n\n" if(defined $err); + print STDERR <<__EOF_USAGE__; +usage: + $0 [options] < dhcpd.conf > dhcpd.ldif + +options: + + --basedn "dc=your,dc=domain" ("$basedn") + + --dhcpdn "dhcp config DN" ("$dhcpdn") + + --server "dhcp server name" ("$server") + + --second "secondary server or DN" ("$second") + + --conf "/path/to/dhcpd.conf" (default is stdin) + --ldif "/path/to/output.ldif" (default is stdout) + + --use "extended features" (see source comments) +__EOF_USAGE__ + exit($rc); +} + + +sub next_token +{ + local ($lowercase) = @_; + local ($token, $newline); + + do + { + if (!defined ($line) || length ($line) == 0) + { + $line = <>; + return undef if !defined ($line); + chop $line; + $line_number++; + $token_number = 0; + } + + $line =~ s/#.*//; + $line =~ s/^\s+//; + $line =~ s/\s+$//; + } + while (length ($line) == 0); + + if (($token, $newline) = $line =~ /^(.*?)\s+(.*)/) + { + if ($token =~ /^"/) { + #handle quoted token + if ($token !~ /"\s*$/) + { + ($tok, $newline) = $newline =~ /([^"]+")(.*)/; + $token .= " $tok"; + } + } + $line = $newline; + } + else + { + $token = $line; + $line = ''; + } + $token_number++; + + $token =~ y/[A-Z]/[a-z]/ if $lowercase; + + return ($token); +} + + +sub remaining_line +{ + local ($block) = shift || 0; + local ($tmp, $str); + + $str = ""; + while (defined($tmp = next_token (0))) + { + $str .= ' ' if !($str eq ""); + $str .= $tmp; + last if $tmp =~ /;\s*$/; + last if($block and $tmp =~ /\s*[}{]\s*$/); + } + + $str =~ s/;$//; + return ($str); +} + + +sub +add_dn_to_stack +{ + local ($dn) = @_; + + $current_dn = "$dn, $current_dn"; +} + + +sub +remove_dn_from_stack +{ + $current_dn =~ s/^.*?,\s*//; +} + + +sub +parse_error +{ + print "Parse error on line number $line_number at token number $token_number\n"; + exit (1); +} + + +sub +print_entry +{ + return if (scalar keys %curentry == 0); + + if (!defined ($curentry{'type'})) + { + $hostdn = "cn=$server, $basedn"; + print "dn: $hostdn\n"; + print "cn: $server\n"; + print "objectClass: top\n"; + print "objectClass: dhcpServer\n"; + print "dhcpServiceDN: $current_dn\n"; + if(grep(/FaIlOvEr/i, @use)) + { + foreach my $fo_peer (keys %failover) + { + next if(scalar(@{$failover{$fo_peer}}) <= 1); + print "dhcpStatements: failover peer $fo_peer { ", + join('; ', @{$failover{$fo_peer}}), "; }\n"; + } + } + print "\n"; + + print "dn: $current_dn\n"; + print "cn: $dhcpcn\n"; + print "objectClass: top\n"; + print "objectClass: dhcpService\n"; + if (defined ($curentry{'options'})) + { + print "objectClass: dhcpOptions\n"; + } + print "dhcpPrimaryDN: $hostdn\n"; + if(grep(/FaIlOvEr/i, @use) and ($second ne '')) + { + print "dhcpSecondaryDN: $second\n"; + } + } + elsif ($curentry{'type'} eq 'subnet') + { + print "dn: $current_dn\n"; + print "cn: " . $curentry{'ip'} . "\n"; + print "objectClass: top\n"; + print "objectClass: dhcpSubnet\n"; + if (defined ($curentry{'options'})) + { + print "objectClass: dhcpOptions\n"; + } + + print "dhcpNetMask: " . $curentry{'netmask'} . "\n"; + if (defined ($curentry{'ranges'})) + { + foreach $statement (@{$curentry{'ranges'}}) + { + print "dhcpRange: $statement\n"; + } + } + } + elsif ($curentry{'type'} eq 'shared-network') + { + print "dn: $current_dn\n"; + print "cn: " . $curentry{'descr'} . "\n"; + print "objectClass: top\n"; + print "objectClass: dhcpSharedNetwork\n"; + if (defined ($curentry{'options'})) + { + print "objectClass: dhcpOptions\n"; + } + } + elsif ($curentry{'type'} eq 'group') + { + print "dn: $current_dn\n"; + print "cn: group", $curentry{'idx'}, "\n"; + print "objectClass: top\n"; + print "objectClass: dhcpGroup\n"; + if (defined ($curentry{'options'})) + { + print "objectClass: dhcpOptions\n"; + } + } + elsif ($curentry{'type'} eq 'host') + { + print "dn: $current_dn\n"; + print "cn: " . $curentry{'host'} . "\n"; + print "objectClass: top\n"; + print "objectClass: dhcpHost\n"; + if (defined ($curentry{'options'})) + { + print "objectClass: dhcpOptions\n"; + } + + if (defined ($curentry{'hwaddress'})) + { + $curentry{'hwaddress'} =~ y/[A-Z]/[a-z]/; + print "dhcpHWAddress: " . $curentry{'hwaddress'} . "\n"; + } + } + elsif ($curentry{'type'} eq 'pool') + { + print "dn: $current_dn\n"; + print "cn: pool", $curentry{'idx'}, "\n"; + print "objectClass: top\n"; + print "objectClass: dhcpPool\n"; + if (defined ($curentry{'options'})) + { + print "objectClass: dhcpOptions\n"; + } + + if (defined ($curentry{'ranges'})) + { + foreach $statement (@{$curentry{'ranges'}}) + { + print "dhcpRange: $statement\n"; + } + } + } + elsif ($curentry{'type'} eq 'class') + { + print "dn: $current_dn\n"; + print "cn: " . $curentry{'class'} . "\n"; + print "objectClass: top\n"; + print "objectClass: dhcpClass\n"; + if (defined ($curentry{'options'})) + { + print "objectClass: dhcpOptions\n"; + } + } + elsif ($curentry{'type'} eq 'subclass') + { + print "dn: $current_dn\n"; + print "cn: " . $curentry{'subclass'} . "\n"; + print "objectClass: top\n"; + print "objectClass: dhcpSubClass\n"; + if (defined ($curentry{'options'})) + { + print "objectClass: dhcpOptions\n"; + } + print "dhcpClassData: " . $curentry{'class'} . "\n"; + } + + if (defined ($curentry{'statements'})) + { + foreach $statement (@{$curentry{'statements'}}) + { + print "dhcpStatements: $statement\n"; + } + } + + if (defined ($curentry{'options'})) + { + foreach $statement (@{$curentry{'options'}}) + { + print "dhcpOption: $statement\n"; + } + } + + print "\n"; + undef (%curentry); +} + + +sub parse_netmask +{ + local ($netmask) = @_; + local ($i); + + if ((($a, $b, $c, $d) = $netmask =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) != 4) + { + parse_error (); + } + + $num = (($a & 0xff) << 24) | + (($b & 0xff) << 16) | + (($c & 0xff) << 8) | + ($d & 0xff); + + for ($i=1; $i<=32 && $num & (1 << (32 - $i)); $i++) + { + } + $i--; + + return ($i); +} + + +sub parse_subnet +{ + local ($ip, $tmp, $netmask); + + print_entry () if %curentry; + + $ip = next_token (0); + parse_error () if !defined ($ip); + + $tmp = next_token (1); + parse_error () if !defined ($tmp); + parse_error () if !($tmp eq 'netmask'); + + $tmp = next_token (0); + parse_error () if !defined ($tmp); + $netmask = parse_netmask ($tmp); + + $tmp = next_token (0); + parse_error () if !defined ($tmp); + parse_error () if !($tmp eq '{'); + + add_dn_to_stack ("cn=$ip"); + $curentry{'type'} = 'subnet'; + $curentry{'ip'} = $ip; + $curentry{'netmask'} = $netmask; + $cursubnet = $ip; + $curcounter{$ip} = { pool => 0, group => 0 }; +} + + +sub parse_shared_network +{ + local ($descr, $tmp); + + print_entry () if %curentry; + + $descr = next_token (0); + parse_error () if !defined ($descr); + + $tmp = next_token (0); + parse_error () if !defined ($tmp); + parse_error () if !($tmp eq '{'); + + add_dn_to_stack ("cn=$descr"); + $curentry{'type'} = 'shared-network'; + $curentry{'descr'} = $descr; +} + + +sub parse_host +{ + local ($descr, $tmp); + + print_entry () if %curentry; + + $host = next_token (0); + parse_error () if !defined ($host); + + $tmp = next_token (0); + parse_error () if !defined ($tmp); + parse_error () if !($tmp eq '{'); + + add_dn_to_stack ("cn=$host"); + $curentry{'type'} = 'host'; + $curentry{'host'} = $host; +} + + +sub parse_group +{ + local ($descr, $tmp); + + print_entry () if %curentry; + + $tmp = next_token (0); + parse_error () if !defined ($tmp); + parse_error () if !($tmp eq '{'); + + my $idx; + if(exists($curcounter{$cursubnet})) { + $idx = ++$curcounter{$cursubnet}->{'group'}; + } else { + $idx = ++$curcounter{''}->{'group'}; + } + + add_dn_to_stack ("cn=group".$idx); + $curentry{'type'} = 'group'; + $curentry{'idx'} = $idx; +} + + +sub parse_pool +{ + local ($descr, $tmp); + + print_entry () if %curentry; + + $tmp = next_token (0); + parse_error () if !defined ($tmp); + parse_error () if !($tmp eq '{'); + + my $idx; + if(exists($curcounter{$cursubnet})) { + $idx = ++$curcounter{$cursubnet}->{'pool'}; + } else { + $idx = ++$curcounter{''}->{'pool'}; + } + + add_dn_to_stack ("cn=pool".$idx); + $curentry{'type'} = 'pool'; + $curentry{'idx'} = $idx; +} + + +sub parse_class +{ + local ($descr, $tmp); + + print_entry () if %curentry; + + $class = next_token (0); + parse_error () if !defined ($class); + + $tmp = next_token (0); + parse_error () if !defined ($tmp); + parse_error () if !($tmp eq '{'); + + $class =~ s/\"//g; + add_dn_to_stack ("cn=$class"); + $curentry{'type'} = 'class'; + $curentry{'class'} = $class; +} + + +sub parse_subclass +{ + local ($descr, $tmp); + + print_entry () if %curentry; + + $class = next_token (0); + parse_error () if !defined ($class); + + $subclass = next_token (0); + parse_error () if !defined ($subclass); + + $tmp = next_token (0); + parse_error () if !defined ($tmp); + parse_error () if !($tmp eq '{'); + + add_dn_to_stack ("cn=$subclass"); + $curentry{'type'} = 'subclass'; + $curentry{'class'} = $class; + $curentry{'subclass'} = $subclass; +} + + +sub parse_hwaddress +{ + local ($type, $hw, $tmp); + + $type = next_token (1); + parse_error () if !defined ($type); + + $hw = next_token (1); + parse_error () if !defined ($hw); + $hw =~ s/;$//; + + $curentry{'hwaddress'} = "$type $hw"; +} + + +sub parse_range +{ + local ($tmp, $str); + + $str = remaining_line (); + + if (!($str eq '')) + { + $str =~ s/;$//; + push (@{$curentry{'ranges'}}, $str); + } +} + + +sub parse_statement +{ + local ($token) = shift; + local ($str); + + if ($token eq 'option') + { + $str = remaining_line (); + push (@{$curentry{'options'}}, $str); + } + elsif($token eq 'failover') + { + $str = remaining_line (1); # take care on block + if($str =~ /[{]/) + { + my ($peername, @statements); + + parse_error() if($str !~ /^\s*peer\s+(.+?)\s+[{]\s*$/); + parse_error() if(($peername = $1) !~ /^\"?[^\"]+\"?$/); + + # + # failover config block found: + # e.g. 'failover peer "some-name" {' + # + if(not grep(/FaIlOvEr/i, @use)) + { + print STDERR "Warning: Failover config 'peer $peername' found!\n"; + print STDERR " Skipping it, since failover disabled!\n"; + print STDERR " You may try out --use=failover option.\n"; + } + + until($str =~ /[}]/ or $str eq "") + { + $str = remaining_line (1); + # collect all statements, except ending '}' + push(@statements, $str) if($str !~ /[}]/); + } + $failover{$peername} = [@statements]; + } + else + { + # + # pool reference to failover config is fine + # e.g. 'failover peer "some-name";' + # + if(not grep(/FaIlOvEr/i, @use)) + { + print STDERR "Warning: Failover reference '$str' found!\n"; + print STDERR " Skipping it, since failover disabled!\n"; + print STDERR " You may try out --use=failover option.\n"; + } + else + { + push (@{$curentry{'statements'}}, $token. " " . $str); + } + } + } + elsif($token eq 'zone') + { + $str = $token; + while($str !~ /}$/) { + $str .= ' ' . next_token (0); + } + push (@{$curentry{'statements'}}, $str); + } + elsif($token =~ /^(authoritative)[;]*$/) + { + push (@{$curentry{'statements'}}, $1); + } + else + { + $str = $token . " " . remaining_line (); + push (@{$curentry{'statements'}}, $str); + } +} + + +my $ok = GetOptions( + 'basedn=s' => \$basedn, + 'dhcpdn=s' => \$dhcpdn, + 'server=s' => \$server, + 'second=s' => \$second, + 'conf=s' => \$i_conf, + 'ldif=s' => \$o_ldif, + 'use=s' => \@use, + 'h|help|usage' => sub { usage(0); }, +); + +unless($server =~ /^\w+/) + { + usage(1, "invalid server name '$server'"); + } +unless($basedn =~ /^\w+=[^,]+/) + { + usage(1, "invalid base dn '$basedn'"); + } + +if($dhcpdn =~ /^cn=([^,]+)/i) + { + $dhcpcn = "$1"; + } +$second = '' if not defined $second; +unless($second eq '' or $second =~ /^cn=[^,]+\s*,\s*\w+=[^,]+/i) + { + if($second =~ /^cn=[^,]+$/i) + { + # relative DN 'cn=name' + $second = "$second, $basedn"; + } + elsif($second =~ /^\w+/) + { + # assume hostname only + $second = "cn=$second, $basedn"; + } + else + { + usage(1, "invalid secondary '$second'") + } + } + +usage(1) unless($ok); + +if($i_conf ne "" and -f $i_conf) + { + if(not open(STDIN, '<', $i_conf)) + { + print STDERR "Error: can't open conf file '$i_conf': $!\n"; + exit(1); + } + } +if($o_ldif ne "") + { + if(-e $o_ldif) + { + print STDERR "Error: output ldif name '$o_ldif' already exists!\n"; + exit(1); + } + if(not open(STDOUT, '>', $o_ldif)) + { + print STDERR "Error: can't open ldif file '$o_ldif': $!\n"; + exit(1); + } + } + + +print STDERR "Creating LDAP Configuration with the following options:\n"; +print STDERR "\tBase DN: $basedn\n"; +print STDERR "\tDHCP DN: $dhcpdn\n"; +print STDERR "\tServer DN: cn=$server, $basedn\n"; +print STDERR "\tSecondary DN: $second\n" + if(grep(/FaIlOvEr/i, @use) and $second ne ''); +print STDERR "\n"; + +my $token; +my $token_number = 0; +my $line_number = 0; +my %curentry; +my $cursubnet = ''; +my %curcounter = ( '' => { pool => 0, group => 0 } ); + +$current_dn = "$dhcpdn"; +$curentry{'descr'} = $dhcpcn; +$line = ''; +%failover = (); + +while (($token = next_token (1))) + { + if ($token eq '}') + { + print_entry () if %curentry; + if($current_dn =~ /.+?,\s*${dhcpdn}$/) { + # don't go below dhcpdn ... + remove_dn_from_stack (); + } + } + elsif ($token eq 'subnet') + { + parse_subnet (); + next; + } + elsif ($token eq 'shared-network') + { + parse_shared_network (); + next; + } + elsif ($token eq 'class') + { + parse_class (); + next; + } + elsif ($token eq 'subclass') + { + parse_subclass (); + next; + } + elsif ($token eq 'pool') + { + parse_pool (); + next; + } + elsif ($token eq 'group') + { + parse_group (); + next; + } + elsif ($token eq 'host') + { + parse_host (); + next; + } + elsif ($token eq 'hardware') + { + parse_hwaddress (); + next; + } + elsif ($token eq 'range') + { + parse_range (); + next; + } + else + { + parse_statement ($token); + next; + } + } + +close(STDIN) if($i_conf); +close(STDOUT) if($o_ldif); + +print STDERR "Done.\n"; + diff --git a/dhcpd.conf b/dhcpd.conf new file mode 100644 index 0000000..d09772d --- /dev/null +++ b/dhcpd.conf @@ -0,0 +1,4 @@ +# +# DHCP Server Configuration file. +# see /usr/share/doc/dhcp*/dhcpd.conf.sample +# \ No newline at end of file