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