1 /* $NetBSD: client_tables.c,v 1.2 2018/04/07 22:37:29 christos Exp $ */ 2 3 /* client_tables.c 4 5 Tables of information only used by client... */ 6 7 /* 8 * Copyright (c) 2017 by Internet Systems Consortium, Inc. ("ISC") 9 * 10 * This Source Code Form is subject to the terms of the Mozilla Public 11 * License, v. 2.0. If a copy of the MPL was not distributed with this 12 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 20 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 * 22 * Internet Systems Consortium, Inc. 23 * 950 Charter Street 24 * Redwood City, CA 94063 25 * <info@isc.org> 26 * https://www.isc.org/ 27 * 28 */ 29 30 #include <sys/cdefs.h> 31 __RCSID("$NetBSD: client_tables.c,v 1.2 2018/04/07 22:37:29 christos Exp $"); 32 33 #include "dhcpd.h" 34 35 struct universe client_universe; 36 static struct option client_options[] = { 37 /* @todo dummy-client-parm should be removed with the first real param */ 38 { "dummy-client-parm", "T", &client_universe, 1, 1 }, 39 { NULL, NULL, NULL, 0, 0 } 40 }; 41 42 #define CLIENT_HASH_SIZE (2*(sizeof(client_options) / sizeof(struct option))) 43 44 void initialize_client_option_spaces(void); 45 void initialize_client_option_spaces(void) 46 { 47 int i; 48 49 /* Set up the client option universe... */ 50 client_universe.name = "client"; 51 client_universe.concat_duplicates = 0; 52 client_universe.lookup_func = lookup_hashed_option; 53 client_universe.option_state_dereference = 54 hashed_option_state_dereference; 55 client_universe.save_func = save_hashed_option; 56 client_universe.delete_func = delete_hashed_option; 57 client_universe.encapsulate = hashed_option_space_encapsulate; 58 client_universe.foreach = hashed_option_space_foreach; 59 client_universe.length_size = 1; /* Never used ... */ 60 client_universe.tag_size = 4; 61 client_universe.store_tag = putUChar; 62 client_universe.store_length = putUChar; 63 client_universe.site_code_min = 0; 64 client_universe.end = 0; 65 client_universe.index = universe_count++; 66 universes [client_universe.index] = &client_universe; 67 if (!option_name_new_hash(&client_universe.name_hash, 68 CLIENT_HASH_SIZE, MDL) || 69 !option_code_new_hash(&client_universe.code_hash, 70 CLIENT_HASH_SIZE, MDL)) 71 log_fatal ("Can't allocate client option hash table."); 72 for (i = 0 ; client_options[i].name ; i++) { 73 option_code_hash_add(client_universe.code_hash, 74 &client_options[i].code, 0, 75 &client_options[i], MDL); 76 option_name_hash_add(client_universe.name_hash, 77 client_options[i].name, 0, 78 &client_options[i], MDL); 79 } 80 81 /* Add the client option space to the option space hash. */ 82 universe_hash_add (universe_hash, 83 client_universe.name, 0, &client_universe, MDL); 84 85 /* Make the client universe the configuration option universe. */ 86 config_universe = &client_universe; 87 } 88