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