]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
[master] Added client_universe to dhclient
authorThomas Markwalder <tmark@isc.org>
Mon, 27 Nov 2017 11:52:52 +0000 (06:52 -0500)
committerThomas Markwalder <tmark@isc.org>
Mon, 27 Nov 2017 11:52:52 +0000 (06:52 -0500)
    Merges in rt46616.

client/Makefile.am
client/Makefile.in
client/client_tables.c [new file with mode: 0644]
client/dhclient.c

index b6a45c64a056bdc655ea0b6982607bc5bc7442c3..d17715982ad9324f8a45af141b728814c27f11b7 100644 (file)
@@ -9,7 +9,7 @@ AM_CPPFLAGS += -DLOCALSTATEDIR='"$(localstatedir)"'
 
 dist_sysconf_DATA = dhclient.conf.example
 sbin_PROGRAMS = dhclient
-dhclient_SOURCES = clparse.c dhclient.c dhc6.c \
+dhclient_SOURCES = client_tables.c clparse.c dhclient.c dhc6.c \
                   scripts/bsdos scripts/freebsd scripts/linux scripts/macos \
                   scripts/netbsd scripts/nextstep scripts/openbsd \
                   scripts/solaris scripts/openwrt
index a2510ea124e2bf6c4daa2d74ab2bc5fbff4cd190..8ec43f0da1c60792988d7ffca3583c2f413ec12f 100644 (file)
@@ -104,8 +104,8 @@ CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man5dir)" \
        "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(sysconfdir)"
 PROGRAMS = $(sbin_PROGRAMS)
-am_dhclient_OBJECTS = clparse.$(OBJEXT) dhclient.$(OBJEXT) \
-       dhc6.$(OBJEXT)
+am_dhclient_OBJECTS = client_tables.$(OBJEXT) clparse.$(OBJEXT) \
+       dhclient.$(OBJEXT) dhc6.$(OBJEXT)
 dhclient_OBJECTS = $(am_dhclient_OBJECTS)
 dhclient_DEPENDENCIES = ../common/libdhcp.@A@ ../omapip/libomapi.@A@
 AM_V_P = $(am__v_P_@AM_V@)
@@ -369,7 +369,7 @@ SUBDIRS = . tests
 AM_CPPFLAGS = -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"' \
        -DLOCALSTATEDIR='"$(localstatedir)"'
 dist_sysconf_DATA = dhclient.conf.example
-dhclient_SOURCES = clparse.c dhclient.c dhc6.c \
+dhclient_SOURCES = client_tables.c clparse.c dhclient.c dhc6.c \
                   scripts/bsdos scripts/freebsd scripts/linux scripts/macos \
                   scripts/netbsd scripts/nextstep scripts/openbsd \
                   scripts/solaris scripts/openwrt
@@ -468,6 +468,7 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client_tables.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clparse.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dhc6.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dhclient.Po@am__quote@
diff --git a/client/client_tables.c b/client/client_tables.c
new file mode 100644 (file)
index 0000000..41a3885
--- /dev/null
@@ -0,0 +1,81 @@
+/* client_tables.c
+
+   Tables of information only used by client... */
+
+/*
+ * Copyright (c) 2017 by Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *   Internet Systems Consortium, Inc.
+ *   950 Charter Street
+ *   Redwood City, CA 94063
+ *   <info@isc.org>
+ *   https://www.isc.org/
+ *
+ */
+
+#include "dhcpd.h"
+
+struct universe client_universe;
+static struct option client_options[] = {
+    /* @todo dummy-client-parm should be removed with the first real param */
+       { "dummy-client-parm", "T",             &client_universe,   1, 1 },
+       { NULL, NULL, NULL, 0, 0 }
+};
+
+#define CLIENT_HASH_SIZE (2*(sizeof(client_options) / sizeof(struct option)))
+
+void initialize_client_option_spaces()
+{
+       int i;
+
+       /* Set up the client option universe... */
+       client_universe.name = "client";
+       client_universe.concat_duplicates = 0;
+       client_universe.lookup_func = lookup_hashed_option;
+       client_universe.option_state_dereference =
+               hashed_option_state_dereference;
+       client_universe.save_func = save_hashed_option;
+       client_universe.delete_func = delete_hashed_option;
+       client_universe.encapsulate = hashed_option_space_encapsulate;
+       client_universe.foreach = hashed_option_space_foreach;
+       client_universe.length_size = 1; /* Never used ... */
+       client_universe.tag_size = 4;
+       client_universe.store_tag = putUChar;
+       client_universe.store_length = putUChar;
+       client_universe.site_code_min = 0;
+       client_universe.end = 0;
+       client_universe.index = universe_count++;
+       universes [client_universe.index] = &client_universe;
+       if (!option_name_new_hash(&client_universe.name_hash,
+                                 CLIENT_HASH_SIZE, MDL) ||
+           !option_code_new_hash(&client_universe.code_hash,
+                                 CLIENT_HASH_SIZE, MDL))
+               log_fatal ("Can't allocate client option hash table.");
+       for (i = 0 ; client_options[i].name ; i++) {
+               option_code_hash_add(client_universe.code_hash,
+                                    &client_options[i].code, 0,
+                                    &client_options[i], MDL);
+               option_name_hash_add(client_universe.name_hash,
+                                    client_options[i].name, 0,
+                                    &client_options[i], MDL);
+       }
+
+       /* Add the client option space to the option space hash. */
+       universe_hash_add (universe_hash,
+                          client_universe.name, 0, &client_universe, MDL);
+
+       /* Make the client universe the configuration option universe. */
+       config_universe = &client_universe;
+}
index 081783b449f617e9dd320ed755f03843f7d23de3..46efee504442b35acd7bce12a395a228e49b3e5f 100644 (file)
@@ -197,6 +197,8 @@ usage(const char *sfmt, const char *sarg)
                  DHCLIENT_USAGEH);
 }
 
+extern void initialize_client_option_spaces();
+
 int
 main(int argc, char **argv) {
        int fd;
@@ -229,7 +231,6 @@ main(int argc, char **argv) {
 #else
        progname = argv[0];
 #endif
-
        /* Initialize client globals. */
        memset(&default_duid, 0, sizeof(default_duid));
 
@@ -573,6 +574,9 @@ main(int argc, char **argv) {
        /* Set up the initial dhcp option universe. */
        initialize_common_option_spaces();
 
+       /* Set up the initial client option universe. */
+       initialize_client_option_spaces();
+
        /* Assign v4 or v6 specific running parameters. */
        if (local_family == AF_INET)
                dhcpv4_client_assignments();