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