diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/Makefile.am | 2 | ||||
-rw-r--r-- | client/Makefile.in | 7 | ||||
-rw-r--r-- | client/client_tables.c | 81 | ||||
-rw-r--r-- | client/dhclient.c | 6 |
4 files changed, 91 insertions, 5 deletions
diff --git a/client/Makefile.am b/client/Makefile.am index b6a45c64..d1771598 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -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 diff --git a/client/Makefile.in b/client/Makefile.in index a2510ea1..8ec43f0d 100644 --- a/client/Makefile.in +++ b/client/Makefile.in @@ -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 index 00000000..41a3885b --- /dev/null +++ b/client/client_tables.c @@ -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; +} diff --git a/client/dhclient.c b/client/dhclient.c index 081783b4..46efee50 100644 --- a/client/dhclient.c +++ b/client/dhclient.c @@ -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(); |