3
Tables of information only used by server... */
6
* Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
7
* Copyright (c) 1995-2003 by Internet Software Consortium
9
* Permission to use, copy, modify, and distribute this software for any
10
* purpose with or without fee is hereby granted, provided that the above
11
* copyright notice and this permission notice appear in all copies.
13
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
14
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
16
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
19
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21
* Internet Systems Consortium, Inc.
23
* Redwood City, CA 94063
25
* https://www.isc.org/
27
* This software has been written for Internet Systems Consortium
28
* by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
29
* To learn more about Internet Systems Consortium, see
30
* ``https://www.isc.org/''. To learn more about Vixie Enterprises,
31
* see ``http://www.vix.com''. To learn more about Nominum, Inc., see
32
* ``http://www.nominum.com''.
38
#if defined (FAILOVER_PROTOCOL)
40
/* This is used to indicate some kind of failure when generating a
42
failover_option_t null_failover_option = { 0, 0 };
43
failover_option_t skip_failover_option = { 0, 0 };
45
/* Information about failover options, for printing, encoding
47
struct failover_option_info ft_options [] =
49
{ 0, "unused", FT_UNDEF, 0, 0, 0 },
50
{ FTO_ADDRESSES_TRANSFERRED, "addresses-transferred", FT_UINT32, 1,
51
FM_OFFSET(addresses_transferred), FTB_ADDRESSES_TRANSFERRED },
52
{ FTO_ASSIGNED_IP_ADDRESS, "assigned-IP-address", FT_IPADDR, 1,
53
FM_OFFSET(assigned_addr), FTB_ASSIGNED_IP_ADDRESS },
54
{ FTO_BINDING_STATUS, "binding-status", FT_UINT8, 1,
55
FM_OFFSET(binding_status), FTB_BINDING_STATUS },
56
{ FTO_CLIENT_IDENTIFIER, "client-identifier", FT_BYTES, 0,
57
FM_OFFSET(client_identifier), FTB_CLIENT_IDENTIFIER },
58
{ FTO_CHADDR, "client-hardware-address", FT_BYTES, 0,
59
FM_OFFSET(chaddr), FTB_CHADDR },
60
{ FTO_CLTT, "client-last-transaction-time", FT_UINT32, 1,
61
FM_OFFSET(cltt), FTB_CLTT },
62
{ FTO_REPLY_OPTIONS, "client-reply-options", FT_BYTES, 0,
63
FM_OFFSET(reply_options), FTB_REPLY_OPTIONS },
64
{ FTO_REQUEST_OPTIONS, "client-request-options", FT_BYTES, 0,
65
FM_OFFSET(request_options), FTB_REQUEST_OPTIONS },
66
{ FTO_DDNS, "DDNS", FT_DDNS, 1, FM_OFFSET(ddns), FTB_DDNS },
67
{ FTO_DELAYED_SERVICE, "delayed-service", FT_UINT8, 1,
68
FM_OFFSET(delayed_service), FTB_DELAYED_SERVICE },
69
{ FTO_HBA, "hash-bucket-assignment", FT_BYTES, 0,
70
FM_OFFSET(hba), FTB_HBA },
71
{ FTO_IP_FLAGS, "IP-flags", FT_UINT16, 1,
72
FM_OFFSET(ip_flags), FTB_IP_FLAGS },
73
{ FTO_LEASE_EXPIRY, "lease-expiration-time", FT_UINT32, 1,
74
FM_OFFSET(expiry), FTB_LEASE_EXPIRY },
75
{ FTO_MAX_UNACKED, "max-unacked-bndupd", FT_UINT32, 1,
76
FM_OFFSET(max_unacked), FTB_MAX_UNACKED },
77
{ FTO_MCLT, "MCLT", FT_UINT32, 1, FM_OFFSET(mclt), FTB_MCLT },
78
{ FTO_MESSAGE, "message", FT_TEXT, 0,
79
FM_OFFSET(message), FTB_MESSAGE },
80
{ FTO_MESSAGE_DIGEST, "message-digest", FT_BYTES, 0,
81
FM_OFFSET(message_digest), FTB_MESSAGE_DIGEST },
82
{ FTO_POTENTIAL_EXPIRY, "potential-expiration-time", FT_UINT32, 1,
83
FM_OFFSET(potential_expiry), FTB_POTENTIAL_EXPIRY },
84
{ FTO_RECEIVE_TIMER, "receive-timer", FT_UINT32, 1,
85
FM_OFFSET(receive_timer), FTB_RECEIVE_TIMER },
86
{ FTO_PROTOCOL_VERSION, "protocol-version", FT_UINT8, 1,
87
FM_OFFSET(protocol_version), FTB_PROTOCOL_VERSION },
88
{ FTO_REJECT_REASON, "reject-reason", FT_UINT8, 1,
89
FM_OFFSET(reject_reason), FTB_REJECT_REASON },
90
{ FTO_RELATIONSHIP_NAME, "relationship-name", FT_BYTES, 0,
91
FM_OFFSET(relationship_name), FTB_RELATIONSHIP_NAME },
92
{ FTO_SERVER_FLAGS, "server-flags", FT_UINT8, 1,
93
FM_OFFSET(server_flags), FTB_SERVER_FLAGS },
94
{ FTO_SERVER_STATE, "server-state", FT_UINT8, 1,
95
FM_OFFSET(server_state), FTB_SERVER_STATE },
96
{ FTO_STOS, "start-time-of-state", FT_UINT32, 1,
97
FM_OFFSET(stos), FTB_STOS },
98
{ FTO_TLS_REPLY, "TLS-reply", FT_UINT8, 1,
99
FM_OFFSET(tls_reply), FTB_TLS_REPLY },
100
{ FTO_TLS_REQUEST, "TLS-request", FT_UINT8, 1,
101
FM_OFFSET(tls_request), FTB_TLS_REQUEST },
102
{ FTO_VENDOR_CLASS, "vendor-class-identifier", FT_BYTES, 0,
103
FM_OFFSET(vendor_class), FTB_VENDOR_CLASS },
104
{ FTO_VENDOR_OPTIONS, "vendor-specific-options", FT_BYTES, 0,
105
FM_OFFSET(vendor_options), FTB_VENDOR_OPTIONS }
108
/* These are really options that make sense for a particular request - if
109
some other option comes in, we're not going to use it, so we can just
110
discard it. Note that the message-digest option is allowed for all
111
message types, but is not saved - it's just used to validate the message
112
and then discarded - so it's not mentioned here. */
114
u_int32_t fto_allowed [] = {
117
FTB_ADDRESSES_TRANSFERRED, /* 2 POOLRESP */
118
(FTB_ASSIGNED_IP_ADDRESS | FTB_BINDING_STATUS | FTB_CLIENT_IDENTIFIER |
119
FTB_CHADDR | FTB_DDNS | FTB_IP_FLAGS | FTB_LEASE_EXPIRY |
120
FTB_POTENTIAL_EXPIRY | FTB_STOS | FTB_CLTT | FTB_REQUEST_OPTIONS |
121
FTB_REPLY_OPTIONS), /* 3 BNDUPD */
122
(FTB_ASSIGNED_IP_ADDRESS | FTB_BINDING_STATUS | FTB_CLIENT_IDENTIFIER |
123
FTB_CHADDR | FTB_DDNS | FTB_IP_FLAGS | FTB_LEASE_EXPIRY |
124
FTB_POTENTIAL_EXPIRY | FTB_STOS | FTB_CLTT | FTB_REQUEST_OPTIONS |
125
FTB_REPLY_OPTIONS | FTB_REJECT_REASON | FTB_MESSAGE), /* 4 BNDACK */
126
(FTB_RELATIONSHIP_NAME | FTB_MAX_UNACKED | FTB_RECEIVE_TIMER |
127
FTB_VENDOR_CLASS | FTB_PROTOCOL_VERSION | FTB_TLS_REQUEST |
128
FTB_MCLT | FTB_HBA), /* 5 CONNECT */
129
(FTB_RELATIONSHIP_NAME | FTB_MAX_UNACKED | FTB_RECEIVE_TIMER |
130
FTB_VENDOR_CLASS | FTB_PROTOCOL_VERSION | FTB_TLS_REPLY |
131
FTB_REJECT_REASON | FTB_MESSAGE), /* CONNECTACK */
135
(FTB_SERVER_STATE | FTB_SERVER_FLAGS | FTB_STOS), /* 10 STATE */
137
(FTB_REJECT_REASON | FTB_MESSAGE) /* 12 DISCONNECT */
140
/* Sizes of the various types. */
146
1, /* FT_TEXT_OR_BYTES */
155
/* Names of the various failover link states. */
156
const char *dhcp_flink_state_names [] = {
159
"message length wait",
163
#endif /* FAILOVER_PROTOCOL */
165
/* Failover binding state names. These are used even if there is no
166
failover protocol support. */
167
const char *binding_state_names [] = {
168
"free", "active", "expired", "released", "abandoned",
171
struct universe agent_universe;
172
static struct option agent_options[] = {
173
{ "circuit-id", "X", &agent_universe, 1, 1 },
174
{ "remote-id", "X", &agent_universe, 2, 1 },
175
{ "agent-id", "I", &agent_universe, 3, 1 },
176
{ "DOCSIS-device-class", "L", &agent_universe, 4, 1 },
177
{ "link-selection", "I", &agent_universe, 5, 1 },
178
{ NULL, NULL, NULL, 0, 0 }
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", "d", &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 },
247
#if defined(LDAP_CONFIGURATION)
248
{ "ldap-server", "t", &server_universe, 60, 1 },
249
{ "ldap-port", "d", &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
#endif /* LDAP_USE_SSL */
268
#endif /* LDAP_CONFIGURATION */
269
{ NULL, NULL, NULL, 0, 0 }
272
#if defined(LDAP_CONFIGURATION)
273
struct enumeration_value ldap_values [] = {
274
{ "static", LDAP_METHOD_STATIC },
275
{ "dynamic", LDAP_METHOD_DYNAMIC },
279
struct enumeration ldap_methods = {
280
(struct enumeration *)0,
285
#if defined(LDAP_USE_SSL)
286
struct enumeration_value ldap_ssl_usage_values [] = {
287
{ "off", LDAP_SSL_OFF },
288
{ "on",LDAP_SSL_ON },
289
{ "ldaps", LDAP_SSL_LDAPS },
290
{ "start_tls", LDAP_SSL_TLS },
294
struct enumeration ldap_ssl_usage_enum = {
295
(struct enumeration *)0,
297
ldap_ssl_usage_values
300
struct enumeration_value ldap_tls_reqcert_values [] = {
301
{ "never", LDAP_OPT_X_TLS_NEVER },
302
{ "hard", LDAP_OPT_X_TLS_HARD },
303
{ "demand", LDAP_OPT_X_TLS_DEMAND},
304
{ "allow", LDAP_OPT_X_TLS_ALLOW },
305
{ "try", LDAP_OPT_X_TLS_TRY },
308
struct enumeration ldap_tls_reqcert_enum = {
309
(struct enumeration *)0,
310
"ldap-tls-reqcert", 1,
311
ldap_tls_reqcert_values
314
struct enumeration_value ldap_tls_crlcheck_values [] = {
315
{ "none", LDAP_OPT_X_TLS_CRL_NONE},
316
{ "peer", LDAP_OPT_X_TLS_CRL_PEER},
317
{ "all", LDAP_OPT_X_TLS_CRL_ALL },
320
struct enumeration ldap_tls_crlcheck_enum = {
321
(struct enumeration *)0,
322
"ldap-tls-crlcheck", 1,
323
ldap_tls_crlcheck_values
328
struct enumeration_value ddns_styles_values [] = {
335
struct enumeration ddns_styles = {
336
(struct enumeration *)0,
341
struct enumeration_value syslog_values [] = {
342
#if defined (LOG_KERN)
343
{ "kern", LOG_KERN },
345
#if defined (LOG_USER)
346
{ "user", LOG_USER },
348
#if defined (LOG_MAIL)
349
{ "mail", LOG_MAIL },
351
#if defined (LOG_DAEMON)
352
{ "daemon", LOG_DAEMON },
354
#if defined (LOG_AUTH)
355
{ "auth", LOG_AUTH },
357
#if defined (LOG_SYSLOG)
358
{ "syslog", LOG_SYSLOG },
360
#if defined (LOG_LPR)
363
#if defined (LOG_NEWS)
364
{ "news", LOG_NEWS },
366
#if defined (LOG_UUCP)
367
{ "uucp", LOG_UUCP },
369
#if defined (LOG_CRON)
370
{ "cron", LOG_CRON },
372
#if defined (LOG_AUTHPRIV)
373
{ "authpriv", LOG_AUTHPRIV },
375
#if defined (LOG_FTP)
378
#if defined (LOG_LOCAL0)
379
{ "local0", LOG_LOCAL0 },
381
#if defined (LOG_LOCAL1)
382
{ "local1", LOG_LOCAL1 },
384
#if defined (LOG_LOCAL2)
385
{ "local2", LOG_LOCAL2 },
387
#if defined (LOG_LOCAL3)
388
{ "local3", LOG_LOCAL3 },
390
#if defined (LOG_LOCAL4)
391
{ "local4", LOG_LOCAL4 },
393
#if defined (LOG_LOCAL5)
394
{ "local5", LOG_LOCAL5 },
396
#if defined (LOG_LOCAL6)
397
{ "local6", LOG_LOCAL6 },
399
#if defined (LOG_LOCAL7)
400
{ "local7", LOG_LOCAL7 },
405
struct enumeration syslog_enum = {
406
(struct enumeration *)0,
407
"syslog-facilities", 1,
411
void initialize_server_option_spaces()
416
/* Set up the Relay Agent Information Option suboption space... */
417
agent_universe.name = "agent";
418
agent_universe.concat_duplicates = 0;
419
agent_universe.option_state_dereference =
420
linked_option_state_dereference;
421
agent_universe.lookup_func = lookup_linked_option;
422
agent_universe.save_func = save_linked_option;
423
agent_universe.delete_func = delete_linked_option;
424
agent_universe.encapsulate = linked_option_space_encapsulate;
425
agent_universe.foreach = linked_option_space_foreach;
426
agent_universe.decode = parse_option_buffer;
427
agent_universe.index = universe_count++;
428
agent_universe.length_size = 1;
429
agent_universe.tag_size = 1;
430
agent_universe.get_tag = getUChar;
431
agent_universe.store_tag = putUChar;
432
agent_universe.get_length = getUChar;
433
agent_universe.store_length = putUChar;
434
agent_universe.site_code_min = 0;
435
agent_universe.end = 0;
436
universes [agent_universe.index] = &agent_universe;
437
if (!option_name_new_hash(&agent_universe.name_hash,
438
AGENT_HASH_SIZE, MDL) ||
439
!option_code_new_hash(&agent_universe.code_hash,
440
AGENT_HASH_SIZE, MDL))
441
log_fatal ("Can't allocate agent option hash table.");
442
for (i = 0 ; agent_options[i].name ; i++) {
443
option_code_hash_add(agent_universe.code_hash,
444
&agent_options[i].code, 0,
445
&agent_options[i], MDL);
446
option_name_hash_add(agent_universe.name_hash,
447
agent_options[i].name, 0,
448
&agent_options[i], MDL);
450
#if defined(REPORT_HASH_PERFORMANCE)
451
log_info("Relay Agent name hash: %s",
452
option_name_hash_report(agent_universe.name_hash));
453
log_info("Relay Agent code hash: %s",
454
option_code_hash_report(agent_universe.code_hash));
456
code = DHO_DHCP_AGENT_OPTIONS;
457
option_code_hash_lookup(&agent_universe.enc_opt,
458
dhcp_universe.code_hash, &code, 0, MDL);
460
/* Set up the server option universe... */
461
server_universe.name = "server";
462
server_universe.concat_duplicates = 0;
463
server_universe.lookup_func = lookup_hashed_option;
464
server_universe.option_state_dereference =
465
hashed_option_state_dereference;
466
server_universe.save_func = save_hashed_option;
467
server_universe.delete_func = delete_hashed_option;
468
server_universe.encapsulate = hashed_option_space_encapsulate;
469
server_universe.foreach = hashed_option_space_foreach;
470
server_universe.length_size = 1; /* Never used ... */
471
server_universe.tag_size = 4;
472
server_universe.store_tag = putUChar;
473
server_universe.store_length = putUChar;
474
server_universe.site_code_min = 0;
475
server_universe.end = 0;
476
server_universe.index = universe_count++;
477
universes [server_universe.index] = &server_universe;
478
if (!option_name_new_hash(&server_universe.name_hash,
479
SERVER_HASH_SIZE, MDL) ||
480
!option_code_new_hash(&server_universe.code_hash,
481
SERVER_HASH_SIZE, MDL))
482
log_fatal ("Can't allocate server option hash table.");
483
for (i = 0 ; server_options[i].name ; i++) {
484
option_code_hash_add(server_universe.code_hash,
485
&server_options[i].code, 0,
486
&server_options[i], MDL);
487
option_name_hash_add(server_universe.name_hash,
488
server_options[i].name, 0,
489
&server_options[i], MDL);
491
#if defined(REPORT_HASH_PERFORMANCE)
492
log_info("Server-Config Option name hash: %s",
493
option_name_hash_report(server_universe.name_hash));
494
log_info("Server-Config Option code hash: %s",
495
option_code_hash_report(server_universe.code_hash));
498
/* Add the server and agent option spaces to the option space hash. */
499
universe_hash_add (universe_hash,
500
agent_universe.name, 0, &agent_universe, MDL);
501
universe_hash_add (universe_hash,
502
server_universe.name, 0, &server_universe, MDL);
504
/* Make the server universe the configuration option universe. */
505
config_universe = &server_universe;
507
code = SV_VENDOR_OPTION_SPACE;
508
option_code_hash_lookup(&vendor_cfg_option, server_universe.code_hash,