]>
Commit | Line | Data |
---|---|---|
d7837182 TL |
1 | /* tree.h |
2 | ||
3 | Definitions for address trees... */ | |
4 | ||
5 | /* | |
f39b6e00 TL |
6 | * Copyright (c) 1996-1999 Internet Software Consortium. |
7 | * Use is subject to license terms which appear in the file named | |
8 | * ISC-LICENSE that should have accompanied this file when you | |
9 | * received it. If a file named ISC-LICENSE did not accompany this | |
10 | * file, or you are not sure the one you have is correct, you may | |
11 | * obtain an applicable copy of the license at: | |
d7837182 | 12 | * |
f39b6e00 | 13 | * http://www.isc.org/isc-license-1.0.html. |
d7837182 | 14 | * |
f39b6e00 TL |
15 | * This file is part of the ISC DHCP distribution. The documentation |
16 | * associated with this file is listed in the file DOCUMENTATION, | |
17 | * included in the top-level directory of this release. | |
d7837182 | 18 | * |
f39b6e00 TL |
19 | * Support and other services are available for ISC products - see |
20 | * http://www.isc.org for more information. | |
d7837182 TL |
21 | */ |
22 | ||
23 | /* A pair of pointers, suitable for making a linked list. */ | |
24 | typedef struct _pair { | |
25 | caddr_t car; | |
26 | struct _pair *cdr; | |
27 | } *pair; | |
28 | ||
29 | /* Tree node types... */ | |
30 | #define TREE_CONCAT 1 | |
31 | #define TREE_HOST_LOOKUP 2 | |
32 | #define TREE_CONST 3 | |
33 | #define TREE_LIMIT 4 | |
50d92f58 | 34 | #define TREE_DATA_EXPR 5 |
d7837182 | 35 | |
a461fb50 TL |
36 | /* A data buffer with a reference count. */ |
37 | struct buffer { | |
38 | int refcnt; | |
c5b0f529 | 39 | unsigned char data [1]; |
a461fb50 TL |
40 | }; |
41 | ||
42 | /* XXX The mechanism by which data strings are returned is currently | |
43 | XXX broken: rather than returning an ephemeral pointer, we create | |
44 | XXX a reference to the data in the caller's space, which the caller | |
45 | XXX then has to dereference - instead, the reference should be | |
46 | XXX ephemeral by default and be made a persistent reference explicitly. */ | |
47 | ||
50d92f58 TL |
48 | /* A string of data bytes, possibly accompanied by a larger buffer. */ |
49 | struct data_string { | |
a461fb50 TL |
50 | struct buffer *buffer; |
51 | unsigned char *data; | |
50d92f58 TL |
52 | int len; |
53 | int terminated; | |
54 | }; | |
55 | ||
56 | /* Expression tree structure. */ | |
57 | ||
a461fb50 TL |
58 | enum expr_op { |
59 | expr_none, | |
60 | expr_match, | |
61 | expr_check, | |
62 | expr_equal, | |
63 | expr_substring, | |
64 | expr_suffix, | |
65 | expr_concat, | |
66 | expr_host_lookup, | |
67 | expr_and, | |
68 | expr_or, | |
69 | expr_not, | |
70 | expr_option, | |
71 | expr_hardware, | |
72 | expr_packet, | |
73 | expr_const_data, | |
74 | expr_extract_int8, | |
75 | expr_extract_int16, | |
76 | expr_extract_int32, | |
77 | expr_const_int, | |
78 | expr_exists, | |
79 | }; | |
80 | ||
50d92f58 | 81 | struct expression { |
a461fb50 TL |
82 | int refcnt; |
83 | enum expr_op op; | |
d7837182 | 84 | union { |
50d92f58 TL |
85 | struct { |
86 | struct expression *expr; | |
87 | struct expression *offset; | |
88 | struct expression *len; | |
89 | } substring; | |
90 | struct expression *equal [2]; | |
91 | struct expression *and [2]; | |
92 | struct expression *or [2]; | |
93 | struct expression *not; | |
94 | struct collection *check; | |
95 | struct { | |
96 | struct expression *expr; | |
97 | struct expression *len; | |
98 | } suffix; | |
99 | struct option *option; | |
100 | struct { | |
101 | struct expression *offset; | |
102 | struct expression *len; | |
103 | } packet; | |
104 | struct data_string const_data; | |
a461fb50 | 105 | struct expression *extract_int; |
50d92f58 TL |
106 | unsigned long const_int; |
107 | struct expression *concat [2]; | |
108 | struct dns_host_entry *host_lookup; | |
a461fb50 | 109 | struct option *exists; |
d7837182 | 110 | } data; |
50d92f58 TL |
111 | int flags; |
112 | # define EXPR_EPHEMERAL 1 | |
113 | }; | |
d7837182 TL |
114 | |
115 | /* DNS host entry structure... */ | |
116 | struct dns_host_entry { | |
a461fb50 | 117 | int refcnt; |
d7837182 | 118 | TIME timeout; |
a461fb50 TL |
119 | struct data_string data; |
120 | char hostname [1]; | |
d7837182 TL |
121 | }; |
122 | ||
a461fb50 | 123 | struct option_cache; /* forward */ |
8b204155 TL |
124 | struct data_string; /* forward */ |
125 | struct packet; /* forward */ | |
50d92f58 | 126 | struct option_state; /* forward */ |
a461fb50 | 127 | struct decoded_option_state; /* forward */ |
8b204155 | 128 | |
d7837182 TL |
129 | struct universe { |
130 | char *name; | |
a461fb50 TL |
131 | int (*lookup_func) |
132 | PROTO ((struct data_string *, | |
133 | struct option_state *, int)); | |
50d92f58 TL |
134 | void (*set_func) PROTO ((struct option_state *, |
135 | struct option_cache *, | |
136 | enum statement_op)); | |
d7837182 TL |
137 | struct hash_table *hash; |
138 | struct option *options [256]; | |
139 | }; | |
140 | ||
141 | struct option { | |
142 | char *name; | |
143 | char *format; | |
144 | struct universe *universe; | |
145 | unsigned char code; | |
146 | }; | |
a461fb50 TL |
147 | |
148 | enum expression_context { | |
149 | context_any, | |
150 | context_boolean, | |
151 | context_data, | |
152 | context_numeric | |
153 | }; |