]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- ./configure was extended to cover many optional build features, such
authorDavid Hankins <dhankins@isc.org>
Thu, 28 Feb 2008 21:21:56 +0000 (21:21 +0000)
committerDavid Hankins <dhankins@isc.org>
Thu, 28 Feb 2008 21:21:56 +0000 (21:21 +0000)
  as failover, server tracing, debugging, and the execute() command.
  [ISC-Bugs #17678]

14 files changed:
RELNOTES
common/execute.c
common/parse.c
configure.ac
includes/site.h
minires/res_init.c
minires/res_mkupdate.c
minires/res_query.c
omapip/buffer.c
omapip/connection.c
omapip/mrtrace.c
server/dhcp.c
server/dhcpd.c
server/mdb.c

index dd06e76ef54957f5c9f81fdae0e6084bd1cd2c5e..3fe70bac27a15c27fbfb04a824c3318e35d034f2 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -54,6 +54,9 @@ work on other platforms. Please report any problems and suggested fixes to
   via two ./configure parameters, --enable-paranoia and
   --enable-early-chroot.
 
+- ./configure was extended to cover many optional build features, such
+  as failover, server tracing, debugging, and the execute() command.
+
                        Changes since 4.0.0 (new features)
 
 - Added DHCPv6 rapid commit support.
index ac63b08431a3ae5243a531f989588375dda6d3b2..0e8ef18cf71634c7ae07b1ce2eec4b27e1298dae 100644 (file)
@@ -729,8 +729,10 @@ void write_statements (file, statements, indent)
        struct executable_statement *statements;
        int indent;
 {
-       struct executable_statement *r, *x;
+#if defined ENABLE_EXECUTE
        struct expression *expr;
+#endif
+       struct executable_statement *r, *x;
        const char *s, *t, *dot;
        int col;
 
index 041a0de860f5c3c84fe2b4bc20fd7a710f3b81af..eea0925e61767f98c93ca8bc18f6442c66d477d3 100644 (file)
@@ -2017,13 +2017,15 @@ int parse_executable_statement (result, cfile, lose, case_context)
        int *lose;
        enum expression_context case_context;
 {
+#if defined(ENABLE_EXECUTE)
+       unsigned len;
+       struct expression **ep;
+#endif
        enum dhcp_token token;
        const char *val;
-       unsigned len;
        struct class *cta;
        struct option *option=NULL;
        struct option_cache *cache;
-       struct expression **ep;
        int known;
        int flag;
        int i;
index f09ad129d6ac25b1b82ea45635aae7b805a04b5d..24a7678513940d460ba4f3f91e3de236ff505b27 100644 (file)
@@ -30,10 +30,72 @@ AC_DEFINE_UNQUOTED([DHCP_BYTE_ORDER], [$byte_order],
                   [Define to BIG_ENDIAN for MSB (Motorola or SPARC CPUs)
                    or LITTLE_ENDIAN for LSB (Intel CPUs).])
 
-# DHCPv6 is off by default
+# Optional compile-time DEBUGging.
+AC_ARG_ENABLE(debug,
+       AC_HELP_STRING([--enable-debug],
+               [create a debug-only version of the software (default is no).]))
+# This is very much off by default.
+if test "$enable_debug" = "yes" ; then
+       AC_DEFINE([DEBUG], [1],
+               [Define to compile debug-only DHCP software.])
+       # Just override CFLAGS to totally to remove optimization.
+       CFLAGS="-g"
+fi
+# XXX: there are actually quite a lot more DEBUG_ features we could enable,
+# but I don't want to pollute the --help space.
+#
+#/* #define DEBUG_TOKENS */
+#/* #define DEBUG_PACKET */
+#/* #define DEBUG_EXPRESSIONS */
+#/* #define DEBUG_FIND_LEASE */
+#/* #define DEBUG_EXPRESSION_PARSE */
+#/* #define DEBUG_CLASS_MATCHING */
+#/* #define DEBUG_MEMORY_LEAKAGE */
+#/* #define DEBUG_MALLOC_POOL */
+#/* #define DEBUG_LEASE_STATE_TRANSITIONS */
+#/* #define DEBUG_RC_HISTORY */
+#/* #define DEBUG_RC_HISTORY_EXHAUSTIVELY */
+#/* #define RC_HISTORY_MAX 10240 */
+#/* #define POINTER_DEBUG */
+#/* #define DEBUG_FAILOVER_MESSAGES */
+#/* #define DEBUG_FAILOVER_TIMING */
+#/* #define DEBUG_DUMP_ALL_LEASES */
+
+# Failover optional compile-time feature.
+AC_ARG_ENABLE(failover,
+       AC_HELP_STRING([--enable-failover],
+               [enable support for failover (default is yes)]))
+# Failover is on by default, so define if it is not explicitly disabled.
+if test "$enable_failover" != "no"; then
+       AC_DEFINE([FAILOVER_PROTOCOL], [1],
+                 [Define to include Failover Protocol support.])
+fi
+
+# execute() support.
+AC_ARG_ENABLE(execute,
+       AC_HELP_STRING([--enable-execute],
+               [enable support for execute() in config (default is yes)]))
+# execute() is on by default, so define if it is not explicitly disabled.
+if test "$enable_execute" != "no" ; then
+       AC_DEFINE([ENABLE_EXECUTE], [1],
+                 [Define to include execute() config language support.])
+fi
+
+# Server tracing support.
+AC_ARG_ENABLE(tracing,
+       AC_HELP_STRING([--enable-tracing],
+               [enable support for server activity tracing (default is yes)]))
+# tracing is on by default, so define if it is not explicitly disabled.
+if test "$enable_tracing" != "no" ; then
+       AC_DEFINE([TRACING], [1],
+                 [Define to include server activity tracing support.])
+fi
+
+# DHCPv6 optional compile-time feature.
 AC_ARG_ENABLE(dhcpv6,
        AC_HELP_STRING([--enable-dhcpv6],
                       [enable support for DHCPv6 (default is yes)]))
+# DHCPv6 is on by default, so define if it is not explicitly disabled.
 if test "$enable_dhcpv6" != "no"; then
        AC_DEFINE([DHCPv6], [1], 
                  [Define to 1 to include DHCPv6 support.])
index 98d332540a97e798c98d8ff1528f58fbcd70822f..dc81ae7bc0c12cfc066cc32f80ddc3e2a8bc160a 100644 (file)
@@ -94,7 +94,7 @@
 /* Define this if you want DHCP failover protocol support in the DHCP
    server. */
 
-#define FAILOVER_PROTOCOL
+/* #define FAILOVER_PROTOCOL */
 
 /* Define this if you want DNS update functionality to be available. */
 
 /* Define this if you want to be able to execute external commands
    during conditional evaluation. */
 
-#define ENABLE_EXECUTE
+/* #define ENABLE_EXECUTE */
 
 /* Define this if you aren't debugging and you want to save memory
    (potentially a _lot_ of memory) by allocating leases in chunks rather
 /* Define this if you want to be able to save and playback server operational
    traces. */
 
-#define TRACING
+/* #define TRACING */
index b96b326bc2d9da9a8404aa5d7816f0487aab1b56..b38fdbf0808a633a717ef1d3777fd5bd359853c9 100644 (file)
@@ -76,7 +76,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)res_init.c   8.1 (Berkeley) 6/7/93";
-static const char rcsid[] = "$Id: res_init.c,v 1.10 2007/10/01 14:47:35 explorer Exp $";
+static const char rcsid[] = "$Id: res_init.c,v 1.11 2008/02/28 21:21:56 dhankins Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -99,7 +99,6 @@ static const char rcsid[] = "$Id: res_init.c,v 1.10 2007/10/01 14:47:35 explorer
 /* Options.  Should all be left alone. */
 #define RESOLVSORT
 #define RFC1535
-#define DEBUG
 
 static void res_setoptions (res_state, const char *, const char *);
 
@@ -389,14 +388,12 @@ minires_vinit(res_state statp, int preinit) {
                        dots--;
                }
                *pp = NULL;
-#ifdef DEBUG
                if (statp->options & RES_DEBUG) {
                        printf(";; res_init()... default dnsrch list:\n");
                        for (pp = statp->dnsrch; *pp; pp++)
                                printf(";;\t%s\n", *pp);
                        printf(";;\t..END..\n");
                }
-#endif
 #endif /* !RFC1535 */
        }
 
@@ -411,11 +408,9 @@ res_setoptions(res_state statp, const char *options, const char *source) {
        const char *cp = options;
        int i;
 
-#ifdef DEBUG
        if (statp->options & RES_DEBUG)
                printf(";; res_setoptions(\"%s\", \"%s\")...\n",
                       options, source);
-#endif
        while (*cp) {
                /* skip leading and inner runs of spaces */
                while (*cp == ' ' || *cp == '\t')
@@ -427,10 +422,8 @@ res_setoptions(res_state statp, const char *options, const char *source) {
                                statp->ndots = i;
                        else
                                statp->ndots = RES_MAXNDOTS;
-#ifdef DEBUG
                        if (statp->options & RES_DEBUG)
                                printf(";;\tndots=%d\n", statp->ndots);
-#endif
                } else if (!strncmp(cp, "timeout:", sizeof("timeout:") - 1)) {
                        i = atoi(cp + sizeof("timeout:") - 1);
                        if (i <= RES_MAXRETRANS)
@@ -444,14 +437,12 @@ res_setoptions(res_state statp, const char *options, const char *source) {
                        else
                                statp->retry = RES_MAXRETRY;
                } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) {
-#ifdef DEBUG
                        if (!(statp->options & RES_DEBUG)) {
                                printf(";; res_setoptions(\"%s\", \"%s\")..\n",
                                       options, source);
                                statp->options |= RES_DEBUG;
                        }
                        printf(";;\tdebug\n");
-#endif
                } else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) {
                        statp->options |= RES_USE_INET6;
                } else if (!strncmp(cp, "rotate", sizeof("rotate") - 1)) {
index f8d8400413d6263bc42968a2a018d01c68ef4983..368bcb055ffcb0c10c0fe10ba31faba601b70617 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 #if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_mkupdate.c,v 1.11 2007/07/13 06:43:42 shane Exp $";
+static const char rcsid[] = "$Id: res_mkupdate.c,v 1.12 2008/02/28 21:21:56 dhankins Exp $";
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -50,7 +50,6 @@ static const char rcsid[] = "$Id: res_mkupdate.c,v 1.11 2007/07/13 06:43:42 shan
 #include "arpa/nameser.h"
 
 /* Options.  Leave them on. */
-#define DEBUG
 #define MAXPORT 1024
 
 static int getnum_str(const u_char **, const u_char *);
index ff119e4ce06a1a87630951ce13f96ea502725895..606c984ccdfa106456a96407541393381fb4c97e 100644 (file)
@@ -76,7 +76,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)res_query.c  8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_query.c,v 1.8 2007/09/05 17:32:10 dhankins Exp $";
+static const char rcsid[] = "$Id: res_query.c,v 1.9 2008/02/28 21:21:56 dhankins Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -95,8 +95,6 @@ static const char rcsid[] = "$Id: res_query.c,v 1.8 2007/09/05 17:32:10 dhankins
 #include "arpa/nameser.h"
 
 /* Options.  Leave them on. */
-#define DEBUG
-
 #if PACKETSZ > 1024
 #define MAXPACKET      PACKETSZ
 #else
@@ -128,37 +126,29 @@ res_nquery(res_state statp,
 
        hp->rcode = NOERROR;    /* default */
 
-#ifdef DEBUG
        if (statp->options & RES_DEBUG)
                printf(";; res_query(%s, %d, %d)\n", name, class, type);
-#endif
 
        rcode = res_nmkquery(statp, QUERY, name, class, type, NULL, 0, NULL,
                             buf, sizeof(buf), &n);
        if (rcode != ISC_R_SUCCESS) {
-#ifdef DEBUG
                if (statp->options & RES_DEBUG)
                        printf(";; res_query: mkquery failed\n");
-#endif
                RES_SET_H_ERRNO(statp, NO_RECOVERY);
                return rcode;
        }
        rcode = res_nsend(statp, buf, n, answer, anslen, &n);
        if (rcode != ISC_R_SUCCESS) {
-#ifdef DEBUG
                if (statp->options & RES_DEBUG)
                        printf(";; res_query: send error\n");
-#endif
                RES_SET_H_ERRNO(statp, TRY_AGAIN);
                return rcode;
        }
 
        if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
-#ifdef DEBUG
                if (statp->options & RES_DEBUG)
                        printf(";; rcode = %d, ancount=%d\n", hp->rcode,
                            ntohs(hp->ancount));
-#endif
                switch (hp->rcode) {
                case NXDOMAIN:
                        RES_SET_H_ERRNO(statp, HOST_NOT_FOUND);
@@ -347,11 +337,9 @@ res_nquerydomain(res_state statp,
        const char *longname = nbuf;
        int n, d;
 
-#ifdef DEBUG
        if (statp->options & RES_DEBUG)
                printf(";; res_nquerydomain(%s, %s, %d, %d)\n",
                       name, domain?domain:"<Nil>", class, type);
-#endif
        if (domain == NULL) {
                /*
                 * Check for trailing '.';
index 4e85128036e4433fe240f018f9136a53cab7ff9c..4204574c1361621d74ece4e79c48c7e22e02fdf9 100644 (file)
@@ -442,7 +442,6 @@ isc_result_t omapi_connection_writer (omapi_object_t *h)
        unsigned first_byte;
        omapi_buffer_t *buffer;
        omapi_connection_object_t *c;
-       isc_result_t status;
 
        if (!h || h -> type != omapi_type_connection)
                return ISC_R_INVALIDARG;
@@ -504,6 +503,7 @@ isc_result_t omapi_connection_writer (omapi_object_t *h)
 
 #if defined (TRACING)
                        if (trace_record ()) {
+                               isc_result_t status;
                                trace_iov_t iov [2];
                                int32_t connect_index;
                                
index 618eaa758b67b9b685adcf4d29fa54182aa8adb4..93509696edf0ca92942fb7f7254af6b776170b3b 100644 (file)
@@ -437,7 +437,6 @@ isc_result_t omapi_disconnect (omapi_object_t *h,
                               int force)
 {
        omapi_connection_object_t *c;
-       isc_result_t status;
 
 #ifdef DEBUG_PROTOCOL
        log_debug ("omapi_disconnect(%s)", force ? "force" : "");
@@ -449,6 +448,7 @@ isc_result_t omapi_disconnect (omapi_object_t *h,
 
 #if defined (TRACING)
        if (trace_record ()) {
+               isc_result_t status;
                int32_t index;
 
                index = htonl (c -> index);
index 838e304c5635f88399250a881994dfb1ab1071e0..c3fe8606336e8fa59937d822e075f47207370080 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <errno.h>
 
+#if defined(TRACING)
 static void trace_mr_output_input (trace_type_t *, unsigned, char *);
 static void trace_mr_output_stop (trace_type_t *);
 static void trace_mr_input_input (trace_type_t *, unsigned, char *);
@@ -46,6 +47,7 @@ static void trace_mr_statp_input (trace_type_t *, unsigned, char *);
 static void trace_mr_statp_stop (trace_type_t *);
 static void trace_mr_randomid_input (trace_type_t *, unsigned, char *);
 static void trace_mr_randomid_stop (trace_type_t *);
+#endif /* TRACING */
 trace_type_t *trace_mr_output;
 trace_type_t *trace_mr_input;
 trace_type_t *trace_mr_statp;
@@ -404,9 +406,9 @@ int trace_mr_select (int s, fd_set *r, fd_set *w, fd_set *x, struct timeval *t)
 
 unsigned int trace_mr_res_randomid (unsigned int oldid)
 {
-       u_int32_t id;
        int rid = oldid;
 #if defined (TRACING)
+       u_int32_t id;
        unsigned buflen = 0;
        char *buf = (char *)0;
        isc_result_t status;
index 93a594ac4030a4c9ef46e948b9c4c349f15dfced..7376932e3dd5bfa6c3c35c18275d5b928e196079 100644 (file)
@@ -796,7 +796,9 @@ void dhcprelease (packet, ms_nulltp)
                release_lease (lease, packet);
        } 
        log_info ("%s", msgbuf);
+#if defined(FAILOVER_PROTOCOL)
       out:
+#endif
        if (lease)
                lease_dereference (&lease, MDL);
 }
@@ -918,8 +920,10 @@ void dhcpdecline (packet, ms_nulltp)
 
        if (!ignorep)
                log_info ("%s: %s", msgbuf, status);
-               
+
+#if defined(FAILOVER_PROTOCOL)
       out:
+#endif
        if (options)
                option_state_dereference (&options, MDL);
        if (lease)
@@ -3153,6 +3157,7 @@ int find_lease (struct lease **lp,
        struct data_string client_identifier;
        struct hardware h;
 
+#if defined(FAILOVER_PROTOCOL)
        /* Quick check to see if the peer has leases. */
        if (peer_has_leases) {
                struct pool *pool;
@@ -3168,6 +3173,7 @@ int find_lease (struct lease **lp,
                        }
                }
        }
+#endif /* FAILOVER_PROTOCOL */
 
        if (packet -> raw -> ciaddr.s_addr) {
                cip.len = 4;
@@ -3487,7 +3493,9 @@ int find_lease (struct lease **lp,
           is not active, and is not ours to reallocate, forget about it. */
        if (ip_lease && (uid_lease || hw_lease) &&
            ip_lease -> binding_state != FTS_ACTIVE &&
+#if defined(FAILOVER_PROTOCOL)
            !lease_mine_to_reallocate (ip_lease) &&
+#endif
            packet -> packet_type == DHCPDISCOVER) {
 #if defined (DEBUG_FIND_LEASE)
                log_info ("ip lease not ours to offer.");
index c6084df319266f716305f1f6a9ba2f1de8fdb7a2..3540e53285470c202f63b7be12525e16e2464981 100644 (file)
@@ -1342,8 +1342,8 @@ isc_result_t dhcp_io_shutdown (omapi_object_t *obj, void *foo)
 
 static isc_result_t dhcp_io_shutdown_countdown (void *vlp)
 {
-       dhcp_failover_state_t *state;
 #if defined (FAILOVER_PROTOCOL)
+       dhcp_failover_state_t *state;
        int failover_connection_count = 0;
 #endif
        struct timeval tv;
index 43104b4d186ef16f058d88cda3252d2cb79ff939..42b3abc6c9efd1c517b2c792dba7e05beee90a05 100644 (file)
@@ -1515,6 +1515,7 @@ void make_binding_state_transition (struct lease *lease)
              case FTS_ABANDONED:
              case FTS_RESET:
                lease -> next_binding_state = FTS_FREE;
+#if defined(FAILOVER_PROTOCOL)
                /* If we are not in partner_down, leases don't go from
                   EXPIRED to FREE on a timeout - only on an update.
                   If we're in partner_down, they expire at mclt past
@@ -1524,6 +1525,7 @@ void make_binding_state_transition (struct lease *lease)
                        lease -> tsfp =
                            (lease -> pool -> failover_peer -> me.stos +
                             lease -> pool -> failover_peer -> mclt);
+#endif /* FAILOVER_PROTOCOL */
                break;
 
              case FTS_FREE: