1 /* $NetBSD: tree.h,v 1.1.1.3 2014/07/12 11:57:56 spz Exp $ */
4 Definitions for address trees... */
7 * Copyright (c) 2011,2013,2014 by Internet Systems Consortium, Inc. ("ISC")
8 * Copyright (c) 2004,2007-2009 by Internet Systems Consortium, Inc. ("ISC")
9 * Copyright (c) 1996-2003 by Internet Software Consortium
11 * Permission to use, copy, modify, and distribute this software for any
12 * purpose with or without fee is hereby granted, provided that the above
13 * copyright notice and this permission notice appear in all copies.
15 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
16 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
18 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Internet Systems Consortium, Inc.
25 * Redwood City, CA 94063
27 * https://www.isc.org/
31 /* A pair of pointers, suitable for making a linked list. */
32 typedef struct _pair
{
37 struct option_chain_head
{
42 struct enumeration_value
{
48 struct enumeration
*next
;
51 struct enumeration_value
*values
;
54 /* Tree node types... */
56 #define TREE_HOST_LOOKUP 2
59 #define TREE_DATA_EXPR 5
61 /* A data buffer with a reference count. */
64 unsigned char data
[1];
67 /* XXX The mechanism by which data strings are returned is currently
68 XXX broken: rather than returning an ephemeral pointer, we create
69 XXX a reference to the data in the caller's space, which the caller
70 XXX then has to dereference - instead, the reference should be
71 XXX ephemeral by default and be made a persistent reference explicitly. */
72 /* XXX on the other hand, it seems to work pretty nicely, so maybe the
73 XXX above comment is meshuggenah. */
74 /* XXX I think the above comment tries to say this:
75 XXX http://tinyurl.com/2tjqre */
77 /* A string of data bytes, possibly accompanied by a larger buffer. */
79 struct buffer
*buffer
;
80 const unsigned char *data
;
81 unsigned len
; /* Does not include NUL terminator, if any. */
85 enum expression_context
{
86 context_any
, /* indefinite */
91 context_data_or_numeric
, /* indefinite */
97 struct string_list
*args
;
98 struct executable_statement
*statements
;
101 struct binding_value
{
111 struct data_string data
;
112 unsigned long intval
;
114 struct fundef
*fundef
;
115 struct binding_value
*bv
;
120 struct binding
*next
;
122 struct binding_value
*value
;
125 struct binding_scope
{
127 struct binding_scope
*outer
;
128 struct binding
*bindings
;
131 /* Expression tree structure. */
161 expr_binary_to_ascii
,
164 expr_pick_first_value
,
166 expr_dns_transaction
,
174 expr_variable_exists
,
175 expr_variable_reference
,
203 struct expression
*expr
;
204 struct expression
*offset
;
205 struct expression
*len
;
207 struct expression
*equal
[2];
208 struct expression
*and [2];
209 struct expression
*or [2];
210 struct expression
*not;
211 struct expression
*add
;
212 struct expression
*subtract
;
213 struct expression
*multiply
;
214 struct expression
*divide
;
215 struct expression
*remainder
;
216 struct collection
*check
;
218 struct expression
*expr
;
219 struct expression
*len
;
221 struct expression
*lcase
;
222 struct expression
*ucase
;
223 struct option
*option
;
224 struct option
*config_option
;
226 struct expression
*offset
;
227 struct expression
*len
;
229 struct data_string const_data
;
230 struct expression
*extract_int
;
231 struct expression
*encode_int
;
232 unsigned long const_int
;
233 struct expression
*concat
[2];
234 struct dns_host_entry
*host_lookup
;
235 struct option
*exists
;
236 struct data_string encapsulate
;
238 struct expression
*base
;
239 struct expression
*width
;
240 struct expression
*separator
;
241 struct expression
*buffer
;
244 struct expression
*width
;
245 struct expression
*buffer
;
248 struct expression
*car
;
249 struct expression
*cdr
;
252 struct expression
*car
;
253 struct expression
*cdr
;
258 struct expression
*rrname
;
259 struct expression
*rrdata
;
260 struct expression
*ttl
;
265 struct expression
*rrname
;
266 struct expression
*rrdata
;
267 } ns_delete
, ns_exists
, ns_not_exists
;
270 struct expression
*val
;
271 struct expression
*next
;
275 struct expression
*arglist
;
279 struct expression
*relay
;
280 struct expression
*roption
;
284 # define EXPR_EPHEMERAL 1
287 /* DNS host entry structure... */
288 struct dns_host_entry
{
291 struct data_string data
;
295 struct option_cache
; /* forward */
296 struct packet
; /* forward */
297 struct option_state
; /* forward */
298 struct decoded_option_state
; /* forward */
299 struct lease
; /* forward */
300 struct client_state
; /* forward */
304 struct option_cache
*(*lookup_func
) (struct universe
*,
305 struct option_state
*,
307 void (*save_func
) (struct universe
*, struct option_state
*,
308 struct option_cache
*, isc_boolean_t
);
309 void (*foreach
) (struct packet
*,
310 struct lease
*, struct client_state
*,
311 struct option_state
*, struct option_state
*,
312 struct binding_scope
**, struct universe
*, void *,
313 void (*) (struct option_cache
*, struct packet
*,
314 struct lease
*, struct client_state
*,
315 struct option_state
*,
316 struct option_state
*,
317 struct binding_scope
**,
318 struct universe
*, void *));
319 void (*delete_func
) (struct universe
*universe
,
320 struct option_state
*, int);
321 int (*option_state_dereference
) (struct universe
*,
322 struct option_state
*,
324 int (*decode
) (struct option_state
*,
325 const unsigned char *, unsigned, struct universe
*);
326 int (*encapsulate
) (struct data_string
*, struct packet
*,
327 struct lease
*, struct client_state
*,
328 struct option_state
*, struct option_state
*,
329 struct binding_scope
**,
331 u_int32_t (*get_tag
) (const unsigned char *);
332 void (*store_tag
) (unsigned char *, u_int32_t
);
333 u_int32_t (*get_length
) (const unsigned char *);
334 void (*store_length
) (unsigned char *, u_int32_t
);
335 int tag_size
, length_size
;
336 unsigned site_code_min
, end
;
337 option_name_hash_t
*name_hash
;
338 option_code_hash_t
*code_hash
;
339 struct option
*enc_opt
;
342 /* Flags should probably become condensed. */
343 int concat_duplicates
;
349 struct universe
*universe
;