ISC DHCP  4.4.3
A reference DHCPv4 and DHCPv6 implementation
tables.c
Go to the documentation of this file.
1 /* tables.c
2 
3  Tables of information... */
4 
5 /*
6  * Copyright (C) 2004-2022 Internet Systems Consortium, Inc. ("ISC")
7  * Copyright (c) 1995-2003 by Internet Software Consortium
8  *
9  * This Source Code Form is subject to the terms of the Mozilla Public
10  * License, v. 2.0. If a copy of the MPL was not distributed with this
11  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12  *
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.
20  *
21  * Internet Systems Consortium, Inc.
22  * PO Box 360
23  * Newmarket, NH 03857 USA
24  * <info@isc.org>
25  * https://www.isc.org/
26  *
27  */
28 
29 #include "dhcpd.h"
30 
31 /* XXXDPN: Moved here from hash.c, when it moved to libomapi. Not sure
32  where these really belong. */
35 HASH_FUNCTIONS (universe, const char *, struct universe, universe_hash_t, 0, 0,
37 HASH_FUNCTIONS (option_name, const char *, struct option, option_name_hash_t,
39 HASH_FUNCTIONS (option_code, const unsigned *, struct option,
42 
43 /* DHCP Option names, formats and codes, from RFC1533.
44 
45  Format codes:
46 
47  I - IPv4 address
48  R - destination descriptor (RFC3442)
49  6 - IPv6 address
50  l - 32-bit signed integer
51  L - 32-bit unsigned integer
52  s - 16-bit signed integer
53  S - 16-bit unsigned integer
54  b - 8-bit signed integer
55  B - 8-bit unsigned integer
56  t - ASCII text
57  T - Lease Time, 32-bit unsigned integer implying a number of seconds from
58  some event. The special all-ones value means 'infinite'. May either
59  be printed as a decimal, eg, "3600", or as this name, eg, "infinite".
60  f - flag (true or false)
61  A - array of all that precedes (e.g., fIA means array of records of
62  a flag and an IP address)
63  a - array of the preceding character (e.g., fIa means a single flag
64  followed by an array of IP addresses)
65  U - name of an option space (universe)
66  F - implicit flag - the presence of the option indicates that the
67  flag is true.
68  o - the preceding value is optional.
69  E - encapsulation, string or colon-separated hex list (the latter
70  two for parsing). E is followed by a text string containing
71  the name of the option space to encapsulate, followed by a '.'.
72  If the E is immediately followed by '.', the applicable vendor
73  option space is used if one is defined.
74  e - If an encapsulation directive is not the first thing in the string,
75  the option scanner requires an efficient way to find the encapsulation.
76  This is done by placing a 'e' at the beginning of the option. The
77  'e' has no other purpose, and is not required if 'E' is the first
78  thing in the option.
79  X - either an ASCII string or binary data. On output, the string is
80  scanned to see if it's printable ASCII and, if so, output as a
81  quoted string. If not, it's output as colon-separated hex. On
82  input, the option can be specified either as a quoted string or as
83  a colon-separated hex list.
84  N - enumeration. N is followed by a text string containing
85  the name of the set of enumeration values to parse or emit,
86  followed by a '.'. The width of the data is specified in the
87  named enumeration. Named enumerations are tracked in parse.c.
88  d - Domain name (e.g., FOO or FOO.BAR) no quotes,
89  on-wire format is RFC 1035.
90  D - Domain list (e.g., "example.com eng.example.com") quoted,
91  on-wire format is RFC 1035.
92  c - When following a 'D' atom, enables compression pointers.
93  Z - Zero-length option
94  k - Key name, unquoted string (e.g. mykey.com or some-text or abc123)
95  parsed with parse_host_name().
96 */
97 
98 struct universe dhcp_universe;
99 static struct option dhcp_options[] = {
100  { "subnet-mask", "I", &dhcp_universe, 1, 1 },
101  { "time-offset", "l", &dhcp_universe, 2, 1 },
102  { "routers", "IA", &dhcp_universe, 3, 1 },
103  { "time-servers", "IA", &dhcp_universe, 4, 1 },
104  { "ien116-name-servers", "IA", &dhcp_universe, 5, 1 },
105  { "domain-name-servers", "IA", &dhcp_universe, 6, 1 },
106  { "log-servers", "IA", &dhcp_universe, 7, 1 },
107  { "cookie-servers", "IA", &dhcp_universe, 8, 1 },
108  { "lpr-servers", "IA", &dhcp_universe, 9, 1 },
109  { "impress-servers", "IA", &dhcp_universe, 10, 1 },
110  { "resource-location-servers", "IA", &dhcp_universe, 11, 1 },
111  { "host-name", "t", &dhcp_universe, 12, 1 },
112  { "boot-size", "S", &dhcp_universe, 13, 1 },
113  { "merit-dump", "t", &dhcp_universe, 14, 1 },
114  { "domain-name", "t", &dhcp_universe, 15, 1 },
115  { "swap-server", "I", &dhcp_universe, 16, 1 },
116  { "root-path", "t", &dhcp_universe, 17, 1 },
117  { "extensions-path", "t", &dhcp_universe, 18, 1 },
118  { "ip-forwarding", "f", &dhcp_universe, 19, 1 },
119  { "non-local-source-routing", "f", &dhcp_universe, 20, 1 },
120  { "policy-filter", "IIA", &dhcp_universe, 21, 1 },
121  { "max-dgram-reassembly", "S", &dhcp_universe, 22, 1 },
122  { "default-ip-ttl", "B", &dhcp_universe, 23, 1 },
123  { "path-mtu-aging-timeout", "L", &dhcp_universe, 24, 1 },
124  { "path-mtu-plateau-table", "SA", &dhcp_universe, 25, 1 },
125  { "interface-mtu", "S", &dhcp_universe, 26, 1 },
126  { "all-subnets-local", "f", &dhcp_universe, 27, 1 },
127  { "broadcast-address", "I", &dhcp_universe, 28, 1 },
128  { "perform-mask-discovery", "f", &dhcp_universe, 29, 1 },
129  { "mask-supplier", "f", &dhcp_universe, 30, 1 },
130  { "router-discovery", "f", &dhcp_universe, 31, 1 },
131  { "router-solicitation-address", "I", &dhcp_universe, 32, 1 },
132  { "static-routes", "IIA", &dhcp_universe, 33, 1 },
133  { "trailer-encapsulation", "f", &dhcp_universe, 34, 1 },
134  { "arp-cache-timeout", "L", &dhcp_universe, 35, 1 },
135  { "ieee802-3-encapsulation", "f", &dhcp_universe, 36, 1 },
136  { "default-tcp-ttl", "B", &dhcp_universe, 37, 1 },
137  { "tcp-keepalive-interval", "L", &dhcp_universe, 38, 1 },
138  { "tcp-keepalive-garbage", "f", &dhcp_universe, 39, 1 },
139  { "nis-domain", "t", &dhcp_universe, 40, 1 },
140  { "nis-servers", "IA", &dhcp_universe, 41, 1 },
141  { "ntp-servers", "IA", &dhcp_universe, 42, 1 },
142  { "vendor-encapsulated-options", "E.", &dhcp_universe, 43, 1 },
143  { "netbios-name-servers", "IA", &dhcp_universe, 44, 1 },
144  { "netbios-dd-server", "IA", &dhcp_universe, 45, 1 },
145  { "netbios-node-type", "B", &dhcp_universe, 46, 1 },
146  { "netbios-scope", "t", &dhcp_universe, 47, 1 },
147  { "font-servers", "IA", &dhcp_universe, 48, 1 },
148  { "x-display-manager", "IA", &dhcp_universe, 49, 1 },
149  { "dhcp-requested-address", "I", &dhcp_universe, 50, 1 },
150  { "dhcp-lease-time", "L", &dhcp_universe, 51, 1 },
151  { "dhcp-option-overload", "B", &dhcp_universe, 52, 1 },
152  { "dhcp-message-type", "B", &dhcp_universe, 53, 1 },
153  { "dhcp-server-identifier", "I", &dhcp_universe, 54, 1 },
154  { "dhcp-parameter-request-list", "BA", &dhcp_universe, 55, 1 },
155  { "dhcp-message", "t", &dhcp_universe, 56, 1 },
156  { "dhcp-max-message-size", "S", &dhcp_universe, 57, 1 },
157  { "dhcp-renewal-time", "L", &dhcp_universe, 58, 1 },
158  { "dhcp-rebinding-time", "L", &dhcp_universe, 59, 1 },
159  { "vendor-class-identifier", "X", &dhcp_universe, 60, 1 },
160  { "dhcp-client-identifier", "X", &dhcp_universe, 61, 1 },
161  { "nwip-domain", "t", &dhcp_universe, 62, 1 },
162  { "nwip-suboptions", "Enwip.", &dhcp_universe, 63, 1 },
163  { "nisplus-domain", "t", &dhcp_universe, 64, 1 },
164  { "nisplus-servers", "IA", &dhcp_universe, 65, 1 },
165  { "tftp-server-name", "t", &dhcp_universe, 66, 1 },
166  { "bootfile-name", "t", &dhcp_universe, 67, 1 },
167  { "mobile-ip-home-agent", "IA", &dhcp_universe, 68, 1 },
168  { "smtp-server", "IA", &dhcp_universe, 69, 1 },
169  { "pop-server", "IA", &dhcp_universe, 70, 1 },
170  { "nntp-server", "IA", &dhcp_universe, 71, 1 },
171  { "www-server", "IA", &dhcp_universe, 72, 1 },
172  { "finger-server", "IA", &dhcp_universe, 73, 1 },
173  { "irc-server", "IA", &dhcp_universe, 74, 1 },
174  { "streettalk-server", "IA", &dhcp_universe, 75, 1 },
175  { "streettalk-directory-assistance-server", "IA",
176  &dhcp_universe, 76, 1 },
177  { "user-class", "t", &dhcp_universe, 77, 1 },
178  { "slp-directory-agent", "fIa", &dhcp_universe, 78, 1 },
179  { "slp-service-scope", "fto", &dhcp_universe, 79, 1 },
180  /* 80 is the zero-length rapid-commit (RFC 4039) */
181  { "fqdn", "Efqdn.", &dhcp_universe, 81, 1 },
182  { "relay-agent-information", "Eagent.", &dhcp_universe, 82, 1 },
183  /* 83 is iSNS (RFC 4174) */
184  /* 84 is unassigned */
185  { "nds-servers", "IA", &dhcp_universe, 85, 1 },
186  { "nds-tree-name", "t", &dhcp_universe, 86, 1 },
187  { "nds-context", "t", &dhcp_universe, 87, 1 },
188 
189  /* Note: RFC4280 fails to identify if the DHCPv4 option is to use
190  * compression pointers or not. Assume not.
191  */
192  { "bcms-controller-names", "D", &dhcp_universe, 88, 1 },
193  { "bcms-controller-address", "Ia", &dhcp_universe, 89, 1 },
194 
195  /* 90 is the authentication option (RFC 3118) */
196 
197  { "client-last-transaction-time", "L", &dhcp_universe, 91, 1 },
198  { "associated-ip", "Ia", &dhcp_universe, 92, 1 },
199 #if defined(RFC4578_OPTIONS)
200  /* Defined by RFC 4578 */
201  { "pxe-system-type", "Sa", &dhcp_universe, 93, 1 },
202  { "pxe-interface-id", "BBB", &dhcp_universe, 94, 1 },
203 #endif
204  { "pxe-client-id", "BX", &dhcp_universe, 97, 1 },
205 
206  { "uap-servers", "t", &dhcp_universe, 98, 1 },
207 #if defined(RFC4776_OPTIONS)
208  { "geoconf-civic", "X", &dhcp_universe, 99, 1 },
209 #endif
210 #if defined(RFC4833_OPTIONS)
211  { "pcode", "t", &dhcp_universe, 100, 1 },
212  { "tcode", "t", &dhcp_universe, 101, 1 },
213 #endif
214 #if defined(RFC8925_OPTIONS)
215  { "v6-only-preferred", "L", &dhcp_universe, 108, 1 },
216 #endif
217  { "netinfo-server-address", "Ia", &dhcp_universe, 112, 1 },
218  { "netinfo-server-tag", "t", &dhcp_universe, 113, 1 },
219  { "default-url", "t", &dhcp_universe, 114, 1 },
220 #if defined(RFC2563_OPTIONS)
221  { "auto-config", "B", &dhcp_universe, 116, 1 },
222 #endif
223 #if defined(RFC2937_OPTIONS)
224  { "name-service-search", "Sa", &dhcp_universe, 117, 1 },
225 #endif
226  { "subnet-selection", "I", &dhcp_universe, 118, 1 },
227  { "domain-search", "D", &dhcp_universe, 119, 1 },
228  { "classless-static-routes", "RIA", &dhcp_universe, 121, 1 },
229  { "vivco", "Evendor-class.", &dhcp_universe, 124, 1 },
230  { "vivso", "Evendor.", &dhcp_universe, 125, 1 },
231 #if 0
232  /* Referenced by RFC 4578.
233  * DO NOT UNCOMMENT THESE DEFINITIONS: these names are placeholders
234  * and will not be used in future versions of the software.
235  */
236  { "pxe-undefined-1", "X", &dhcp_universe, 128, 1 },
237  { "pxe-undefined-2", "X", &dhcp_universe, 129, 1 },
238  { "pxe-undefined-3", "X", &dhcp_universe, 130, 1 },
239  { "pxe-undefined-4", "X", &dhcp_universe, 131, 1 },
240  { "pxe-undefined-5", "X", &dhcp_universe, 132, 1 },
241  { "pxe-undefined-6", "X", &dhcp_universe, 133, 1 },
242  { "pxe-undefined-7", "X", &dhcp_universe, 134, 1 },
243  { "pxe-undefined-8", "X", &dhcp_universe, 135, 1 },
244 #endif
245 #if defined(RFC5192_OPTIONS)
246  {"pana-agent", "Ia", &dhcp_universe, 136, 1 },
247 #endif
248 #if defined(RFC5223_OPTIONS)
249  {"v4-lost", "d", &dhcp_universe, 137, 1 },
250 #endif
251 #if defined(RFC5417_OPTIONS)
252  {"capwap-ac-v4", "Ia", &dhcp_universe, 138, 1 },
253 #endif
254 #if defined(RFC6011_OPTIONS)
255  { "sip-ua-cs-domains", "Dc", &dhcp_universe, 141, 1 },
256 #endif
257 #if defined(RFC6153_OPTIONS)
258  { "ipv4-address-andsf", "IA", &dhcp_universe, 142, 1 },
259 #endif
260 #if defined(RFC6731_OPTIONS)
261  { "rdnss-selection", "BIID", &dhcp_universe, 146, 1 },
262 #endif
263 #if defined(RFC5859_OPTIONS)
264  { "tftp-server-address", "Ia", &dhcp_universe, 150, 1 },
265 #endif
266 #if defined(RFC7618_OPTIONS)
267  { "v4-portparams", "BBS", &dhcp_universe, 159, 1 },
268 #endif
269 #if defined(RFC7710_OPTIONS)
270  { "v4-captive-portal", "t", &dhcp_universe, 160, 1 },
271 #endif
272 #if defined(RFC5071_OPTIONS)
273 #if 0
274  /* Option 208 has been officially deprecated. Do NOT define it */
275  { "pxelinux-magic", "BBBB", &dhcp_universe, 208, 1 },
276 #endif
277  { "loader-configfile", "t", &dhcp_universe, 209, 1 },
278  { "loader-pathprefix", "t", &dhcp_universe, 210, 1 },
279  { "loader-reboottime", "L", &dhcp_universe, 211, 1 },
280 #endif
281 #if defined(RFC5969_OPTIONS)
282  { "option-6rd", "BB6Ia", &dhcp_universe, 212, 1 },
283 #endif
284 #if defined(RFC5986_OPTIONS)
285  {"v4-access-domain", "d", &dhcp_universe, 213, 1 },
286 #endif
287  { NULL, NULL, NULL, 0, 0 }
288 };
289 
290 struct universe nwip_universe;
291 static struct option nwip_options[] = {
292  { "illegal-1", "", &nwip_universe, 1, 1 },
293  { "illegal-2", "", &nwip_universe, 2, 1 },
294  { "illegal-3", "", &nwip_universe, 3, 1 },
295  { "illegal-4", "", &nwip_universe, 4, 1 },
296  { "nsq-broadcast", "f", &nwip_universe, 5, 1 },
297  { "preferred-dss", "IA", &nwip_universe, 6, 1 },
298  { "nearest-nwip-server", "IA", &nwip_universe, 7, 1 },
299  { "autoretries", "B", &nwip_universe, 8, 1 },
300  { "autoretry-secs", "B", &nwip_universe, 9, 1 },
301  { "nwip-1-1", "f", &nwip_universe, 10, 1 },
302  { "primary-dss", "I", &nwip_universe, 11, 1 },
303  { NULL, NULL, NULL, 0, 0 }
304 };
305 
306 /* Note that the "FQDN suboption space" does not reflect the FQDN option
307  * format - rather, this is a handy "virtualization" of a flat option
308  * which makes manual configuration and presentation of some of its
309  * contents easier (each of these suboptions is a fixed-space field within
310  * the fqdn contents - domain and host names are derived from a common field,
311  * and differ in the left and right hand side of the leftmost dot, fqdn is
312  * the combination of the two).
313  *
314  * Note further that the DHCPv6 and DHCPv4 'fqdn' options use the same
315  * virtualized option space to store their work.
316  */
317 
318 struct universe fqdn_universe;
319 struct universe fqdn6_universe;
320 static struct option fqdn_options[] = {
321  { "no-client-update", "f", &fqdn_universe, 1, 1 },
322  { "server-update", "f", &fqdn_universe, 2, 1 },
323  { "encoded", "f", &fqdn_universe, 3, 1 },
324  { "rcode1", "B", &fqdn_universe, 4, 1 },
325  { "rcode2", "B", &fqdn_universe, 5, 1 },
326  { "hostname", "t", &fqdn_universe, 6, 1 },
327  { "domainname", "t", &fqdn_universe, 7, 1 },
328  { "fqdn", "t", &fqdn_universe, 8, 1 },
329  { NULL, NULL, NULL, 0, 0 }
330 };
331 
333 static struct option vendor_class_options[] = {
334  { "isc", "X", &vendor_class_universe, 2495, 1 },
335  { NULL, NULL, NULL, 0, 0 }
336 };
337 
339 static struct option vendor_options[] = {
340  { "isc", "Eisc.", &vendor_universe, 2495, 1 },
341  { NULL, NULL, NULL, 0, 0 }
342 };
343 
344 struct universe isc_universe;
345 static struct option isc_options [] = {
346  { "media", "t", &isc_universe, 1, 1 },
347  { "update-assist", "X", &isc_universe, 2, 1 },
348  { NULL, NULL, NULL, 0, 0 }
349 };
350 
352 static struct option dhcpv6_options[] = {
353 
354  /* RFC3315 OPTIONS */
355 
356  /* Client and server DUIDs are opaque fields, but marking them
357  * up somewhat makes configuration easier.
358  */
359  { "client-id", "X", &dhcpv6_universe, 1, 1 },
360  { "server-id", "X", &dhcpv6_universe, 2, 1 },
361 
362  /* ia-* options actually have at their ends a space for options
363  * that are specific to this instance of the option. We can not
364  * handle this yet at this stage of development, so the encoding
365  * of these options is unspecified ("X").
366  */
367  { "ia-na", "X", &dhcpv6_universe, 3, 1 },
368  { "ia-ta", "X", &dhcpv6_universe, 4, 1 },
369  { "ia-addr", "X", &dhcpv6_universe, 5, 1 },
370 
371  /* "oro" is DHCPv6 speak for "parameter-request-list" */
372  { "oro", "SA", &dhcpv6_universe, 6, 1 },
373 
374  { "preference", "B", &dhcpv6_universe, 7, 1 },
375  { "elapsed-time", "S", &dhcpv6_universe, 8, 1 },
376  { "relay-msg", "X", &dhcpv6_universe, 9, 1 },
377 
378  /* Option code 10 is curiously unassigned. */
379  /*
380  * In draft-ietf-dhc-dhcpv6-25 there were two OPTION_CLIENT_MSG and
381  * OPTION_SERVER_MSG options. They were eventually unified as
382  * OPTION_RELAY_MSG, hence no option with value of 10.
383  */
384 #if 0
385  /* XXX: missing suitable atoms for the auth option. We may want
386  * to 'virtually encapsulate' this option a la the fqdn option
387  * seeing as it is processed explicitly by the server and unlikely
388  * to be configured by hand by users as such.
389  */
390  { "auth", "Nauth-protocol.Nauth-algorithm.Nrdm-type.LLX",
391  &dhcpv6_universe, 11, 1 },
392 #endif
393  { "unicast", "6", &dhcpv6_universe, 12, 1 },
394  { "status-code", "Nstatus-codes.to", &dhcpv6_universe, 13, 1 },
395  { "rapid-commit", "Z", &dhcpv6_universe, 14, 1 },
396 #if 0
397  /* XXX: user-class contents are of the form "StA" where the
398  * integer describes the length of the text field. We don't have
399  * an atom for pre-determined-length octet strings yet, so we
400  * can't quite do these two.
401  */
402  { "user-class", "X", &dhcpv6_universe, 15, 1 },
403  { "vendor-class", "X", &dhcpv6_universe, 16, 1 },
404 #endif
405  { "vendor-opts", "Evsio.", &dhcpv6_universe, 17, 1 },
406  { "interface-id", "X", &dhcpv6_universe, 18, 1 },
407  { "reconf-msg", "Ndhcpv6-messages.", &dhcpv6_universe, 19, 1 },
408  { "reconf-accept", "Z", &dhcpv6_universe, 20, 1 },
409 
410  /* RFC3319 OPTIONS */
411 
412  /* Of course: we would HAVE to have a different atom for
413  * domain names without compression. Typical.
414  */
415  { "sip-servers-names", "D", &dhcpv6_universe, 21, 1 },
416  { "sip-servers-addresses", "6A", &dhcpv6_universe, 22, 1 },
417 
418  /* RFC3646 OPTIONS */
419 
420  { "name-servers", "6A", &dhcpv6_universe, 23, 1 },
421  { "domain-search", "D", &dhcpv6_universe, 24, 1 },
422 
423  /* RFC3633 OPTIONS */
424 
425  { "ia-pd", "X", &dhcpv6_universe, 25, 1 },
426  { "ia-prefix", "X", &dhcpv6_universe, 26, 1 },
427 
428  /* RFC3898 OPTIONS */
429 
430  { "nis-servers", "6A", &dhcpv6_universe, 27, 1 },
431  { "nisp-servers", "6A", &dhcpv6_universe, 28, 1 },
432  { "nis-domain-name", "D", &dhcpv6_universe, 29, 1 },
433  { "nisp-domain-name", "D", &dhcpv6_universe, 30, 1 },
434 
435  /* RFC4075 OPTIONS */
436  { "sntp-servers", "6A", &dhcpv6_universe, 31, 1 },
437 
438  /* RFC4242 OPTIONS */
439 
440  { "info-refresh-time", "T", &dhcpv6_universe, 32, 1 },
441 
442  /* RFC4280 OPTIONS */
443 
444  { "bcms-server-d", "D", &dhcpv6_universe, 33, 1 },
445  { "bcms-server-a", "6A", &dhcpv6_universe, 34, 1 },
446 
447  /* Note that 35 is not assigned. */
448 
449 #if defined(RFC4776_OPTIONS)
450  /* RFC4776 OPTIONS */
451 
452  { "geoconf-civic", "X", &dhcpv6_universe, 36, 1 },
453 #endif
454 
455  /* RFC4649 OPTIONS */
456 
457  /* The remote-id option looks like the VSIO option, but for all
458  * intents and purposes we only need to treat the entire field
459  * like a globally unique identifier (and if we create such an
460  * option, ensure the first 4 bytes are our enterprise-id followed
461  * by a globally unique ID so long as you're within that enterprise
462  * id). So we'll use "X" for now unless someone grumbles.
463  */
464  { "remote-id", "X", &dhcpv6_universe, 37, 1 },
465 
466  /* RFC4580 OPTIONS */
467 
468  { "subscriber-id", "X", &dhcpv6_universe, 38, 1 },
469 
470  /* RFC4704 OPTIONS */
471 
472  /* The DHCPv6 FQDN option is...weird.
473  *
474  * We use the same "virtual" encapsulated space as DHCPv4's FQDN
475  * option, so it can all be configured in one place. Since the
476  * options system does not support multiple inheritance, we use
477  * a 'shill' layer to perform the different protocol conversions,
478  * and to redirect any queries in the DHCPv4 FQDN's space.
479  */
480  { "fqdn", "Efqdn6-if-you-see-me-its-a-bug-bug-bug.",
481  &dhcpv6_universe, 39, 1 },
482 
483 
484  /* RFC5192 */
485 #if defined(RFC5192_OPTIONS)
486  { "pana-agent", "6A", &dhcpv6_universe, 40, 1 },
487 #endif
488 
489  /* RFC4833 OPTIONS */
490 #if defined(RFC4833_OPTIONS)
491  { "new-posix-timezone", "t", &dhcpv6_universe, 41, 1 },
492  { "new-tzdb-timezone", "t", &dhcpv6_universe, 42, 1 },
493 #endif
494 
495  /* RFC4994 OPTIONS */
496 #if defined(RFC4994_OPTIONS)
497  { "ero", "SA", &dhcpv6_universe, 43, 1 },
498 #endif
499 
500  /* RFC5007 OPTIONS */
501 
502  { "lq-query", "X", &dhcpv6_universe, 44, 1 },
503  { "client-data", "X", &dhcpv6_universe, 45, 1 },
504  { "clt-time", "L", &dhcpv6_universe, 46, 1 },
505  { "lq-relay-data", "6X", &dhcpv6_universe, 47, 1 },
506  { "lq-client-link", "6A", &dhcpv6_universe, 48, 1 },
507 
508  /* RFC5223 OPTIONS */
509 #if defined(RFC5223_OPTIONS)
510  { "v6-lost", "d", &dhcpv6_universe, 51, 1 },
511 #endif
512 
513  /* RFC5417 OPTIONS */
514 #if defined(RFC5417_OPTIONS)
515  { "capwap-ac-v6", "6a", &dhcpv6_universe, 52, 1 },
516 #endif
517 
518  /* RFC5460 OPTIONS */
519 #if defined(RFC5460_OPTIONS)
520  { "relay-id", "X", &dhcpv6_universe, 53, 1 },
521 #endif
522 
523  /* RFC5986 OPTIONS */
524 #if defined(RFC5986_OPTIONS)
525  { "v6-access-domain", "d", &dhcpv6_universe, 57, 1 },
526 #endif
527 
528  /* RFC6011 OPTIONS */
529 #if defined(RFC6011_OPTIONS)
530  { "sip-ua-cs-list", "D", &dhcpv6_universe, 58, 1 },
531 #endif
532 
533  /* RFC5970 OPTIONS */
534 #if defined(RFC5970_OPTIONS)
535  { "bootfile-url", "t", &dhcpv6_universe, 59, 1 },
536  { "bootfile-param", "X", &dhcpv6_universe, 60, 1 },
537  { "client-arch-type", "SA", &dhcpv6_universe, 61, 1 },
538  { "nii", "BBB", &dhcpv6_universe, 62, 1 },
539 #endif
540 
541  /* RFC6334 OPTIONS */
542 #if defined(RFC6334_OPTIONS)
543  { "aftr-name", "d", &dhcpv6_universe, 64, 1 },
544 #endif
545 
546  /* RFC6440 OPTIONS */
547 #if defined(RFC6440_OPTIONS)
548  { "erp-local-domain-name", "d", &dhcpv6_universe, 65, 1 },
549 #endif
550 
551  /* RFC6731 OPTIONS */
552 #if defined(RFC6731_OPTIONS)
553  { "rdnss-selection", "6BD", &dhcpv6_universe, 74, 1 },
554 #endif
555 
556  /* RFC6939 OPTIONS */
557 #if defined(RFC6939_OPTIONS)
558  { "client-linklayer-addr", "X", &dhcpv6_universe, 79, 1 },
559 #endif
560 
561  /* RFC6977 OPTIONS */
562 #if defined(RFC6977_OPTIONS)
563  { "link-address", "6", &dhcpv6_universe, 80, 1 },
564 #endif
565 
566  /* RFC7083 OPTIONS */
567 #if defined(RFC7083_OPTIONS)
568  { "solmax-rt", "L", &dhcpv6_universe, 82, 1 },
569  { "inf-max-rt", "L", &dhcpv6_universe, 83, 1 },
570 #endif
571 
572  /* RFC7341 OPTIONS */
573 #if defined(RFC7341_OPTIONS)
574  { "dhcpv4-msg", "X", &dhcpv6_universe, 87, 1 },
575  { "dhcp4-o-dhcp6-server", "6A", &dhcpv6_universe, 88, 1 },
576 #endif
577 
578 #if defined(RFC7710_OPTIONS)
579  { "v6-captive-portal", "t", &dhcpv6_universe, 103, 1 },
580 #endif
581 
582  { "relay-source-port", "S", &dhcpv6_universe, 135, 1 },
583 
584 #if defined(RFC6153_OPTIONS)
585  { "ipv6-address-andsf", "6A", &dhcpv6_universe, 143, 1 },
586 #endif
587 
588  { NULL, NULL, NULL, 0, 0 }
589 };
590 
592  { "duid-llt", DUID_LLT }, /* Link-Local Plus Time */
593  { "duid-en", DUID_EN }, /* DUID based upon enterprise-ID. */
594  { "duid-ll", DUID_LL }, /* DUID from Link Local address only. */
595  { "duid-uuid", DUID_UUID }, /* DUID based upon UUID */
596  { NULL, 0 }
597 };
598 
600  NULL,
601  "duid-types", 2,
603 };
604 
606  { "success", 0 }, /* Success */
607  { "UnspecFail", 1 }, /* Failure, for unspecified reasons. */
608  { "NoAddrsAvail", 2 }, /* Server has no addresses to assign. */
609  { "NoBinding", 3 }, /* Client record (binding) unavailable. */
610  { "NotOnLink", 4 }, /* Bad prefix for the link. */
611  { "UseMulticast", 5 }, /* Not just good advice. It's the law. */
612  { "NoPrefixAvail", 6 }, /* Server has no prefixes to assign. */
613  { "UnknownQueryType", 7 }, /* Query-type unknown/unsupported. */
614  { "MalformedQuery", 8 }, /* Leasequery not valid. */
615  { "NotConfigured", 9 }, /* The target address is not in config. */
616  { "NotAllowed", 10 }, /* Server doesn't allow the leasequery. */
617  { "QueryTerminated", 11 }, /* Leasequery terminated. */
618  { NULL, 0 }
619 };
620 
622  NULL,
623  "status-codes", 2,
625 };
626 
628  { "query-by-address", 1 },
629  { "query-by-clientid", 2 },
630  { "query-by-relay-id", 3 },
631  { "query-by-link-address", 4 },
632  { "query-by-remote-id", 5 },
633  { NULL, 0 }
634 };
635 
636 struct enumeration lq6_query_types = {
637  NULL,
638  "query-types", 2,
640 };
641 
643  { "SOLICIT", 1 },
644  { "ADVERTISE", 2 },
645  { "REQUEST", 3 },
646  { "CONFIRM", 4 },
647  { "RENEW", 5 },
648  { "REBIND", 6 },
649  { "REPLY", 7 },
650  { "RELEASE", 8 },
651  { "DECLINE", 9 },
652  { "RECONFIGURE", 10 },
653  { "INFORMATION-REQUEST", 11 },
654  { "RELAY-FORW", 12 },
655  { "RELAY-REPL", 13 },
656  { "LEASEQUERY", 14 },
657  { "LEASEQUERY-REPLY", 15 },
658  { "LEASEQUERY-DONE", 16 },
659  { "LEASEQUERY-DATA", 17 },
660  { "RECONFIGURE-REQUEST", 18 },
661  { "RECONFIGURE-REPLY", 19 },
662  { "DHCPV4-QUERY", 20 },
663  { "DHCPV4-RESPONSE", 21 },
664  { NULL, 0 }
665 };
666 
667 /* Some code refers to a different table. */
668 const char *dhcpv6_type_names[] = {
669  NULL,
670  "Solicit",
671  "Advertise",
672  "Request",
673  "Confirm",
674  "Renew",
675  "Rebind",
676  "Reply",
677  "Release",
678  "Decline",
679  "Reconfigure",
680  "Information-request",
681  "Relay-forward",
682  "Relay-reply",
683  "Leasequery",
684  "Leasequery-reply",
685  "Leasequery-done",
686  "Leasequery-data",
687  "Reconfigure-request",
688  "Reconfigure-reply",
689  "Dhcpv4-query",
690  "Dhcpv4-response"
691 };
693  (sizeof(dhcpv6_type_names) / sizeof(dhcpv6_type_names[0]));
694 
695 struct enumeration dhcpv6_messages = {
696  NULL,
697  "dhcpv6-messages", 1,
699 };
700 
701 struct universe vsio_universe;
702 static struct option vsio_options[] = {
703  { "isc", "Eisc6.", &vsio_universe, 2495, 1 },
704  { NULL, NULL, NULL, 0, 0 }
705 };
706 
707 struct universe isc6_universe;
708 static struct option isc6_options[] = {
709  { "media", "t", &isc6_universe, 1, 1 },
710  { "update-assist", "X", &isc6_universe, 2, 1 },
711  { "4o6-interface", "t", &isc6_universe, 60000, 1 },
712  { "4o6-source-address", "6", &isc6_universe, 60001, 1 },
713  { NULL, NULL, NULL, 0, 0 }
714 };
715 
716 const char *hardware_types [] = {
717  "unknown-0",
718  "ethernet",
719  "unknown-2",
720  "unknown-3",
721  "unknown-4",
722  "unknown-5",
723  "token-ring",
724  "unknown-7",
725  "fddi",
726  "unknown-9",
727  "unknown-10",
728  "unknown-11",
729  "unknown-12",
730  "unknown-13",
731  "unknown-14",
732  "unknown-15",
733  "unknown-16",
734  "unknown-17",
735  "unknown-18",
736  "unknown-19",
737  "unknown-20",
738  "unknown-21",
739  "unknown-22",
740  "unknown-23",
741  "unknown-24",
742  "unknown-25",
743  "unknown-26",
744  "unknown-27",
745  "unknown-28",
746  "unknown-29",
747  "unknown-30",
748  "unknown-31",
749  "infiniband",
750  "unknown-33",
751  "unknown-34",
752  "unknown-35",
753  "unknown-36",
754  "unknown-37",
755  "unknown-38",
756  "unknown-39",
757  "unknown-40",
758  "unknown-41",
759  "unknown-42",
760  "unknown-43",
761  "unknown-44",
762  "unknown-45",
763  "unknown-46",
764  "unknown-47",
765  "unknown-48",
766  "unknown-49",
767  "unknown-50",
768  "unknown-51",
769  "unknown-52",
770  "unknown-53",
771  "unknown-54",
772  "unknown-55",
773  "unknown-56",
774  "unknown-57",
775  "unknown-58",
776  "unknown-59",
777  "unknown-60",
778  "unknown-61",
779  "unknown-62",
780  "unknown-63",
781  "unknown-64",
782  "unknown-65",
783  "unknown-66",
784  "unknown-67",
785  "unknown-68",
786  "unknown-69",
787  "unknown-70",
788  "unknown-71",
789  "unknown-72",
790  "unknown-73",
791  "unknown-74",
792  "unknown-75",
793  "unknown-76",
794  "unknown-77",
795  "unknown-78",
796  "unknown-79",
797  "unknown-80",
798  "unknown-81",
799  "unknown-82",
800  "unknown-83",
801  "unknown-84",
802  "unknown-85",
803  "unknown-86",
804  "unknown-87",
805  "unknown-88",
806  "unknown-89",
807  "unknown-90",
808  "unknown-91",
809  "unknown-92",
810  "unknown-93",
811  "unknown-94",
812  "unknown-95",
813  "unknown-96",
814  "unknown-97",
815  "unknown-98",
816  "unknown-99",
817  "unknown-100",
818  "unknown-101",
819  "unknown-102",
820  "unknown-103",
821  "unknown-104",
822  "unknown-105",
823  "unknown-106",
824  "unknown-107",
825  "unknown-108",
826  "unknown-109",
827  "unknown-110",
828  "unknown-111",
829  "unknown-112",
830  "unknown-113",
831  "unknown-114",
832  "unknown-115",
833  "unknown-116",
834  "unknown-117",
835  "unknown-118",
836  "unknown-119",
837  "unknown-120",
838  "unknown-121",
839  "unknown-122",
840  "unknown-123",
841  "unknown-124",
842  "unknown-125",
843  "unknown-126",
844  "unknown-127",
845  "unknown-128",
846  "unknown-129",
847  "unknown-130",
848  "unknown-131",
849  "unknown-132",
850  "unknown-133",
851  "unknown-134",
852  "unknown-135",
853  "unknown-136",
854  "unknown-137",
855  "unknown-138",
856  "unknown-139",
857  "unknown-140",
858  "unknown-141",
859  "unknown-142",
860  "unknown-143",
861  "unknown-144",
862  "unknown-145",
863  "unknown-146",
864  "unknown-147",
865  "unknown-148",
866  "unknown-149",
867  "unknown-150",
868  "unknown-151",
869  "unknown-152",
870  "unknown-153",
871  "unknown-154",
872  "unknown-155",
873  "unknown-156",
874  "unknown-157",
875  "unknown-158",
876  "unknown-159",
877  "unknown-160",
878  "unknown-161",
879  "unknown-162",
880  "unknown-163",
881  "unknown-164",
882  "unknown-165",
883  "unknown-166",
884  "unknown-167",
885  "unknown-168",
886  "unknown-169",
887  "unknown-170",
888  "unknown-171",
889  "unknown-172",
890  "unknown-173",
891  "unknown-174",
892  "unknown-175",
893  "unknown-176",
894  "unknown-177",
895  "unknown-178",
896  "unknown-179",
897  "unknown-180",
898  "unknown-181",
899  "unknown-182",
900  "unknown-183",
901  "unknown-184",
902  "unknown-185",
903  "unknown-186",
904  "unknown-187",
905  "unknown-188",
906  "unknown-189",
907  "unknown-190",
908  "unknown-191",
909  "unknown-192",
910  "unknown-193",
911  "unknown-194",
912  "unknown-195",
913  "unknown-196",
914  "unknown-197",
915  "unknown-198",
916  "unknown-199",
917  "unknown-200",
918  "unknown-201",
919  "unknown-202",
920  "unknown-203",
921  "unknown-204",
922  "unknown-205",
923  "unknown-206",
924  "unknown-207",
925  "unknown-208",
926  "unknown-209",
927  "unknown-210",
928  "unknown-211",
929  "unknown-212",
930  "unknown-213",
931  "unknown-214",
932  "unknown-215",
933  "unknown-216",
934  "unknown-217",
935  "unknown-218",
936  "unknown-219",
937  "unknown-220",
938  "unknown-221",
939  "unknown-222",
940  "unknown-223",
941  "unknown-224",
942  "unknown-225",
943  "unknown-226",
944  "unknown-227",
945  "unknown-228",
946  "unknown-229",
947  "unknown-230",
948  "unknown-231",
949  "unknown-232",
950  "unknown-233",
951  "unknown-234",
952  "unknown-235",
953  "unknown-236",
954  "unknown-237",
955  "unknown-238",
956  "unknown-239",
957  "unknown-240",
958  "unknown-241",
959  "unknown-242",
960  "unknown-243",
961  "unknown-244",
962  "unknown-245",
963  "unknown-246",
964  "unknown-247",
965  "unknown-248",
966  "unknown-249",
967  "unknown-250",
968  "unknown-251",
969  "unknown-252",
970  "unknown-253",
971  "unknown-254",
972  "unknown-255" };
973 
977 
978 /* Universe containing names of configuration options, which, rather than
979  writing "option universe-name.option-name ...;", can be set by writing
980  "option-name ...;". */
981 
983 
984 /* XXX: omapi must die...all the below keeps us from having to make the
985  * option structures omapi typed objects, which is a bigger headache.
986  */
987 
988 char *default_option_format = (char *) "X";
989 
990 /* Must match hash_reference/dereference types in omapip/hash.h. */
991 int
992 option_reference(struct option **dest, struct option *src,
993  const char * file, int line)
994 {
995  if (!dest || !src)
996  return DHCP_R_INVALIDARG;
997 
998  if (*dest) {
999 #if defined(POINTER_DEBUG)
1000  log_fatal("%s(%d): reference store into non-null pointer!",
1001  file, line);
1002 #else
1003  return DHCP_R_INVALIDARG;
1004 #endif
1005  }
1006 
1007  *dest = src;
1008  src->refcnt++;
1009  rc_register(file, line, dest, src, src->refcnt, 0, RC_MISC);
1010  return(ISC_R_SUCCESS);
1011 }
1012 
1013 int
1014 option_dereference(struct option **dest, const char *file, int line)
1015 {
1016  if (!dest)
1017  return DHCP_R_INVALIDARG;
1018 
1019  if (!*dest) {
1020 #if defined (POINTER_DEBUG)
1021  log_fatal("%s(%d): dereference of null pointer!", file, line);
1022 #else
1023  return DHCP_R_INVALIDARG;
1024 #endif
1025  }
1026 
1027  if ((*dest)->refcnt <= 0) {
1028 #if defined (POINTER_DEBUG)
1029  log_fatal("%s(%d): dereference of <= 0 refcnt!", file, line);
1030 #else
1031  return DHCP_R_INVALIDARG;
1032 #endif
1033  }
1034 
1035  (*dest)->refcnt--;
1036 
1037  rc_register(file, line, dest, (*dest), (*dest)->refcnt, 1, RC_MISC);
1038 
1039  if ((*dest)->refcnt == 0) {
1040  /* The option name may be packed in the same alloc as the
1041  * option structure.
1042  */
1043  if ((char *) (*dest)->name != (char *) ((*dest) + 1))
1044  dfree((char *) (*dest)->name, file, line);
1045 
1046  /* It's either a user-configured format (allocated), or the
1047  * default static format.
1048  */
1049  if (((*dest)->format != NULL) &&
1050  ((*dest)->format != default_option_format)) {
1051  dfree((char *) (*dest)->format, file, line);
1052  }
1053 
1054  dfree(*dest, file, line);
1055  }
1056 
1057  *dest = NULL;
1058  return ISC_R_SUCCESS;
1059 }
1060 
1062 {
1063  unsigned code;
1064  int i;
1065 
1066  /* The 'universes' table is dynamically grown to contain
1067  * universe as they're configured - except during startup.
1068  * Since we know how many we put down in .c files, we can
1069  * allocate a more-than-right-sized buffer now, leaving some
1070  * space for user-configured option spaces.
1071  *
1072  * 1: dhcp_universe (dhcpv4 options)
1073  * 2: nwip_universe (dhcpv4 NWIP option)
1074  * 3: fqdn_universe (dhcpv4 fqdn option - reusable for v6)
1075  * 4: vendor_class_universe (VIVCO)
1076  * 5: vendor_universe (VIVSO)
1077  * 6: isc_universe (dhcpv4 isc config space)
1078  * 7: dhcpv6_universe (dhcpv6 options)
1079  * 8: vsio_universe (DHCPv6 Vendor-Identified space)
1080  * 9: isc6_universe (ISC's Vendor universe in DHCPv6 VSIO)
1081  * 10: fqdn6_universe (dhcpv6 fqdn option shill to v4)
1082  * 11: agent_universe (dhcpv4 relay agent - see server/stables.c)
1083  * 12: server_universe (server's config, see server/stables.c)
1084  * 13: user-config
1085  * 14: more user-config
1086  * 15: more user-config
1087  * 16: more user-config
1088  */
1089  universe_max = 16;
1090  i = universe_max * sizeof(struct universe *);
1091  if (i <= 0)
1092  log_fatal("Ludicrous initial size option space table.");
1093  universes = dmalloc(i, MDL);
1094  if (universes == NULL)
1095  log_fatal("Can't allocate option space table.");
1096  memset(universes, 0, i);
1097 
1098  /* Set up the DHCP option universe... */
1099  dhcp_universe.name = "dhcp";
1110  dhcp_universe.tag_size = 1;
1119  if (!option_name_new_hash(&dhcp_universe.name_hash,
1121  !option_code_new_hash(&dhcp_universe.code_hash,
1123  log_fatal ("Can't allocate dhcp option hash table.");
1124  for (i = 0 ; dhcp_options[i].name ; i++) {
1125  option_code_hash_add(dhcp_universe.code_hash,
1126  &dhcp_options[i].code, 0,
1127  &dhcp_options[i], MDL);
1128  option_name_hash_add(dhcp_universe.name_hash,
1129  dhcp_options [i].name, 0,
1130  &dhcp_options [i], MDL);
1131  }
1132 #if defined(REPORT_HASH_PERFORMANCE)
1133  log_info("DHCP name hash: %s",
1134  option_name_hash_report(dhcp_universe.name_hash));
1135  log_info("DHCP code hash: %s",
1136  option_code_hash_report(dhcp_universe.code_hash));
1137 #endif
1138 
1139  /* Set up the Novell option universe (for option 63)... */
1140  nwip_universe.name = "nwip";
1141  nwip_universe.concat_duplicates = 0; /* XXX: reference? */
1151  nwip_universe.tag_size = 1;
1157  nwip_universe.end = 0;
1158  code = DHO_NWIP_SUBOPTIONS;
1159  nwip_universe.enc_opt = NULL;
1160  if (!option_code_hash_lookup(&nwip_universe.enc_opt,
1161  dhcp_universe.code_hash, &code, 0, MDL))
1162  log_fatal("Unable to find NWIP parent option (%s:%d).", MDL);
1165  if (!option_name_new_hash(&nwip_universe.name_hash,
1166  NWIP_HASH_SIZE, MDL) ||
1167  !option_code_new_hash(&nwip_universe.code_hash,
1168  NWIP_HASH_SIZE, MDL))
1169  log_fatal ("Can't allocate nwip option hash table.");
1170  for (i = 0 ; nwip_options[i].name ; i++) {
1171  option_code_hash_add(nwip_universe.code_hash,
1172  &nwip_options[i].code, 0,
1173  &nwip_options[i], MDL);
1174  option_name_hash_add(nwip_universe.name_hash,
1175  nwip_options[i].name, 0,
1176  &nwip_options[i], MDL);
1177  }
1178 #if defined(REPORT_HASH_PERFORMANCE)
1179  log_info("NWIP name hash: %s",
1180  option_name_hash_report(nwip_universe.name_hash));
1181  log_info("NWIP code hash: %s",
1182  option_code_hash_report(nwip_universe.code_hash));
1183 #endif
1184 
1185  /* Set up the FQDN option universe... */
1186  fqdn_universe.name = "fqdn";
1197  fqdn_universe.tag_size = 1;
1203  fqdn_universe.end = 0;
1205  code = DHO_FQDN;
1206  fqdn_universe.enc_opt = NULL;
1207  if (!option_code_hash_lookup(&fqdn_universe.enc_opt,
1208  dhcp_universe.code_hash, &code, 0, MDL))
1209  log_fatal("Unable to find FQDN parent option (%s:%d).", MDL);
1211  if (!option_name_new_hash(&fqdn_universe.name_hash,
1212  FQDN_HASH_SIZE, MDL) ||
1213  !option_code_new_hash(&fqdn_universe.code_hash,
1214  FQDN_HASH_SIZE, MDL))
1215  log_fatal ("Can't allocate fqdn option hash table.");
1216  for (i = 0 ; fqdn_options[i].name ; i++) {
1217  option_code_hash_add(fqdn_universe.code_hash,
1218  &fqdn_options[i].code, 0,
1219  &fqdn_options[i], MDL);
1220  option_name_hash_add(fqdn_universe.name_hash,
1221  fqdn_options[i].name, 0,
1222  &fqdn_options[i], MDL);
1223  }
1224 #if defined(REPORT_HASH_PERFORMANCE)
1225  log_info("FQDN name hash: %s",
1226  option_name_hash_report(fqdn_universe.name_hash));
1227  log_info("FQDN code hash: %s",
1228  option_code_hash_report(fqdn_universe.code_hash));
1229 #endif
1230 
1231  /* Set up the Vendor Identified Vendor Class options (for option
1232  * 125)...
1233  */
1234  vendor_class_universe.name = "vendor-class";
1235  vendor_class_universe.concat_duplicates = 0; /* XXX: reference? */
1252  code = DHO_VIVCO_SUBOPTIONS;
1254  if (!option_code_hash_lookup(&vendor_class_universe.enc_opt,
1255  dhcp_universe.code_hash, &code, 0, MDL))
1256  log_fatal("Unable to find VIVCO parent option (%s:%d).", MDL);
1259  if (!option_name_new_hash(&vendor_class_universe.name_hash,
1260  VIVCO_HASH_SIZE, MDL) ||
1261  !option_code_new_hash(&vendor_class_universe.code_hash,
1262  VIVCO_HASH_SIZE, MDL))
1263  log_fatal("Can't allocate Vendor Identified Vendor Class "
1264  "option hash table.");
1265  for (i = 0 ; vendor_class_options[i].name ; i++) {
1266  option_code_hash_add(vendor_class_universe.code_hash,
1267  &vendor_class_options[i].code, 0,
1268  &vendor_class_options[i], MDL);
1269  option_name_hash_add(vendor_class_universe.name_hash,
1270  vendor_class_options[i].name, 0,
1271  &vendor_class_options[i], MDL);
1272  }
1273 #if defined(REPORT_HASH_PERFORMANCE)
1274  log_info("VIVCO name hash: %s",
1275  option_name_hash_report(vendor_class_universe.name_hash));
1276  log_info("VIVCO code hash: %s",
1277  option_code_hash_report(vendor_class_universe.code_hash));
1278 #endif
1279 
1280  /* Set up the Vendor Identified Vendor Sub-options (option 126)... */
1281  vendor_universe.name = "vendor";
1282  vendor_universe.concat_duplicates = 0; /* XXX: reference? */
1298  vendor_universe.end = 0;
1299  code = DHO_VIVSO_SUBOPTIONS;
1300  vendor_universe.enc_opt = NULL;
1301  if (!option_code_hash_lookup(&vendor_universe.enc_opt,
1302  dhcp_universe.code_hash, &code, 0, MDL))
1303  log_fatal("Unable to find VIVSO parent option (%s:%d).", MDL);
1306  if (!option_name_new_hash(&vendor_universe.name_hash,
1307  VIVSO_HASH_SIZE, MDL) ||
1308  !option_code_new_hash(&vendor_universe.code_hash,
1309  VIVSO_HASH_SIZE, MDL))
1310  log_fatal("Can't allocate Vendor Identified Vendor Sub-"
1311  "options hash table.");
1312  for (i = 0 ; vendor_options[i].name ; i++) {
1313  option_code_hash_add(vendor_universe.code_hash,
1314  &vendor_options[i].code, 0,
1315  &vendor_options[i], MDL);
1316  option_name_hash_add(vendor_universe.name_hash,
1317  vendor_options[i].name, 0,
1318  &vendor_options[i], MDL);
1319  }
1320 #if defined(REPORT_HASH_PERFORMANCE)
1321  log_info("VIVSO name hash: %s",
1322  option_name_hash_report(vendor_universe.name_hash));
1323  log_info("VIVSO code hash: %s",
1324  option_code_hash_report(vendor_universe.code_hash));
1325 #endif
1326 
1327  /* Set up the ISC Vendor-option universe (for option 125.2495)... */
1328  isc_universe.name = "isc";
1329  isc_universe.concat_duplicates = 0; /* XXX: check VIVSO ref */
1339  isc_universe.tag_size = 2;
1345  isc_universe.end = 0;
1346  code = VENDOR_ISC_SUBOPTIONS;
1347  isc_universe.enc_opt = NULL;
1348  if (!option_code_hash_lookup(&isc_universe.enc_opt,
1349  vendor_universe.code_hash, &code, 0, MDL))
1350  log_fatal("Unable to find ISC parent option (%s:%d).", MDL);
1353  if (!option_name_new_hash(&isc_universe.name_hash,
1354  VIV_ISC_HASH_SIZE, MDL) ||
1355  !option_code_new_hash(&isc_universe.code_hash,
1357  log_fatal("Can't allocate ISC Vendor options hash table.");
1358  for (i = 0 ; isc_options[i].name ; i++) {
1359  option_code_hash_add(isc_universe.code_hash,
1360  &isc_options[i].code, 0,
1361  &isc_options[i], MDL);
1362  option_name_hash_add(isc_universe.name_hash,
1363  isc_options[i].name, 0,
1364  &isc_options[i], MDL);
1365  }
1366 #if defined(REPORT_HASH_PERFORMANCE)
1367  log_info("ISC name hash: %s",
1368  option_name_hash_report(isc_universe.name_hash));
1369  log_info("ISC code hash: %s",
1370  option_code_hash_report(isc_universe.code_hash));
1371 #endif
1372 
1373  /* Set up the DHCPv6 root universe. */
1374  dhcpv6_universe.name = "dhcp6";
1391  /* DHCPv6 has no END option. */
1392  dhcpv6_universe.end = 0x00;
1395  if (!option_name_new_hash(&dhcpv6_universe.name_hash,
1397  !option_code_new_hash(&dhcpv6_universe.code_hash,
1399  log_fatal("Can't allocate dhcpv6 option hash tables.");
1400  for (i = 0 ; dhcpv6_options[i].name ; i++) {
1401  option_code_hash_add(dhcpv6_universe.code_hash,
1402  &dhcpv6_options[i].code, 0,
1403  &dhcpv6_options[i], MDL);
1404  option_name_hash_add(dhcpv6_universe.name_hash,
1405  dhcpv6_options[i].name, 0,
1406  &dhcpv6_options[i], MDL);
1407  }
1408 
1409  /* Add DHCPv6 protocol enumeration sets. */
1413 
1414  /* Set up DHCPv6 VSIO universe. */
1415  vsio_universe.name = "vsio";
1426  vsio_universe.tag_size = 4;
1429  vsio_universe.get_length = NULL;
1430  vsio_universe.store_length = NULL;
1432  /* No END option. */
1433  vsio_universe.end = 0x00;
1434  code = D6O_VENDOR_OPTS;
1435  if (!option_code_hash_lookup(&vsio_universe.enc_opt,
1436  dhcpv6_universe.code_hash, &code, 0, MDL))
1437  log_fatal("Unable to find VSIO parent option (%s:%d).", MDL);
1440  if (!option_name_new_hash(&vsio_universe.name_hash,
1441  VSIO_HASH_SIZE, MDL) ||
1442  !option_code_new_hash(&vsio_universe.code_hash,
1443  VSIO_HASH_SIZE, MDL))
1444  log_fatal("Can't allocate Vendor Specific Information "
1445  "Options space.");
1446  for (i = 0 ; vsio_options[i].name != NULL ; i++) {
1447  option_code_hash_add(vsio_universe.code_hash,
1448  &vsio_options[i].code, 0,
1449  &vsio_options[i], MDL);
1450  option_name_hash_add(vsio_universe.name_hash,
1451  vsio_options[i].name, 0,
1452  &vsio_options[i], MDL);
1453  }
1454 
1455  /* Add ISC VSIO sub-sub-option space. */
1456  isc6_universe.name = "isc6";
1467  isc6_universe.tag_size = 4;
1470  isc6_universe.get_length = NULL;
1471  isc6_universe.store_length = NULL;
1473  /* No END option. */
1474  isc6_universe.end = 0x00;
1475  code = 2495;
1476  if (!option_code_hash_lookup(&isc6_universe.enc_opt,
1477  vsio_universe.code_hash, &code, 0, MDL))
1478  log_fatal("Unable to find ISC parent option (%s:%d).", MDL);
1481  if (!option_name_new_hash(&isc6_universe.name_hash,
1482  VIV_ISC_HASH_SIZE, MDL) ||
1483  !option_code_new_hash(&isc6_universe.code_hash,
1485  log_fatal("Can't allocate Vendor Specific Information "
1486  "Options space.");
1487  for (i = 0 ; isc6_options[i].name != NULL ; i++) {
1488  option_code_hash_add(isc6_universe.code_hash,
1489  &isc6_options[i].code, 0,
1490  &isc6_options[i], MDL);
1491  option_name_hash_add(isc6_universe.name_hash,
1492  isc6_options[i].name, 0,
1493  &isc6_options[i], MDL);
1494  }
1495 
1496  /* The fqdn6 option space is a protocol-wrapper shill for the
1497  * old DHCPv4 space.
1498  */
1499  fqdn6_universe.name = "fqdn6-if-you-see-me-its-a-bug-bug-bug";
1501  fqdn6_universe.option_state_dereference = NULL; /* Covered by v4. */
1507  /* This is not a 'normal' encapsulated space, so these values are
1508  * meaningless.
1509  */
1512  fqdn6_universe.get_tag = NULL;
1513  fqdn6_universe.store_tag = NULL;
1514  fqdn6_universe.get_length = NULL;
1517  fqdn6_universe.end = 0;
1519  code = D6O_CLIENT_FQDN;
1520  fqdn6_universe.enc_opt = NULL;
1521  if (!option_code_hash_lookup(&fqdn6_universe.enc_opt,
1522  dhcpv6_universe.code_hash, &code, 0, MDL))
1523  log_fatal("Unable to find FQDN v6 parent option. (%s:%d).",
1524  MDL);
1526  /* The fqdn6 space shares the same option space as the v4 space.
1527  * So there are no name or code hashes on the v6 side.
1528  */
1529  fqdn6_universe.name_hash = NULL;
1530  fqdn6_universe.code_hash = NULL;
1531 
1532 
1533  /* Set up the hash of DHCPv4 universes. */
1534  universe_new_hash(&universe_hash, UNIVERSE_HASH_SIZE, MDL);
1535  universe_hash_add(universe_hash, dhcp_universe.name, 0,
1536  &dhcp_universe, MDL);
1537  universe_hash_add(universe_hash, nwip_universe.name, 0,
1538  &nwip_universe, MDL);
1539  universe_hash_add(universe_hash, fqdn_universe.name, 0,
1540  &fqdn_universe, MDL);
1541  universe_hash_add(universe_hash, vendor_class_universe.name, 0,
1543  universe_hash_add(universe_hash, vendor_universe.name, 0,
1544  &vendor_universe, MDL);
1545  universe_hash_add(universe_hash, isc_universe.name, 0,
1546  &isc_universe, MDL);
1547 
1548  /* Set up hashes for DHCPv6 universes. */
1549  universe_hash_add(universe_hash, dhcpv6_universe.name, 0,
1550  &dhcpv6_universe, MDL);
1551  universe_hash_add(universe_hash, vsio_universe.name, 0,
1552  &vsio_universe, MDL);
1553  universe_hash_add(universe_hash, isc6_universe.name, 0,
1554  &isc6_universe, MDL);
1555  /* previously this wasn't necessary, now that we can send
1556  * v6 encapsulated options it is.
1557  */
1558  universe_hash_add(universe_hash, fqdn6_universe.name, 0,
1559  &fqdn6_universe, MDL);
1560 
1561 }
#define RC_MISC
Definition: alloc.h:56
#define rc_register(file, line, reference, addr, refcnt, d, f)
Definition: alloc.h:88
int group_dereference(struct group **ptr, const char *file, int line)
Definition: alloc.c:205
int group_reference(struct group **ptr, struct group *bp, const char *file, int line)
Definition: alloc.c:177
struct option_cache * lookup_linked_option(struct universe *universe, struct option_state *options, unsigned code)
Definition: options.c:3978
void delete_fqdn6_option(struct universe *universe, struct option_state *options, int code)
Definition: options.c:3555
int nwip_option_space_encapsulate(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *universe)
Definition: options.c:3292
void fqdn6_option_space_foreach(struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff, void(*func)(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *))
Definition: options.c:3569
void save_hashed_option(struct universe *universe, struct option_state *options, struct option_cache *oc, isc_boolean_t appendp)
Definition: options.c:2839
int hashed_option_space_encapsulate(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *universe)
Definition: options.c:3249
int fqdn_universe_decode(struct option_state *options, const unsigned char *buffer, unsigned length, struct universe *u)
Definition: options.c:366
struct option_cache * lookup_hashed_option(struct universe *universe, struct option_state *options, unsigned code)
Definition: options.c:2518
int hashed_option_state_dereference(struct universe *universe, struct option_state *state, const char *file, int line)
Definition: options.c:3003
struct option_cache * lookup_fqdn6_option(struct universe *universe, struct option_state *options, unsigned code)
Definition: options.c:3534
int linked_option_state_dereference(struct universe *universe, struct option_state *state, const char *file, int line)
Definition: options.c:4003
void hashed_option_space_foreach(struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff, void(*func)(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *))
Definition: options.c:3832
int linked_option_space_encapsulate(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *universe)
Definition: options.c:3913
void linked_option_space_foreach(struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff, void(*func)(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *))
Definition: options.c:4014
void delete_hashed_option(struct universe *universe, struct option_state *options, int code)
Definition: options.c:2918
void save_linked_option(struct universe *universe, struct option_state *options, struct option_cache *oc, isc_boolean_t appendp)
Definition: options.c:3869
int fqdn_option_space_encapsulate(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *universe)
Definition: options.c:3417
int fqdn6_universe_decode(struct option_state *options, const unsigned char *buffer, unsigned length, struct universe *u)
Definition: options.c:3690
int fqdn6_option_space_encapsulate(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *universe)
Definition: options.c:3591
int parse_option_buffer(struct option_state *options, const unsigned char *buffer, unsigned length, struct universe *universe)
Definition: options.c:119
void save_fqdn6_option(struct universe *universe, struct option_state *options, struct option_cache *oc, isc_boolean_t appendp)
Definition: options.c:3545
void delete_linked_option(struct universe *universe, struct option_state *options, int code)
Definition: options.c:3949
void add_enumeration(struct enumeration *enumeration)
Definition: parse.c:41
u_int32_t getUShort(const unsigned char *)
void putUShort(unsigned char *, u_int32_t)
Definition: convert.c:86
u_int32_t getULong(const unsigned char *)
void putUChar(unsigned char *, u_int32_t)
Definition: convert.c:102
u_int32_t getUChar(const unsigned char *)
void putULong(unsigned char *, u_int32_t)
Definition: convert.c:70
#define D6O_CLIENT_FQDN
Definition: dhcp6.h:68
#define DUID_UUID
Definition: dhcp6.h:170
#define DUID_LL
Definition: dhcp6.h:169
#define DUID_LLT
Definition: dhcp6.h:167
#define DUID_EN
Definition: dhcp6.h:168
#define D6O_VENDOR_OPTS
Definition: dhcp6.h:46
#define VENDOR_ISC_SUBOPTIONS
Definition: dhcp.h:204
#define DHO_VIVSO_SUBOPTIONS
Definition: dhcp.h:165
#define DHO_VIVCO_SUBOPTIONS
Definition: dhcp.h:164
#define DHO_NWIP_SUBOPTIONS
Definition: dhcp.h:152
#define DHO_END
Definition: dhcp.h:167
#define DHO_FQDN
Definition: dhcp.h:154
#define BYTE_NAME_HASH_SIZE
Definition: dhcpd.h:109
#define FQDN_HASH_SIZE
Definition: dhcpd.h:153
#define BYTE_CODE_HASH_SIZE
Definition: dhcpd.h:112
#define UNIVERSE_HASH_SIZE
Definition: dhcpd.h:176
#define VIVCO_HASH_SIZE
Definition: dhcpd.h:160
#define VIV_ISC_HASH_SIZE
Definition: dhcpd.h:172
#define WORD_NAME_HASH_SIZE
Definition: dhcpd.h:121
#define VSIO_HASH_SIZE
Definition: dhcpd.h:168
struct universe dhcp_universe
#define NWIP_HASH_SIZE
Definition: dhcpd.h:149
const char int line
Definition: dhcpd.h:3802
#define VIVSO_HASH_SIZE
Definition: dhcpd.h:164
const char * file
Definition: dhcpd.h:3802
#define WORD_CODE_HASH_SIZE
Definition: dhcpd.h:124
unsigned do_case_hash(const void *, unsigned, unsigned)
Definition: hash.c:240
unsigned do_string_hash(const void *, unsigned, unsigned)
Definition: hash.c:266
unsigned do_number_hash(const void *, unsigned, unsigned)
Definition: hash.c:324
#define ISC_R_SUCCESS
#define MDL
Definition: omapip.h:567
void * dmalloc(size_t, const char *, int)
Definition: alloc.c:57
void dfree(void *, const char *, int)
Definition: alloc.c:145
void log_fatal(const char *,...) __attribute__((__format__(__printf__
int int log_info(const char *,...) __attribute__((__format__(__printf__
#define DHCP_R_INVALIDARG
Definition: result.h:49
Definition: dhcpd.h:962
Definition: tree.h:345
unsigned code
Definition: tree.h:349
int refcnt
Definition: tree.h:350
const char * name
Definition: tree.h:346
Definition: tree.h:301
int(* decode)(struct option_state *, const unsigned char *, unsigned, struct universe *)
Definition: tree.h:323
void(* store_length)(unsigned char *, u_int32_t)
Definition: tree.h:333
int tag_size
Definition: tree.h:334
void(* save_func)(struct universe *, struct option_state *, struct option_cache *, isc_boolean_t)
Definition: tree.h:306
int(* encapsulate)(struct data_string *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *)
Definition: tree.h:325
void(* store_tag)(unsigned char *, u_int32_t)
Definition: tree.h:331
int index
Definition: tree.h:339
int(* option_state_dereference)(struct universe *, struct option_state *, const char *, int)
Definition: tree.h:320
void(* delete_func)(struct universe *universe, struct option_state *, int)
Definition: tree.h:318
option_name_hash_t * name_hash
Definition: tree.h:336
unsigned site_code_min
Definition: tree.h:335
int concat_duplicates
Definition: tree.h:342
option_code_hash_t * code_hash
Definition: tree.h:337
u_int32_t(* get_tag)(const unsigned char *)
Definition: tree.h:330
u_int32_t(* get_length)(const unsigned char *)
Definition: tree.h:332
struct option * enc_opt
Definition: tree.h:338
int length_size
Definition: tree.h:334
void(* foreach)(struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *, void(*)(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *))
Definition: tree.h:308
const char * name
Definition: tree.h:302
struct option_cache *(* lookup_func)(struct universe *, struct option_state *, unsigned)
Definition: tree.h:303
unsigned end
Definition: tree.h:335
const int dhcpv6_type_name_max
Definition: tables.c:692
struct enumeration dhcpv6_status_codes
Definition: tables.c:621
struct enumeration_value dhcpv6_duid_type_values[]
Definition: tables.c:591
struct universe isc_universe
Definition: tables.c:344
HASH_FUNCTIONS(group, HASH_FUNCTIONS(const char *, struct group_object, group_hash_t, group_reference, group_dereference, do_string_hash)
Definition: tables.c:33
const char * hardware_types[]
Definition: tables.c:716
struct universe fqdn_universe
Definition: tables.c:318
struct enumeration_value lq6_query_type_values[]
Definition: tables.c:627
struct enumeration_value dhcpv6_status_code_values[]
Definition: tables.c:605
struct universe * config_universe
Definition: tables.c:982
struct universe nwip_universe
Definition: tables.c:290
char * default_option_format
Definition: tables.c:988
struct universe vsio_universe
Definition: tables.c:701
struct enumeration lq6_query_types
Definition: tables.c:636
int universe_count
Definition: tables.c:976
int option_reference(struct option **dest, struct option *src, const char *file, int line)
Definition: tables.c:992
struct enumeration_value dhcpv6_message_values[]
Definition: tables.c:642
struct universe fqdn6_universe
Definition: tables.c:319
struct universe vendor_universe
Definition: tables.c:338
struct enumeration dhcpv6_messages
Definition: tables.c:695
const char * dhcpv6_type_names[]
Definition: tables.c:668
struct universe isc6_universe
Definition: tables.c:707
int option_dereference(struct option **dest, const char *file, int line)
Definition: tables.c:1014
universe_hash_t * universe_hash
Definition: tables.c:974
struct universe vendor_class_universe
Definition: tables.c:332
struct universe dhcpv6_universe
Definition: tables.c:351
int universe_max
Definition: tables.c:976
void initialize_common_option_spaces()
Definition: tables.c:1061
struct enumeration dhcpv6_duid_types
Definition: tables.c:599
struct universe ** universes
Definition: tables.c:975