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