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