1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
|
/* tables.c
Tables of information... */
/*
* Copyright (c) 2004-2006 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* http://www.isc.org/
*
* This software has been written for Internet Systems Consortium
* by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
* To learn more about Internet Systems Consortium, see
* ``http://www.isc.org/''. To learn more about Vixie Enterprises,
* see ``http://www.vix.com''. To learn more about Nominum, Inc., see
* ``http://www.nominum.com''.
*/
#ifndef lint
static char copyright[] =
"$Id: tables.c,v 1.56 2006/07/22 02:24:16 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* XXXDPN: Moved here from hash.c, when it moved to libomapi. Not sure
where these really belong. */
HASH_FUNCTIONS (group, const char *, struct group_object, group_hash_t,
group_reference, group_dereference, do_string_hash)
HASH_FUNCTIONS (universe, const char *, struct universe, universe_hash_t, 0, 0,
do_case_hash)
HASH_FUNCTIONS (option_name, const char *, struct option, option_name_hash_t,
option_reference, option_dereference, do_case_hash)
HASH_FUNCTIONS (option_code, const unsigned *, struct option,
option_code_hash_t, option_reference, option_dereference,
do_number_hash)
/* DHCP Option names, formats and codes, from RFC1533.
Format codes:
I - IP address
l - 32-bit signed integer
L - 32-bit unsigned integer
s - 16-bit signed integer
S - 16-bit unsigned integer
b - 8-bit signed integer
B - 8-bit unsigned integer
t - ASCII text
T - Lease Time, 32-bit unsigned integer implying a number of seconds from
some event. The special all-ones value means 'infinite'. May either
be printed as a decimal, eg, "3600", or as this name, eg, "infinite".
f - flag (true or false)
A - array of whatever precedes (e.g., IA means array of IP addresses)
a - array of the preceding character (e.g., IIa means two or more IP
addresses)
U - name of an option space (universe)
F - implicit flag - the presence of the option indicates that the
flag is true.
o - the preceding value is optional.
E - encapsulation, string or colon-seperated hex list (the latter
two for parsing). E is followed by a text string containing
the name of the option space to encapsulate, followed by a '.'.
If the E is immediately followed by '.', the applicable vendor
option space is used if one is defined.
e - If an encapsulation directive is not the first thing in the string,
the option scanner requires an efficient way to find the encapsulation.
This is done by placing a 'e' at the beginning of the option. The
'e' has no other purpose, and is not required if 'E' is the first
thing in the option.
X - either an ASCII string or binary data. On output, the string is
scanned to see if it's printable ASCII and, if so, output as a
quoted string. If not, it's output as colon-seperated hex. On
input, the option can be specified either as a quoted string or as
a colon-seperated hex list.
N - enumeration. N is followed by a text string containing
the name of the set of enumeration values to parse or emit,
followed by a '.'. The width of the data is specified in the
named enumeration. Named enumerations are tracked in parse.c.
d - Domain name (i.e., FOO or FOO.BAR).
D - Domain list (i.e., example.com eng.example.com)
*/
struct universe dhcp_universe;
static struct option dhcp_options[] = {
{ "subnet-mask", "I", &dhcp_universe, 1, 1 },
{ "time-offset", "l", &dhcp_universe, 2, 1 },
{ "routers", "IA", &dhcp_universe, 3, 1 },
{ "time-servers", "IA", &dhcp_universe, 4, 1 },
{ "ien116-name-servers", "IA", &dhcp_universe, 5, 1 },
{ "domain-name-servers", "IA", &dhcp_universe, 6, 1 },
{ "log-servers", "IA", &dhcp_universe, 7, 1 },
{ "cookie-servers", "IA", &dhcp_universe, 8, 1 },
{ "lpr-servers", "IA", &dhcp_universe, 9, 1 },
{ "impress-servers", "IA", &dhcp_universe, 10, 1 },
{ "resource-location-servers", "IA", &dhcp_universe, 11, 1 },
{ "host-name", "t", &dhcp_universe, 12, 1 },
{ "boot-size", "S", &dhcp_universe, 13, 1 },
{ "merit-dump", "t", &dhcp_universe, 14, 1 },
{ "domain-name", "t", &dhcp_universe, 15, 1 },
{ "swap-server", "I", &dhcp_universe, 16, 1 },
{ "root-path", "t", &dhcp_universe, 17, 1 },
{ "extensions-path", "t", &dhcp_universe, 18, 1 },
{ "ip-forwarding", "f", &dhcp_universe, 19, 1 },
{ "non-local-source-routing", "f", &dhcp_universe, 20, 1 },
{ "policy-filter", "IIA", &dhcp_universe, 21, 1 },
{ "max-dgram-reassembly", "S", &dhcp_universe, 22, 1 },
{ "default-ip-ttl", "B", &dhcp_universe, 23, 1 },
{ "path-mtu-aging-timeout", "L", &dhcp_universe, 24, 1 },
{ "path-mtu-plateau-table", "SA", &dhcp_universe, 25, 1 },
{ "interface-mtu", "S", &dhcp_universe, 26, 1 },
{ "all-subnets-local", "f", &dhcp_universe, 27, 1 },
{ "broadcast-address", "I", &dhcp_universe, 28, 1 },
{ "perform-mask-discovery", "f", &dhcp_universe, 29, 1 },
{ "mask-supplier", "f", &dhcp_universe, 30, 1 },
{ "router-discovery", "f", &dhcp_universe, 31, 1 },
{ "router-solicitation-address", "I", &dhcp_universe, 32, 1 },
{ "static-routes", "IIA", &dhcp_universe, 33, 1 },
{ "trailer-encapsulation", "f", &dhcp_universe, 34, 1 },
{ "arp-cache-timeout", "L", &dhcp_universe, 35, 1 },
{ "ieee802-3-encapsulation", "f", &dhcp_universe, 36, 1 },
{ "default-tcp-ttl", "B", &dhcp_universe, 37, 1 },
{ "tcp-keepalive-interval", "L", &dhcp_universe, 38, 1 },
{ "tcp-keepalive-garbage", "f", &dhcp_universe, 39, 1 },
{ "nis-domain", "t", &dhcp_universe, 40, 1 },
{ "nis-servers", "IA", &dhcp_universe, 41, 1 },
{ "ntp-servers", "IA", &dhcp_universe, 42, 1 },
{ "vendor-encapsulated-options", "E.", &dhcp_universe, 43, 1 },
{ "netbios-name-servers", "IA", &dhcp_universe, 44, 1 },
{ "netbios-dd-server", "IA", &dhcp_universe, 45, 1 },
{ "netbios-node-type", "B", &dhcp_universe, 46, 1 },
{ "netbios-scope", "t", &dhcp_universe, 47, 1 },
{ "font-servers", "IA", &dhcp_universe, 48, 1 },
{ "x-display-manager", "IA", &dhcp_universe, 49, 1 },
{ "dhcp-requested-address", "I", &dhcp_universe, 50, 1 },
{ "dhcp-lease-time", "L", &dhcp_universe, 51, 1 },
{ "dhcp-option-overload", "B", &dhcp_universe, 52, 1 },
{ "dhcp-message-type", "B", &dhcp_universe, 53, 1 },
{ "dhcp-server-identifier", "I", &dhcp_universe, 54, 1 },
{ "dhcp-parameter-request-list", "BA", &dhcp_universe, 55, 1 },
{ "dhcp-message", "t", &dhcp_universe, 56, 1 },
{ "dhcp-max-message-size", "S", &dhcp_universe, 57, 1 },
{ "dhcp-renewal-time", "L", &dhcp_universe, 58, 1 },
{ "dhcp-rebinding-time", "L", &dhcp_universe, 59, 1 },
{ "vendor-class-identifier", "X", &dhcp_universe, 60, 1 },
{ "dhcp-client-identifier", "X", &dhcp_universe, 61, 1 },
{ "nwip-domain", "t", &dhcp_universe, 62, 1 },
{ "nwip-suboptions", "Enwip.", &dhcp_universe, 63, 1 },
{ "nisplus-domain", "t", &dhcp_universe, 64, 1 },
{ "nisplus-servers", "IA", &dhcp_universe, 65, 1 },
{ "tftp-server-name", "t", &dhcp_universe, 66, 1 },
{ "bootfile-name", "t", &dhcp_universe, 67, 1 },
{ "mobile-ip-home-agent", "IA", &dhcp_universe, 68, 1 },
{ "smtp-server", "IA", &dhcp_universe, 69, 1 },
{ "pop-server", "IA", &dhcp_universe, 70, 1 },
{ "nntp-server", "IA", &dhcp_universe, 71, 1 },
{ "www-server", "IA", &dhcp_universe, 72, 1 },
{ "finger-server", "IA", &dhcp_universe, 73, 1 },
{ "irc-server", "IA", &dhcp_universe, 74, 1 },
{ "streettalk-server", "IA", &dhcp_universe, 75, 1 },
{ "streettalk-directory-assistance-server", "IA",
&dhcp_universe, 76, 1 },
{ "user-class", "t", &dhcp_universe, 77, 1 },
{ "slp-directory-agent", "fIa", &dhcp_universe, 78, 1 },
{ "slp-service-scope", "fto", &dhcp_universe, 79, 1 },
{ "fqdn", "Efqdn.", &dhcp_universe, 81, 1 },
{ "relay-agent-information", "Eagent.", &dhcp_universe, 82, 1 },
{ "nds-servers", "IA", &dhcp_universe, 85, 1 },
{ "nds-tree-name", "t", &dhcp_universe, 86, 1 },
{ "nds-context", "t", &dhcp_universe, 87, 1 },
{ "uap-servers", "t", &dhcp_universe, 98, 1 },
{ "subnet-selection", "I", &dhcp_universe, 118, 1 },
{ "domain-search", "D", &dhcp_universe, 119, 1 },
{ "vivco", "Evendor-class.", &dhcp_universe, 124, 1 },
{ "vivso", "Evendor.", &dhcp_universe, 125, 1 },
{ NULL, NULL, NULL, 0, 0 }
};
struct universe nwip_universe;
static struct option nwip_options[] = {
{ "illegal-1", "", &nwip_universe, 1, 1 },
{ "illegal-2", "", &nwip_universe, 2, 1 },
{ "illegal-3", "", &nwip_universe, 3, 1 },
{ "illegal-4", "", &nwip_universe, 4, 1 },
{ "nsq-broadcast", "f", &nwip_universe, 5, 1 },
{ "preferred-dss", "IA", &nwip_universe, 6, 1 },
{ "nearest-nwip-server", "IA", &nwip_universe, 7, 1 },
{ "autoretries", "B", &nwip_universe, 8, 1 },
{ "autoretry-secs", "B", &nwip_universe, 9, 1 },
{ "nwip-1-1", "f", &nwip_universe, 10, 1 },
{ "primary-dss", "I", &nwip_universe, 11, 1 },
{ NULL, NULL, NULL, 0, 0 }
};
/* Note that the "FQDN suboption space" does not reflect the FQDN option
* format - rather, this is a handy "virtualization" of a flat option
* which makes manual configuration and presentation of some of its
* contents easier (each of these suboptions is a fixed-space field within
* the fqdn contents - domain and host names are derived from a common field,
* and differ in the left and right hand side of the leftmost dot, fqdn is
* the combination of the two).
*/
struct universe fqdn_universe;
static struct option fqdn_options[] = {
{ "no-client-update", "f", &fqdn_universe, 1, 1 },
{ "server-update", "f", &fqdn_universe, 2, 1 },
{ "encoded", "f", &fqdn_universe, 3, 1 },
{ "rcode1", "B", &fqdn_universe, 4, 1 },
{ "rcode2", "B", &fqdn_universe, 5, 1 },
{ "hostname", "t", &fqdn_universe, 6, 1 },
{ "domainname", "t", &fqdn_universe, 7, 1 },
{ "fqdn", "t", &fqdn_universe, 8, 1 },
{ NULL, NULL, NULL, 0, 0 }
};
struct universe vendor_class_universe;
static struct option vendor_class_options[] = {
{ "isc", "X", &vendor_class_universe, 2495, 1 },
{ NULL, NULL, NULL, 0, 0 }
};
struct universe vendor_universe;
static struct option vendor_options[] = {
{ "isc", "Eisc.", &vendor_universe, 2495, 1 },
{ NULL, NULL, NULL, 0, 0 }
};
struct universe isc_universe;
static struct option isc_options [] = {
{ "media", "t", &isc_universe, 1, 1 },
{ "update-assist", "X", &isc_universe, 2, 1 },
{ NULL, NULL, NULL, 0, 0 }
};
const char *hardware_types [] = {
"unknown-0",
"ethernet",
"unknown-2",
"unknown-3",
"unknown-4",
"unknown-5",
"token-ring",
"unknown-7",
"fddi",
"unknown-9",
"unknown-10",
"unknown-11",
"unknown-12",
"unknown-13",
"unknown-14",
"unknown-15",
"unknown-16",
"unknown-17",
"unknown-18",
"unknown-19",
"unknown-20",
"unknown-21",
"unknown-22",
"unknown-23",
"unknown-24",
"unknown-25",
"unknown-26",
"unknown-27",
"unknown-28",
"unknown-29",
"unknown-30",
"unknown-31",
"unknown-32",
"unknown-33",
"unknown-34",
"unknown-35",
"unknown-36",
"unknown-37",
"unknown-38",
"unknown-39",
"unknown-40",
"unknown-41",
"unknown-42",
"unknown-43",
"unknown-44",
"unknown-45",
"unknown-46",
"unknown-47",
"unknown-48",
"unknown-49",
"unknown-50",
"unknown-51",
"unknown-52",
"unknown-53",
"unknown-54",
"unknown-55",
"unknown-56",
"unknown-57",
"unknown-58",
"unknown-59",
"unknown-60",
"unknown-61",
"unknown-62",
"unknown-63",
"unknown-64",
"unknown-65",
"unknown-66",
"unknown-67",
"unknown-68",
"unknown-69",
"unknown-70",
"unknown-71",
"unknown-72",
"unknown-73",
"unknown-74",
"unknown-75",
"unknown-76",
"unknown-77",
"unknown-78",
"unknown-79",
"unknown-80",
"unknown-81",
"unknown-82",
"unknown-83",
"unknown-84",
"unknown-85",
"unknown-86",
"unknown-87",
"unknown-88",
"unknown-89",
"unknown-90",
"unknown-91",
"unknown-92",
"unknown-93",
"unknown-94",
"unknown-95",
"unknown-96",
"unknown-97",
"unknown-98",
"unknown-99",
"unknown-100",
"unknown-101",
"unknown-102",
"unknown-103",
"unknown-104",
"unknown-105",
"unknown-106",
"unknown-107",
"unknown-108",
"unknown-109",
"unknown-110",
"unknown-111",
"unknown-112",
"unknown-113",
"unknown-114",
"unknown-115",
"unknown-116",
"unknown-117",
"unknown-118",
"unknown-119",
"unknown-120",
"unknown-121",
"unknown-122",
"unknown-123",
"unknown-124",
"unknown-125",
"unknown-126",
"unknown-127",
"unknown-128",
"unknown-129",
"unknown-130",
"unknown-131",
"unknown-132",
"unknown-133",
"unknown-134",
"unknown-135",
"unknown-136",
"unknown-137",
"unknown-138",
"unknown-139",
"unknown-140",
"unknown-141",
"unknown-142",
"unknown-143",
"unknown-144",
"unknown-145",
"unknown-146",
"unknown-147",
"unknown-148",
"unknown-149",
"unknown-150",
"unknown-151",
"unknown-152",
"unknown-153",
"unknown-154",
"unknown-155",
"unknown-156",
"unknown-157",
"unknown-158",
"unknown-159",
"unknown-160",
"unknown-161",
"unknown-162",
"unknown-163",
"unknown-164",
"unknown-165",
"unknown-166",
"unknown-167",
"unknown-168",
"unknown-169",
"unknown-170",
"unknown-171",
"unknown-172",
"unknown-173",
"unknown-174",
"unknown-175",
"unknown-176",
"unknown-177",
"unknown-178",
"unknown-179",
"unknown-180",
"unknown-181",
"unknown-182",
"unknown-183",
"unknown-184",
"unknown-185",
"unknown-186",
"unknown-187",
"unknown-188",
"unknown-189",
"unknown-190",
"unknown-191",
"unknown-192",
"unknown-193",
"unknown-194",
"unknown-195",
"unknown-196",
"unknown-197",
"unknown-198",
"unknown-199",
"unknown-200",
"unknown-201",
"unknown-202",
"unknown-203",
"unknown-204",
"unknown-205",
"unknown-206",
"unknown-207",
"unknown-208",
"unknown-209",
"unknown-210",
"unknown-211",
"unknown-212",
"unknown-213",
"unknown-214",
"unknown-215",
"unknown-216",
"unknown-217",
"unknown-218",
"unknown-219",
"unknown-220",
"unknown-221",
"unknown-222",
"unknown-223",
"unknown-224",
"unknown-225",
"unknown-226",
"unknown-227",
"unknown-228",
"unknown-229",
"unknown-230",
"unknown-231",
"unknown-232",
"unknown-233",
"unknown-234",
"unknown-235",
"unknown-236",
"unknown-237",
"unknown-238",
"unknown-239",
"unknown-240",
"unknown-241",
"unknown-242",
"unknown-243",
"unknown-244",
"unknown-245",
"unknown-246",
"unknown-247",
"unknown-248",
"unknown-249",
"unknown-250",
"unknown-251",
"unknown-252",
"unknown-253",
"unknown-254",
"unknown-255" };
universe_hash_t *universe_hash;
struct universe **universes;
int universe_count, universe_max;
/* Universe containing names of configuration options, which, rather than
writing "option universe-name.option-name ...;", can be set by writing
"option-name ...;". */
struct universe *config_universe;
/* XXX: omapi must die...all the below keeps us from having to make the
* option structures omapi typed objects, which is a bigger headache.
*/
char *default_option_format = "X";
/* Must match hash_reference/dereference types in omapip/hash.h. */
int
option_reference(struct option **dest, struct option *src,
const char * file, int line)
{
if (!dest || !src)
return ISC_R_INVALIDARG;
if (*dest) {
#if defined(POINTER_DEBUG)
log_fatal("%s(%d): reference store into non-null pointer!",
file, line);
#else
return ISC_R_INVALIDARG;
#endif
}
*dest = src;
src->refcnt++;
rc_register(file, line, dest, src, src->refcnt, 0, RC_MISC);
return(ISC_R_SUCCESS);
}
int
option_dereference(struct option **dest, const char *file, int line)
{
if (!dest)
return ISC_R_INVALIDARG;
if (!*dest) {
#if defined (POINTER_DEBUG)
log_fatal("%s(%d): dereference of null pointer!", file, line);
#else
return ISC_R_INVALIDARG;
#endif
}
if ((*dest)->refcnt <= 0) {
#if defined (POINTER_DEBUG)
log_fatal("%s(%d): dereference of <= 0 refcnt!", file, line);
#else
return ISC_R_INVALIDARG;
#endif
}
(*dest)->refcnt--;
rc_register(file, line, dest, (*dest), (*dest)->refcnt, 1, RC_MISC);
if ((*dest)->refcnt == 0) {
/* The option name may be packed in the same alloc as the
* option structure.
*/
if ((*dest)->name != (char *)((*dest) + 1))
dfree((*dest)->name, file, line);
/* It's either a user-configured format (allocated), or the
* default static format.
*/
if ((*dest)->format != default_option_format)
dfree((*dest)->format, file, line);
dfree(*dest, file, line);
}
*dest = NULL;
return ISC_R_SUCCESS;
}
void initialize_common_option_spaces()
{
unsigned code;
int i;
universe_max = 10;
universes = ((struct universe **)
dmalloc (universe_max * sizeof (struct universe *), MDL));
if (!universes)
log_fatal ("Can't allocate option space table.");
memset (universes, 0, universe_max * sizeof (struct universe *));
/* Set up the DHCP option universe... */
dhcp_universe.name = "dhcp";
dhcp_universe.lookup_func = lookup_hashed_option;
dhcp_universe.option_state_dereference =
hashed_option_state_dereference;
dhcp_universe.save_func = save_hashed_option;
dhcp_universe.delete_func = delete_hashed_option;
dhcp_universe.encapsulate = hashed_option_space_encapsulate;
dhcp_universe.foreach = hashed_option_space_foreach;
dhcp_universe.decode = parse_option_buffer;
dhcp_universe.length_size = 1;
dhcp_universe.tag_size = 1;
dhcp_universe.get_tag = getUChar;
dhcp_universe.store_tag = putUChar;
dhcp_universe.get_length = getUChar;
dhcp_universe.store_length = putUChar;
dhcp_universe.end = DHO_END;
dhcp_universe.index = universe_count++;
universes [dhcp_universe.index] = &dhcp_universe;
if (!option_name_new_hash(&dhcp_universe.name_hash,
BYTE_NAME_HASH_SIZE, MDL) ||
!option_code_new_hash(&dhcp_universe.code_hash,
BYTE_CODE_HASH_SIZE, MDL))
log_fatal ("Can't allocate dhcp option hash table.");
for (i = 0 ; dhcp_options[i].name ; i++) {
option_code_hash_add(dhcp_universe.code_hash,
&dhcp_options[i].code, 0,
&dhcp_options[i], MDL);
option_name_hash_add(dhcp_universe.name_hash,
dhcp_options [i].name, 0,
&dhcp_options [i], MDL);
}
/* Set up the Novell option universe (for option 63)... */
nwip_universe.name = "nwip";
nwip_universe.lookup_func = lookup_linked_option;
nwip_universe.option_state_dereference =
linked_option_state_dereference;
nwip_universe.save_func = save_linked_option;
nwip_universe.delete_func = delete_linked_option;
nwip_universe.encapsulate = nwip_option_space_encapsulate;
nwip_universe.foreach = linked_option_space_foreach;
nwip_universe.decode = parse_option_buffer;
nwip_universe.length_size = 1;
nwip_universe.tag_size = 1;
nwip_universe.get_tag = getUChar;
nwip_universe.store_tag = putUChar;
nwip_universe.get_length = getUChar;
nwip_universe.store_length = putUChar;
nwip_universe.end = 0;
code = DHO_NWIP_SUBOPTIONS;
nwip_universe.enc_opt = NULL;
if (!option_code_hash_lookup(&nwip_universe.enc_opt,
dhcp_universe.code_hash, &code, 0, MDL))
log_fatal("Unable to find NWIP parent option (%s:%d).", MDL);
nwip_universe.index = universe_count++;
universes [nwip_universe.index] = &nwip_universe;
if (!option_name_new_hash(&nwip_universe.name_hash,
NWIP_HASH_SIZE, MDL) ||
!option_code_new_hash(&nwip_universe.code_hash,
NWIP_HASH_SIZE, MDL))
log_fatal ("Can't allocate nwip option hash table.");
for (i = 0 ; nwip_options[i].name ; i++) {
option_code_hash_add(nwip_universe.code_hash,
&nwip_options[i].code, 0,
&nwip_options[i], MDL);
option_name_hash_add(nwip_universe.name_hash,
nwip_options[i].name, 0,
&nwip_options[i], MDL);
}
/* Set up the FQDN option universe... */
fqdn_universe.name = "fqdn";
fqdn_universe.lookup_func = lookup_linked_option;
fqdn_universe.option_state_dereference =
linked_option_state_dereference;
fqdn_universe.save_func = save_linked_option;
fqdn_universe.delete_func = delete_linked_option;
fqdn_universe.encapsulate = fqdn_option_space_encapsulate;
fqdn_universe.foreach = linked_option_space_foreach;
fqdn_universe.decode = fqdn_universe_decode;
fqdn_universe.length_size = 1;
fqdn_universe.tag_size = 1;
fqdn_universe.get_tag = getUChar;
fqdn_universe.store_tag = putUChar;
fqdn_universe.get_length = getUChar;
fqdn_universe.store_length = putUChar;
fqdn_universe.end = 0;
fqdn_universe.index = universe_count++;
code = DHO_FQDN;
fqdn_universe.enc_opt = NULL;
if (!option_code_hash_lookup(&fqdn_universe.enc_opt,
dhcp_universe.code_hash, &code, 0, MDL))
log_fatal("Unable to find FQDN parent option (%s:%d).", MDL);
universes [fqdn_universe.index] = &fqdn_universe;
if (!option_name_new_hash(&fqdn_universe.name_hash,
FQDN_HASH_SIZE, MDL) ||
!option_code_new_hash(&fqdn_universe.code_hash,
FQDN_HASH_SIZE, MDL))
log_fatal ("Can't allocate fqdn option hash table.");
for (i = 0 ; fqdn_options[i].name ; i++) {
option_code_hash_add(nwip_universe.code_hash,
&fqdn_options[i].code, 0,
&fqdn_options[i], MDL);
option_name_hash_add(fqdn_universe.name_hash,
fqdn_options[i].name, 0,
&fqdn_options[i], MDL);
}
/* Set up the Vendor Identified Vendor Class options (for option
* 125)...
*/
vendor_class_universe.name = "vendor-class";
vendor_class_universe.lookup_func = lookup_hashed_option;
vendor_class_universe.option_state_dereference =
hashed_option_state_dereference;
vendor_class_universe.save_func = save_hashed_option;
vendor_class_universe.delete_func = delete_hashed_option;
vendor_class_universe.encapsulate = hashed_option_space_encapsulate;
vendor_class_universe.foreach = hashed_option_space_foreach;
vendor_class_universe.decode = parse_option_buffer;
vendor_class_universe.length_size = 1;
vendor_class_universe.tag_size = 4;
vendor_class_universe.get_tag = getULong;
vendor_class_universe.store_tag = putULong;
vendor_class_universe.get_length = getUChar;
vendor_class_universe.store_length = putUChar;
vendor_class_universe.end = 0;
code = DHO_VIVCO_SUBOPTIONS;
vendor_class_universe.enc_opt = NULL;
if (!option_code_hash_lookup(&vendor_class_universe.enc_opt,
dhcp_universe.code_hash, &code, 0, MDL))
log_fatal("Unable to find VIVCO parent option (%s:%d).", MDL);
vendor_class_universe.index = universe_count++;
universes[vendor_class_universe.index] = &vendor_class_universe;
if (!option_name_new_hash(&vendor_class_universe.name_hash,
VIVCO_HASH_SIZE, MDL) ||
!option_code_new_hash(&vendor_class_universe.code_hash,
VIVCO_HASH_SIZE, MDL))
log_fatal("Can't allocate Vendor Identified Vendor Class "
"option hash table.");
for (i = 0 ; vendor_class_options[i].name ; i++) {
option_code_hash_add(vendor_class_universe.code_hash,
&vendor_class_options[i].code, 0,
&vendor_class_options[i], MDL);
option_name_hash_add(vendor_class_universe.name_hash,
vendor_class_options[i].name, 0,
&vendor_class_options[i], MDL);
}
/* Set up the Vendor Identified Vendor Sub-options (option 126)... */
vendor_universe.name = "vendor";
vendor_universe.lookup_func = lookup_hashed_option;
vendor_universe.option_state_dereference =
hashed_option_state_dereference;
vendor_universe.save_func = save_hashed_option;
vendor_universe.delete_func = delete_hashed_option;
vendor_universe.encapsulate = hashed_option_space_encapsulate;
vendor_universe.foreach = hashed_option_space_foreach;
vendor_universe.decode = parse_option_buffer;
vendor_universe.length_size = 1;
vendor_universe.tag_size = 4;
vendor_universe.get_tag = getULong;
vendor_universe.store_tag = putULong;
vendor_universe.get_length = getUChar;
vendor_universe.store_length = putUChar;
vendor_universe.end = 0;
code = DHO_VIVSO_SUBOPTIONS;
vendor_universe.enc_opt = NULL;
if (!option_code_hash_lookup(&vendor_universe.enc_opt,
dhcp_universe.code_hash, &code, 0, MDL))
log_fatal("Unable to find VIVSO parent option (%s:%d).", MDL);
vendor_universe.index = universe_count++;
universes[vendor_universe.index] = &vendor_universe;
if (!option_name_new_hash(&vendor_universe.name_hash,
VIVSO_HASH_SIZE, MDL) ||
!option_code_new_hash(&vendor_universe.code_hash,
VIVSO_HASH_SIZE, MDL))
log_fatal("Can't allocate Vendor Identified Vendor Sub-"
"options hash table.");
for (i = 0 ; vendor_options[i].name ; i++) {
option_code_hash_add(vendor_universe.code_hash,
&vendor_options[i].code, 0,
&vendor_options[i], MDL);
option_name_hash_add(vendor_universe.name_hash,
vendor_options[i].name, 0,
&vendor_options[i], MDL);
}
/* Set up the ISC Vendor-option universe (for option 125.2495)... */
isc_universe.name = "isc";
isc_universe.lookup_func = lookup_linked_option;
isc_universe.option_state_dereference =
linked_option_state_dereference;
isc_universe.save_func = save_linked_option;
isc_universe.delete_func = delete_linked_option;
isc_universe.encapsulate = linked_option_space_encapsulate;
isc_universe.foreach = linked_option_space_foreach;
isc_universe.decode = parse_option_buffer;
isc_universe.length_size = 2;
isc_universe.tag_size = 2;
isc_universe.get_tag = getUShort;
isc_universe.store_tag = putUShort;
isc_universe.get_length = getUShort;
isc_universe.store_length = putUShort;
isc_universe.end = 0;
code = VENDOR_ISC_SUBOPTIONS;
isc_universe.enc_opt = NULL;
if (!option_code_hash_lookup(&isc_universe.enc_opt,
vendor_universe.code_hash, &code, 0, MDL))
log_fatal("Unable to find ISC parent option (%s:%d).", MDL);
isc_universe.index = universe_count++;
universes[isc_universe.index] = &isc_universe;
if (!option_name_new_hash(&isc_universe.name_hash,
VIV_ISC_HASH_SIZE, MDL) ||
!option_code_new_hash(&isc_universe.code_hash,
VIV_ISC_HASH_SIZE, MDL))
log_fatal("Can't allocate ISC Vendor options hash table.");
for (i = 0 ; vendor_options[i].name ; i++) {
option_code_hash_add(vendor_universe.code_hash,
&vendor_options[i].code, 0,
&vendor_options[i], MDL);
option_name_hash_add(vendor_universe.name_hash,
vendor_options[i].name, 0,
&vendor_options[i], MDL);
}
/* Set up the hash of universes. */
universe_new_hash(&universe_hash, UNIVERSE_HASH_SIZE, MDL);
universe_hash_add(universe_hash, dhcp_universe.name, 0,
&dhcp_universe, MDL);
universe_hash_add(universe_hash, nwip_universe.name, 0,
&nwip_universe, MDL);
universe_hash_add(universe_hash, fqdn_universe.name, 0,
&fqdn_universe, MDL);
universe_hash_add(universe_hash, vendor_class_universe.name, 0,
&vendor_class_universe, MDL);
universe_hash_add(universe_hash, vendor_universe.name, 0,
&vendor_universe, MDL);
universe_hash_add(universe_hash, isc_universe.name, 0,
&isc_universe, MDL);
}
|