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