1 /* $NetBSD: stables.c,v 1.3 2020/08/03 21:10:57 christos Exp $ */ 2 3 /* stables.c 4 5 Tables of information only used by server... */ 6 7 /* 8 * Copyright (c) 2004-2019 by Internet Systems Consortium, Inc. ("ISC") 9 * Copyright (c) 1995-2003 by Internet Software Consortium 10 * 11 * This Source Code Form is subject to the terms of the Mozilla Public 12 * License, v. 2.0. If a copy of the MPL was not distributed with this 13 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 16 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 18 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 20 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 21 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 * 23 * Internet Systems Consortium, Inc. 24 * 950 Charter Street 25 * Redwood City, CA 94063 26 * <info@isc.org> 27 * https://www.isc.org/ 28 * 29 */ 30 31 #include <sys/cdefs.h> 32 __RCSID("$NetBSD: stables.c,v 1.3 2020/08/03 21:10:57 christos Exp $"); 33 34 #include "dhcpd.h" 35 #include <syslog.h> 36 37 #if defined (FAILOVER_PROTOCOL) 38 39 /* This is used to indicate some kind of failure when generating a 40 failover option. */ 41 failover_option_t null_failover_option = { 0, 0 }; 42 failover_option_t skip_failover_option = { 0, 0 }; 43 44 /* Information about failover options, for printing, encoding 45 and decoding. */ 46 struct failover_option_info ft_options [] = 47 { 48 { 0, "unused", FT_UNDEF, 0, 0, 0 }, 49 { FTO_ADDRESSES_TRANSFERRED, "addresses-transferred", FT_UINT32, 1, 50 FM_OFFSET(addresses_transferred), FTB_ADDRESSES_TRANSFERRED }, 51 { FTO_ASSIGNED_IP_ADDRESS, "assigned-IP-address", FT_IPADDR, 1, 52 FM_OFFSET(assigned_addr), FTB_ASSIGNED_IP_ADDRESS }, 53 { FTO_BINDING_STATUS, "binding-status", FT_UINT8, 1, 54 FM_OFFSET(binding_status), FTB_BINDING_STATUS }, 55 { FTO_CLIENT_IDENTIFIER, "client-identifier", FT_BYTES, 0, 56 FM_OFFSET(client_identifier), FTB_CLIENT_IDENTIFIER }, 57 { FTO_CHADDR, "client-hardware-address", FT_BYTES, 0, 58 FM_OFFSET(chaddr), FTB_CHADDR }, 59 { FTO_CLTT, "client-last-transaction-time", FT_UINT32, 1, 60 FM_OFFSET(cltt), FTB_CLTT }, 61 { FTO_REPLY_OPTIONS, "client-reply-options", FT_BYTES, 0, 62 FM_OFFSET(reply_options), FTB_REPLY_OPTIONS }, 63 { FTO_REQUEST_OPTIONS, "client-request-options", FT_BYTES, 0, 64 FM_OFFSET(request_options), FTB_REQUEST_OPTIONS }, 65 { FTO_DDNS, "DDNS", FT_DDNS, 1, FM_OFFSET(ddns), FTB_DDNS }, 66 { FTO_DELAYED_SERVICE, "delayed-service", FT_UINT8, 1, 67 FM_OFFSET(delayed_service), FTB_DELAYED_SERVICE }, 68 { FTO_HBA, "hash-bucket-assignment", FT_BYTES, 0, 69 FM_OFFSET(hba), FTB_HBA }, 70 { FTO_IP_FLAGS, "IP-flags", FT_UINT16, 1, 71 FM_OFFSET(ip_flags), FTB_IP_FLAGS }, 72 { FTO_LEASE_EXPIRY, "lease-expiration-time", FT_UINT32, 1, 73 FM_OFFSET(expiry), FTB_LEASE_EXPIRY }, 74 { FTO_MAX_UNACKED, "max-unacked-bndupd", FT_UINT32, 1, 75 FM_OFFSET(max_unacked), FTB_MAX_UNACKED }, 76 { FTO_MCLT, "MCLT", FT_UINT32, 1, FM_OFFSET(mclt), FTB_MCLT }, 77 { FTO_MESSAGE, "message", FT_TEXT, 0, 78 FM_OFFSET(message), FTB_MESSAGE }, 79 { FTO_MESSAGE_DIGEST, "message-digest", FT_BYTES, 0, 80 FM_OFFSET(message_digest), FTB_MESSAGE_DIGEST }, 81 { FTO_POTENTIAL_EXPIRY, "potential-expiration-time", FT_UINT32, 1, 82 FM_OFFSET(potential_expiry), FTB_POTENTIAL_EXPIRY }, 83 { FTO_RECEIVE_TIMER, "receive-timer", FT_UINT32, 1, 84 FM_OFFSET(receive_timer), FTB_RECEIVE_TIMER }, 85 { FTO_PROTOCOL_VERSION, "protocol-version", FT_UINT8, 1, 86 FM_OFFSET(protocol_version), FTB_PROTOCOL_VERSION }, 87 { FTO_REJECT_REASON, "reject-reason", FT_UINT8, 1, 88 FM_OFFSET(reject_reason), FTB_REJECT_REASON }, 89 { FTO_RELATIONSHIP_NAME, "relationship-name", FT_BYTES, 0, 90 FM_OFFSET(relationship_name), FTB_RELATIONSHIP_NAME }, 91 { FTO_SERVER_FLAGS, "server-flags", FT_UINT8, 1, 92 FM_OFFSET(server_flags), FTB_SERVER_FLAGS }, 93 { FTO_SERVER_STATE, "server-state", FT_UINT8, 1, 94 FM_OFFSET(server_state), FTB_SERVER_STATE }, 95 { FTO_STOS, "start-time-of-state", FT_UINT32, 1, 96 FM_OFFSET(stos), FTB_STOS }, 97 { FTO_TLS_REPLY, "TLS-reply", FT_UINT8, 1, 98 FM_OFFSET(tls_reply), FTB_TLS_REPLY }, 99 { FTO_TLS_REQUEST, "TLS-request", FT_UINT8, 1, 100 FM_OFFSET(tls_request), FTB_TLS_REQUEST }, 101 { FTO_VENDOR_CLASS, "vendor-class-identifier", FT_BYTES, 0, 102 FM_OFFSET(vendor_class), FTB_VENDOR_CLASS }, 103 { FTO_VENDOR_OPTIONS, "vendor-specific-options", FT_BYTES, 0, 104 FM_OFFSET(vendor_options), FTB_VENDOR_OPTIONS } 105 }; 106 107 /* These are really options that make sense for a particular request - if 108 some other option comes in, we're not going to use it, so we can just 109 discard it. Note that the message-digest option is allowed for all 110 message types, but is not saved - it's just used to validate the message 111 and then discarded - so it's not mentioned here. */ 112 113 u_int32_t fto_allowed [] = { 114 0, /* 0 unused */ 115 0, /* 1 POOLREQ */ 116 FTB_ADDRESSES_TRANSFERRED, /* 2 POOLRESP */ 117 (FTB_ASSIGNED_IP_ADDRESS | FTB_BINDING_STATUS | FTB_CLIENT_IDENTIFIER | 118 FTB_CHADDR | FTB_DDNS | FTB_IP_FLAGS | FTB_LEASE_EXPIRY | 119 FTB_POTENTIAL_EXPIRY | FTB_STOS | FTB_CLTT | FTB_REQUEST_OPTIONS | 120 FTB_REPLY_OPTIONS), /* 3 BNDUPD */ 121 (FTB_ASSIGNED_IP_ADDRESS | FTB_BINDING_STATUS | FTB_CLIENT_IDENTIFIER | 122 FTB_CHADDR | FTB_DDNS | FTB_IP_FLAGS | FTB_LEASE_EXPIRY | 123 FTB_POTENTIAL_EXPIRY | FTB_STOS | FTB_CLTT | FTB_REQUEST_OPTIONS | 124 FTB_REPLY_OPTIONS | FTB_REJECT_REASON | FTB_MESSAGE), /* 4 BNDACK */ 125 (FTB_RELATIONSHIP_NAME | FTB_MAX_UNACKED | FTB_RECEIVE_TIMER | 126 FTB_VENDOR_CLASS | FTB_PROTOCOL_VERSION | FTB_TLS_REQUEST | 127 FTB_MCLT | FTB_HBA), /* 5 CONNECT */ 128 (FTB_RELATIONSHIP_NAME | FTB_MAX_UNACKED | FTB_RECEIVE_TIMER | 129 FTB_VENDOR_CLASS | FTB_PROTOCOL_VERSION | FTB_TLS_REPLY | 130 FTB_REJECT_REASON | FTB_MESSAGE), /* CONNECTACK */ 131 0, /* 7 UPDREQALL */ 132 0, /* 8 UPDDONE */ 133 0, /* 9 UPDREQ */ 134 (FTB_SERVER_STATE | FTB_SERVER_FLAGS | FTB_STOS), /* 10 STATE */ 135 0, /* 11 CONTACT */ 136 (FTB_REJECT_REASON | FTB_MESSAGE) /* 12 DISCONNECT */ 137 }; 138 139 /* Sizes of the various types. */ 140 int ft_sizes [] = { 141 1, /* FT_UINT8 */ 142 4, /* FT_IPADDR */ 143 4, /* FT_UINT32 */ 144 1, /* FT_BYTES */ 145 1, /* FT_TEXT_OR_BYTES */ 146 0, /* FT_DDNS */ 147 0, /* FT_DDNS1 */ 148 2, /* FT_UINT16 */ 149 1, /* FT_TEXT */ 150 0, /* FT_UNDEF */ 151 0, /* FT_DIGEST */ 152 }; 153 154 /* Names of the various failover link states. */ 155 const char *dhcp_flink_state_names [] = { 156 "invalid state 0", 157 "startup", 158 "message length wait", 159 "message wait", 160 "disconnected" 161 }; 162 #endif /* FAILOVER_PROTOCOL */ 163 164 /* Failover binding state names. These are used even if there is no 165 failover protocol support. */ 166 const char *binding_state_names [] = { 167 "free", "active", "expired", "released", "abandoned", 168 "reset", "backup" }; 169 170 struct universe agent_universe; 171 static struct option agent_options[] = { 172 { "circuit-id", "X", &agent_universe, 1, 1 }, 173 { "remote-id", "X", &agent_universe, 2, 1 }, 174 { "agent-id", "I", &agent_universe, 3, 1 }, 175 { "DOCSIS-device-class", "L", &agent_universe, 4, 1 }, 176 { "link-selection", "I", &agent_universe, 5, 1 }, 177 { "relay-port", "Z", &agent_universe, 19, 1 }, 178 { NULL, NULL, NULL, 0, 0 } 179 }; 180 181 struct universe server_universe; 182 static struct option server_options[] = { 183 { "default-lease-time", "T", &server_universe, 1, 1 }, 184 { "max-lease-time", "T", &server_universe, 2, 1 }, 185 { "min-lease-time", "T", &server_universe, 3, 1 }, 186 { "dynamic-bootp-lease-cutoff", "T", &server_universe, 4, 1 }, 187 { "dynamic-bootp-lease-length", "L", &server_universe, 5, 1 }, 188 { "boot-unknown-clients", "f", &server_universe, 6, 1 }, 189 { "dynamic-bootp", "f", &server_universe, 7, 1 }, 190 { "allow-bootp", "f", &server_universe, 8, 1 }, 191 { "allow-booting", "f", &server_universe, 9, 1 }, 192 { "one-lease-per-client", "f", &server_universe, 10, 1 }, 193 { "get-lease-hostnames", "f", &server_universe, 11, 1 }, 194 { "use-host-decl-names", "f", &server_universe, 12, 1 }, 195 { "use-lease-addr-for-default-route", "f", 196 &server_universe, 13, 1 }, 197 { "min-secs", "B", &server_universe, 14, 1 }, 198 { "filename", "t", &server_universe, 15, 1 }, 199 { "server-name", "t", &server_universe, 16, 1 }, 200 { "next-server", "I", &server_universe, 17, 1 }, 201 { "authoritative", "f", &server_universe, 18, 1 }, 202 { "vendor-option-space", "U", &server_universe, 19, 1 }, 203 { "always-reply-rfc1048", "f", &server_universe, 20, 1 }, 204 { "site-option-space", "X", &server_universe, 21, 1 }, 205 { "always-broadcast", "f", &server_universe, 22, 1 }, 206 { "ddns-domainname", "t", &server_universe, 23, 1 }, 207 { "ddns-hostname", "t", &server_universe, 24, 1 }, 208 { "ddns-rev-domainname", "t", &server_universe, 25, 1 }, 209 { "lease-file-name", "t", &server_universe, 26, 1 }, 210 { "pid-file-name", "t", &server_universe, 27, 1 }, 211 { "duplicates", "f", &server_universe, 28, 1 }, 212 { "declines", "f", &server_universe, 29, 1 }, 213 { "ddns-updates", "f", &server_universe, 30, 1 }, 214 { "omapi-port", "S", &server_universe, 31, 1 }, 215 { "local-port", "S", &server_universe, 32, 1 }, 216 { "limited-broadcast-address", "I", &server_universe, 33, 1 }, 217 { "remote-port", "S", &server_universe, 34, 1 }, 218 { "local-address", "I", &server_universe, 35, 1 }, 219 { "omapi-key", "k", &server_universe, 36, 1 }, 220 { "stash-agent-options", "f", &server_universe, 37, 1 }, 221 { "ddns-ttl", "T", &server_universe, 38, 1 }, 222 { "ddns-update-style", "Nddns-styles.", &server_universe, 39, 1 }, 223 { "client-updates", "f", &server_universe, 40, 1 }, 224 { "update-optimization", "f", &server_universe, 41, 1 }, 225 { "ping-check", "f", &server_universe, 42, 1 }, 226 { "update-static-leases", "f", &server_universe, 43, 1 }, 227 { "log-facility", "Nsyslog-facilities.", 228 &server_universe, 44, 1 }, 229 { "do-forward-updates", "f", &server_universe, 45, 1 }, 230 { "ping-timeout", "T", &server_universe, 46, 1 }, 231 { "infinite-is-reserved", "f", &server_universe, 47, 1 }, 232 { "update-conflict-detection", "f", &server_universe, 48, 1 }, 233 { "leasequery", "f", &server_universe, 49, 1 }, 234 { "adaptive-lease-time-threshold", "B", &server_universe, 50, 1 }, 235 { "do-reverse-updates", "f", &server_universe, 51, 1 }, 236 { "fqdn-reply", "f", &server_universe, 52, 1 }, 237 { "preferred-lifetime", "T", &server_universe, 53, 1 }, 238 { "dhcpv6-lease-file-name", "t", &server_universe, 54, 1 }, 239 { "dhcpv6-pid-file-name", "t", &server_universe, 55, 1 }, 240 { "limit-addrs-per-ia", "L", &server_universe, 56, 1 }, 241 { "limit-prefs-per-ia", "L", &server_universe, 57, 1 }, 242 /* Assert a configuration parsing error if delayed-ack isn't compiled in. */ 243 #if defined(DELAYED_ACK) 244 { "delayed-ack", "S", &server_universe, 58, 1 }, 245 { "max-ack-delay", "L", &server_universe, 59, 1 }, 246 #endif 247 #if defined(LDAP_CONFIGURATION) 248 { "ldap-server", "t", &server_universe, 60, 1 }, 249 { "ldap-port", "L", &server_universe, 61, 1 }, 250 { "ldap-username", "t", &server_universe, 62, 1 }, 251 { "ldap-password", "t", &server_universe, 63, 1 }, 252 { "ldap-base-dn", "t", &server_universe, 64, 1 }, 253 { "ldap-method", "Nldap-methods.", &server_universe, 65, 1 }, 254 { "ldap-debug-file", "t", &server_universe, 66, 1 }, 255 { "ldap-dhcp-server-cn", "t", &server_universe, 67, 1 }, 256 { "ldap-referrals", "f", &server_universe, 68, 1 }, 257 #if defined(LDAP_USE_SSL) 258 { "ldap-ssl", "Nldap-ssl-usage.", &server_universe, 69, 1 }, 259 { "ldap-tls-reqcert", "Nldap-tls-reqcert.", &server_universe, 70, 1 }, 260 { "ldap-tls-ca-file", "t", &server_universe, 71, 1 }, 261 { "ldap-tls-ca-dir", "t", &server_universe, 72, 1 }, 262 { "ldap-tls-cert", "t", &server_universe, 73, 1 }, 263 { "ldap-tls-key", "t", &server_universe, 74, 1 }, 264 { "ldap-tls-crlcheck", "Nldap-tls-crlcheck.", &server_universe, 75, 1 }, 265 { "ldap-tls-ciphers", "t", &server_universe, 76, 1 }, 266 { "ldap-tls-randfile", "t", &server_universe, 77, 1 }, 267 { "ldap-init-retry", "L", &server_universe, SV_LDAP_INIT_RETRY, 1 }, 268 #endif /* LDAP_USE_SSL */ 269 #if defined(LDAP_USE_GSSAPI) 270 { "ldap-gssapi-keytab", "t", &server_universe, SV_LDAP_GSSAPI_KEYTAB, 1}, 271 { "ldap-gssapi-principal", "t", &server_universe, SV_LDAP_GSSAPI_PRINCIPAL, 1}, 272 #endif /* LDAP_USE_GSSAPI */ 273 #endif /* LDAP_CONFIGURATION */ 274 { "dhcp-cache-threshold", "B", &server_universe, 78, 1 }, 275 { "dont-use-fsync", "f", &server_universe, 79, 1 }, 276 { "ddns-local-address4", "I", &server_universe, 80, 1 }, 277 { "ddns-local-address6", "6", &server_universe, 81, 1 }, 278 { "ignore-client-uids", "f", &server_universe, 82, 1 }, 279 { "log-threshold-low", "B", &server_universe, 83, 1 }, 280 { "log-threshold-high", "B", &server_universe, 84, 1 }, 281 { "echo-client-id", "f", &server_universe, SV_ECHO_CLIENT_ID, 1 }, 282 { "server-id-check", "f", &server_universe, SV_SERVER_ID_CHECK, 1 }, 283 { "prefix-length-mode", "Nprefix_length_modes.", &server_universe, SV_PREFIX_LEN_MODE, 1 }, 284 { "dhcpv6-set-tee-times", "f", &server_universe, SV_DHCPV6_SET_TEE_TIMES, 1 }, 285 { "abandon-lease-time", "T", &server_universe, SV_ABANDON_LEASE_TIME, 1 }, 286 #ifdef EUI_64 287 { "use-eui-64", "f", &server_universe, SV_USE_EUI_64, 1 }, 288 { "persist-eui-64-leases", "f", &server_universe, SV_PERSIST_EUI_64_LEASES, 1 }, 289 #endif 290 #if defined (FAILOVER_PROTOCOL) 291 { "check-secs-byte-order", "f", &server_universe, SV_CHECK_SECS_BYTE_ORDER, 1 }, 292 #endif 293 { "ddns-dual-stack-mixed-mode", "f", &server_universe, SV_DDNS_DUAL_STACK_MIXED_MODE, 1 }, 294 { "ddns-guard-id-must-match", "f", &server_universe, SV_DDNS_GUARD_ID_MUST_MATCH, 1 }, 295 { "ddns-other-guard-is-dynamic", "f", &server_universe, SV_DDNS_OTHER_GUARD_IS_DYNAMIC, 1 }, 296 { "release-on-roam", "f", &server_universe, SV_RELEASE_ON_ROAM, 1 }, 297 { "local-address6", "6", &server_universe, SV_LOCAL_ADDRESS6, 1 }, 298 { "bind-local-address6", "f", &server_universe, SV_BIND_LOCAL_ADDRESS6, 1 }, 299 { "ping-cltt-secs", "T", &server_universe, SV_PING_CLTT_SECS, 1 }, 300 { "ping-timeout-ms", "T", &server_universe, SV_PING_TIMEOUT_MS, 1 }, 301 { NULL, NULL, NULL, 0, 0 } 302 }; 303 304 #if defined(LDAP_CONFIGURATION) 305 struct enumeration_value ldap_values [] = { 306 { "static", LDAP_METHOD_STATIC }, 307 { "dynamic", LDAP_METHOD_DYNAMIC }, 308 { (char *) 0, 0 } 309 }; 310 311 struct enumeration ldap_methods = { 312 (struct enumeration *)0, 313 "ldap-methods", 1, 314 ldap_values 315 }; 316 317 #if defined(LDAP_USE_SSL) 318 struct enumeration_value ldap_ssl_usage_values [] = { 319 { "off", LDAP_SSL_OFF }, 320 { "on",LDAP_SSL_ON }, 321 { "ldaps", LDAP_SSL_LDAPS }, 322 { "start_tls", LDAP_SSL_TLS }, 323 { (char *) 0, 0 } 324 }; 325 326 struct enumeration ldap_ssl_usage_enum = { 327 (struct enumeration *)0, 328 "ldap-ssl-usage", 1, 329 ldap_ssl_usage_values 330 }; 331 332 struct enumeration_value ldap_tls_reqcert_values [] = { 333 { "never", LDAP_OPT_X_TLS_NEVER }, 334 { "hard", LDAP_OPT_X_TLS_HARD }, 335 { "demand", LDAP_OPT_X_TLS_DEMAND}, 336 { "allow", LDAP_OPT_X_TLS_ALLOW }, 337 { "try", LDAP_OPT_X_TLS_TRY }, 338 { (char *) 0, 0 } 339 }; 340 struct enumeration ldap_tls_reqcert_enum = { 341 (struct enumeration *)0, 342 "ldap-tls-reqcert", 1, 343 ldap_tls_reqcert_values 344 }; 345 346 struct enumeration_value ldap_tls_crlcheck_values [] = { 347 { "none", LDAP_OPT_X_TLS_CRL_NONE}, 348 { "peer", LDAP_OPT_X_TLS_CRL_PEER}, 349 { "all", LDAP_OPT_X_TLS_CRL_ALL }, 350 { (char *) 0, 0 } 351 }; 352 struct enumeration ldap_tls_crlcheck_enum = { 353 (struct enumeration *)0, 354 "ldap-tls-crlcheck", 1, 355 ldap_tls_crlcheck_values 356 }; 357 #endif 358 #endif 359 360 struct enumeration_value ddns_styles_values [] = { 361 { "none", 0 }, 362 { "ad-hoc", 1 }, 363 { "interim", 2 }, 364 { "standard", 3 }, 365 { (char *)0, 0 } 366 }; 367 368 struct enumeration ddns_styles = { 369 (struct enumeration *)0, 370 "ddns-styles", 1, 371 ddns_styles_values 372 }; 373 374 struct enumeration_value prefix_length_modes_values[] = { 375 { "ignore", PLM_IGNORE }, 376 { "prefer", PLM_PREFER }, 377 { "exact", PLM_EXACT }, 378 { "minimum", PLM_MINIMUM }, 379 { "maximum", PLM_MAXIMUM }, 380 { (char *)0, 0 } 381 }; 382 383 struct enumeration prefix_length_modes = { 384 (struct enumeration *)0, 385 "prefix_length_modes", 1, 386 prefix_length_modes_values 387 }; 388 389 struct enumeration_value syslog_values [] = { 390 #if defined (LOG_KERN) 391 { "kern", LOG_KERN }, 392 #endif 393 #if defined (LOG_USER) 394 { "user", LOG_USER }, 395 #endif 396 #if defined (LOG_MAIL) 397 { "mail", LOG_MAIL }, 398 #endif 399 #if defined (LOG_DAEMON) 400 { "daemon", LOG_DAEMON }, 401 #endif 402 #if defined (LOG_AUTH) 403 { "auth", LOG_AUTH }, 404 #endif 405 #if defined (LOG_SYSLOG) 406 { "syslog", LOG_SYSLOG }, 407 #endif 408 #if defined (LOG_LPR) 409 { "lpr", LOG_LPR }, 410 #endif 411 #if defined (LOG_NEWS) 412 { "news", LOG_NEWS }, 413 #endif 414 #if defined (LOG_UUCP) 415 { "uucp", LOG_UUCP }, 416 #endif 417 #if defined (LOG_CRON) 418 { "cron", LOG_CRON }, 419 #endif 420 #if defined (LOG_AUTHPRIV) 421 { "authpriv", LOG_AUTHPRIV }, 422 #endif 423 #if defined (LOG_FTP) 424 { "ftp", LOG_FTP }, 425 #endif 426 #if defined (LOG_LOCAL0) 427 { "local0", LOG_LOCAL0 }, 428 #endif 429 #if defined (LOG_LOCAL1) 430 { "local1", LOG_LOCAL1 }, 431 #endif 432 #if defined (LOG_LOCAL2) 433 { "local2", LOG_LOCAL2 }, 434 #endif 435 #if defined (LOG_LOCAL3) 436 { "local3", LOG_LOCAL3 }, 437 #endif 438 #if defined (LOG_LOCAL4) 439 { "local4", LOG_LOCAL4 }, 440 #endif 441 #if defined (LOG_LOCAL5) 442 { "local5", LOG_LOCAL5 }, 443 #endif 444 #if defined (LOG_LOCAL6) 445 { "local6", LOG_LOCAL6 }, 446 #endif 447 #if defined (LOG_LOCAL7) 448 { "local7", LOG_LOCAL7 }, 449 #endif 450 { (char *)0, 0 } 451 }; 452 453 struct enumeration syslog_enum = { 454 (struct enumeration *)0, 455 "syslog-facilities", 1, 456 syslog_values 457 }; 458 459 void initialize_server_option_spaces() 460 { 461 int i; 462 unsigned code; 463 464 /* Set up the Relay Agent Information Option suboption space... */ 465 agent_universe.name = "agent"; 466 agent_universe.concat_duplicates = 0; 467 agent_universe.option_state_dereference = 468 linked_option_state_dereference; 469 agent_universe.lookup_func = lookup_linked_option; 470 agent_universe.save_func = save_linked_option; 471 agent_universe.delete_func = delete_linked_option; 472 agent_universe.encapsulate = linked_option_space_encapsulate; 473 agent_universe.foreach = linked_option_space_foreach; 474 agent_universe.decode = parse_option_buffer; 475 agent_universe.index = universe_count++; 476 agent_universe.length_size = 1; 477 agent_universe.tag_size = 1; 478 agent_universe.get_tag = getUChar; 479 agent_universe.store_tag = putUChar; 480 agent_universe.get_length = getUChar; 481 agent_universe.store_length = putUChar; 482 agent_universe.site_code_min = 0; 483 agent_universe.end = 0; 484 universes [agent_universe.index] = &agent_universe; 485 if (!option_name_new_hash(&agent_universe.name_hash, 486 AGENT_HASH_SIZE, MDL) || 487 !option_code_new_hash(&agent_universe.code_hash, 488 AGENT_HASH_SIZE, MDL)) 489 log_fatal ("Can't allocate agent option hash table."); 490 for (i = 0 ; agent_options[i].name ; i++) { 491 option_code_hash_add(agent_universe.code_hash, 492 &agent_options[i].code, 0, 493 &agent_options[i], MDL); 494 option_name_hash_add(agent_universe.name_hash, 495 agent_options[i].name, 0, 496 &agent_options[i], MDL); 497 } 498 #if defined(REPORT_HASH_PERFORMANCE) 499 log_info("Relay Agent name hash: %s", 500 option_name_hash_report(agent_universe.name_hash)); 501 log_info("Relay Agent code hash: %s", 502 option_code_hash_report(agent_universe.code_hash)); 503 #endif 504 code = DHO_DHCP_AGENT_OPTIONS; 505 option_code_hash_lookup(&agent_universe.enc_opt, 506 dhcp_universe.code_hash, &code, 0, MDL); 507 508 /* Set up the server option universe... */ 509 server_universe.name = "server"; 510 server_universe.concat_duplicates = 0; 511 server_universe.lookup_func = lookup_hashed_option; 512 server_universe.option_state_dereference = 513 hashed_option_state_dereference; 514 server_universe.save_func = save_hashed_option; 515 server_universe.delete_func = delete_hashed_option; 516 server_universe.encapsulate = hashed_option_space_encapsulate; 517 server_universe.foreach = hashed_option_space_foreach; 518 server_universe.length_size = 1; /* Never used ... */ 519 server_universe.tag_size = 4; 520 server_universe.store_tag = putUChar; 521 server_universe.store_length = putUChar; 522 server_universe.site_code_min = 0; 523 server_universe.end = 0; 524 server_universe.index = universe_count++; 525 universes [server_universe.index] = &server_universe; 526 if (!option_name_new_hash(&server_universe.name_hash, 527 SERVER_HASH_SIZE, MDL) || 528 !option_code_new_hash(&server_universe.code_hash, 529 SERVER_HASH_SIZE, MDL)) 530 log_fatal ("Can't allocate server option hash table."); 531 for (i = 0 ; server_options[i].name ; i++) { 532 option_code_hash_add(server_universe.code_hash, 533 &server_options[i].code, 0, 534 &server_options[i], MDL); 535 option_name_hash_add(server_universe.name_hash, 536 server_options[i].name, 0, 537 &server_options[i], MDL); 538 } 539 #if defined(REPORT_HASH_PERFORMANCE) 540 log_info("Server-Config Option name hash: %s", 541 option_name_hash_report(server_universe.name_hash)); 542 log_info("Server-Config Option code hash: %s", 543 option_code_hash_report(server_universe.code_hash)); 544 #endif 545 546 /* Add the server and agent option spaces to the option space hash. */ 547 universe_hash_add (universe_hash, 548 agent_universe.name, 0, &agent_universe, MDL); 549 universe_hash_add (universe_hash, 550 server_universe.name, 0, &server_universe, MDL); 551 552 /* Make the server universe the configuration option universe. */ 553 config_universe = &server_universe; 554 555 code = SV_VENDOR_OPTION_SPACE; 556 option_code_hash_lookup(&vendor_cfg_option, server_universe.code_hash, 557 &code, 0, MDL); 558 } 559