ISC DHCP  4.3.1
A reference DHCPv4 and DHCPv6 implementation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tree.h
Go to the documentation of this file.
1 /* tree.h
2 
3  Definitions for address trees... */
4 
5 /*
6  * Copyright (c) 2011,2013,2014 by Internet Systems Consortium, Inc. ("ISC")
7  * Copyright (c) 2004,2007-2009 by Internet Systems Consortium, Inc. ("ISC")
8  * Copyright (c) 1996-2003 by Internet Software Consortium
9  *
10  * Permission to use, copy, modify, and distribute this software for any
11  * purpose with or without fee is hereby granted, provided that the above
12  * copyright notice and this permission notice appear in all copies.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
15  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
17  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
20  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  *
22  * Internet Systems Consortium, Inc.
23  * 950 Charter Street
24  * Redwood City, CA 94063
25  * <info@isc.org>
26  * https://www.isc.org/
27  *
28  */
29 
30 /* A pair of pointers, suitable for making a linked list. */
31 typedef struct _pair {
32  caddr_t car;
33  struct _pair *cdr;
34 } *pair;
35 
37  int refcnt;
39 };
40 
42  const char *name;
43  u_int8_t value;
44 };
45 
46 struct enumeration {
47  struct enumeration *next;
48  const char *name;
49  unsigned width;
51 };
52 
53 /* Tree node types... */
54 #define TREE_CONCAT 1
55 #define TREE_HOST_LOOKUP 2
56 #define TREE_CONST 3
57 #define TREE_LIMIT 4
58 #define TREE_DATA_EXPR 5
59 
60 /* A data buffer with a reference count. */
61 struct buffer {
62  int refcnt;
63  unsigned char data [1];
64 };
65 
66 /* XXX The mechanism by which data strings are returned is currently
67  XXX broken: rather than returning an ephemeral pointer, we create
68  XXX a reference to the data in the caller's space, which the caller
69  XXX then has to dereference - instead, the reference should be
70  XXX ephemeral by default and be made a persistent reference explicitly. */
71 /* XXX on the other hand, it seems to work pretty nicely, so maybe the
72  XXX above comment is meshuggenah. */
73 /* XXX I think the above comment tries to say this:
74  XXX http://tinyurl.com/2tjqre */
75 
76 /* A string of data bytes, possibly accompanied by a larger buffer. */
77 struct data_string {
78  struct buffer *buffer;
79  const unsigned char *data;
80  unsigned len; /* Does not include NUL terminator, if any. */
82 };
83 
85  context_any, /* indefinite */
90  context_data_or_numeric, /* indefinite */
92 };
93 
94 struct fundef {
95  int refcnt;
96  struct string_list *args;
98 };
99 
101  int refcnt;
102  enum {
108  } type;
109  union value {
111  unsigned long intval;
112  int boolean;
113  struct fundef *fundef;
114  struct binding_value *bv;
115  } value;
116 };
117 
118 struct binding {
119  struct binding *next;
120  char *name;
122 };
123 
125  int refcnt;
127  struct binding *bindings;
128 };
129 
130 /* Expression tree structure. */
131 
132 enum expr_op {
195 };
196 
197 struct expression {
198  int refcnt;
199  enum expr_op op;
200  union expr_union {
201  struct {
202  struct expression *expr;
204  struct expression *len;
205  } substring;
206  struct expression *equal [2];
207  struct expression *and [2];
208  struct expression *or [2];
209  struct expression *not;
210  struct expression *add;
215  struct collection *check;
216  struct {
217  struct expression *expr;
218  struct expression *len;
219  } suffix;
220  struct expression *lcase;
221  struct expression *ucase;
222  struct option *option;
223  struct option *config_option;
224  struct {
225  struct expression *offset;
226  struct expression *len;
227  } packet;
231  unsigned long const_int;
232  struct expression *concat [2];
234  struct option *exists;
236  struct {
237  struct expression *base;
238  struct expression *width;
241  } b2a;
242  struct {
243  struct expression *width;
244  struct expression *buffer;
245  } reverse;
246  struct {
247  struct expression *car;
248  struct expression *cdr;
250  struct {
251  struct expression *car;
252  struct expression *cdr;
253  } dns_transaction;
254  struct {
255  unsigned rrclass;
256  unsigned rrtype;
259  struct expression *ttl;
260  } ns_add;
261  struct {
262  unsigned rrclass;
263  unsigned rrtype;
264  struct expression *rrname;
265  struct expression *rrdata;
267  char *variable;
268  struct {
269  struct expression *val;
270  struct expression *next;
271  } arg;
272  struct {
273  char *name;
275  } funcall;
276  struct fundef *func;
277  struct {
278  struct expression *relay;
280  } v6relay;
281  } data;
282  int flags;
283 # define EXPR_EPHEMERAL 1
284 };
285 
286 /* DNS host entry structure... */
288  int refcnt;
291  char hostname [1];
292 };
293 
294 struct option_cache; /* forward */
295 struct packet; /* forward */
296 struct option_state; /* forward */
297 struct decoded_option_state; /* forward */
298 struct lease; /* forward */
299 struct client_state; /* forward */
300 
301 struct universe {
302  const char *name;
303  struct option_cache *(*lookup_func) (struct universe *,
304  struct option_state *,
305  unsigned);
306  void (*save_func) (struct universe *, struct option_state *,
307  struct option_cache *, isc_boolean_t);
308  void (*foreach) (struct packet *,
309  struct lease *, struct client_state *,
310  struct option_state *, struct option_state *,
311  struct binding_scope **, struct universe *, void *,
312  void (*) (struct option_cache *, struct packet *,
313  struct lease *, struct client_state *,
314  struct option_state *,
315  struct option_state *,
316  struct binding_scope **,
317  struct universe *, void *));
318  void (*delete_func) (struct universe *universe,
319  struct option_state *, int);
320  int (*option_state_dereference) (struct universe *,
321  struct option_state *,
322  const char *, int);
323  int (*decode) (struct option_state *,
324  const unsigned char *, unsigned, struct universe *);
325  int (*encapsulate) (struct data_string *, struct packet *,
326  struct lease *, struct client_state *,
327  struct option_state *, struct option_state *,
328  struct binding_scope **,
329  struct universe *);
330  u_int32_t (*get_tag) (const unsigned char *);
331  void (*store_tag) (unsigned char *, u_int32_t);
332  u_int32_t (*get_length) (const unsigned char *);
333  void (*store_length) (unsigned char *, u_int32_t);
335  unsigned site_code_min, end;
338  struct option *enc_opt;
339  int index;
340 
341  /* Flags should probably become condensed. */
343 };
344 
345 struct option {
346  const char *name;
347  const char *format;
349  unsigned code;
350  int refcnt;
351 };
const char * name
Definition: tree.h:302
enum expr_op op
Definition: tree.h:199
int(* decode)(struct option_state *, const unsigned char *, unsigned, struct universe *)
Definition: tree.h:323
Definition: tree.h:31
struct _pair * cdr
Definition: tree.h:33
int(* encapsulate)(struct data_string *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *)
Definition: tree.h:325
struct expression::expr_union::@24 ns_exists
struct universe * universe
Definition: tree.h:348
Definition: tree.h:142
Definition: dhcpd.h:507
unsigned len
Definition: tree.h:80
Definition: tree.h:94
struct expression * val
Definition: tree.h:269
u_int8_t value
Definition: tree.h:43
const char * name
Definition: tree.h:42
struct expression::expr_union::@25 arg
struct expression * equal[2]
Definition: tree.h:206
struct binding_scope * outer
Definition: tree.h:126
struct data_string encapsulate
Definition: tree.h:235
int tag_size
Definition: tree.h:334
struct option * config_option
Definition: tree.h:223
struct expression::expr_union::@21 pick_first_value
int refcnt
Definition: tree.h:125
int refcnt
Definition: tree.h:198
int(* option_state_dereference)(struct universe *, struct option_state *, const char *, int)
Definition: tree.h:320
struct executable_statement * statements
Definition: tree.h:97
unsigned long const_int
Definition: tree.h:231
struct expression * lcase
Definition: tree.h:220
struct data_string data
Definition: tree.h:110
struct binding * next
Definition: tree.h:119
struct expression * arglist
Definition: tree.h:274
struct expression::expr_union::@16 substring
pair first
Definition: tree.h:38
unsigned end
Definition: tree.h:335
struct expression * concat[2]
Definition: tree.h:232
Definition: tree.h:141
enum binding_value::@15 type
struct expression * offset
Definition: tree.h:203
int flags
Definition: tree.h:282
u_int32_t(* get_length)(const unsigned char *)
Definition: tree.h:332
Definition: tree.h:177
struct fundef * func
Definition: tree.h:276
struct expression * rrdata
Definition: tree.h:258
struct _pair * pair
unsigned site_code_min
Definition: tree.h:335
struct expression * not
Definition: tree.h:209
caddr_t car
Definition: tree.h:32
int terminated
Definition: tree.h:81
int refcnt
Definition: tree.h:350
Definition: tree.h:301
struct expression::expr_union::@17 suffix
char hostname[1]
Definition: tree.h:291
struct expression * add
Definition: tree.h:210
void(* store_length)(unsigned char *, u_int32_t)
Definition: tree.h:333
struct fundef * fundef
Definition: tree.h:113
union expression::expr_union data
struct expression * encode_int
Definition: tree.h:230
int concat_duplicates
Definition: tree.h:342
struct expression * remainder
Definition: tree.h:214
Definition: tree.h:345
char * name
Definition: tree.h:120
int refcnt
Definition: tree.h:95
struct expression * or[2]
Definition: tree.h:208
struct expression::expr_union::@20 reverse
struct expression * width
Definition: tree.h:238
struct expression * roption
Definition: tree.h:279
struct expression::expr_union::@22 dns_transaction
unsigned code
Definition: tree.h:349
struct enumeration_value * values
Definition: tree.h:50
Definition: dhcpd.h:369
struct expression * next
Definition: tree.h:270
option_name_hash_t * name_hash
Definition: tree.h:336
struct expression * expr
Definition: tree.h:202
int index
Definition: tree.h:339
struct expression::expr_union::@24 ns_not_exists
struct expression * buffer
Definition: tree.h:240
const char * name
Definition: tree.h:48
const char * name
Definition: tree.h:346
struct expression * and[2]
Definition: tree.h:207
struct expression * multiply
Definition: tree.h:212
struct expression * base
Definition: tree.h:237
struct expression * subtract
Definition: tree.h:211
struct enumeration * next
Definition: tree.h:47
struct expression * relay
Definition: tree.h:278
struct expression::expr_union::@19 b2a
struct expression * extract_int
Definition: tree.h:229
Definition: tree.h:287
struct option * option
Definition: tree.h:222
void(* delete_func)(struct universe *universe, struct option_state *, int)
Definition: tree.h:318
unsigned width
Definition: tree.h:49
unsigned rrclass
Definition: tree.h:255
Definition: tree.h:143
union binding_value::value value
struct expression * divide
Definition: tree.h:213
struct data_string const_data
Definition: tree.h:228
const char * format
Definition: tree.h:347
u_int32_t(* get_tag)(const unsigned char *)
Definition: tree.h:330
struct binding * bindings
Definition: tree.h:127
expr_op
Definition: tree.h:132
struct expression * len
Definition: tree.h:204
unsigned rrtype
Definition: tree.h:256
struct expression::expr_union::@24 ns_delete
struct string_list * args
Definition: tree.h:96
struct option * exists
Definition: tree.h:234
struct data_string data
Definition: tree.h:290
const char int
Definition: omapip.h:443
struct binding_value * value
Definition: tree.h:121
time_t TIME
Definition: dhcpd.h:85
void(* store_tag)(unsigned char *, u_int32_t)
Definition: tree.h:331
struct expression * ucase
Definition: tree.h:221
unsigned char data[1]
Definition: tree.h:63
Definition: tree.h:61
int length_size
Definition: tree.h:334
struct expression::expr_union::@23 ns_add
struct collection * check
Definition: tree.h:215
int refcnt
Definition: tree.h:101
expression_context
Definition: tree.h:84
struct expression * ttl
Definition: tree.h:259
Definition: tree.h:118
struct expression * cdr
Definition: tree.h:248
struct expression * rrname
Definition: tree.h:257
option_code_hash_t * code_hash
Definition: tree.h:337
struct binding_value * bv
Definition: tree.h:114
struct expression::expr_union::@27 v6relay
struct dns_host_entry * host_lookup
Definition: tree.h:233
TIME timeout
Definition: tree.h:289
struct expression * car
Definition: tree.h:247
unsigned long intval
Definition: tree.h:111
const unsigned char * data
Definition: tree.h:79
struct option * enc_opt
Definition: tree.h:338
struct expression::expr_union::@26 funcall
void(* save_func)(struct universe *, struct option_state *, struct option_cache *, isc_boolean_t)
Definition: tree.h:306
int refcnt
Definition: tree.h:288
int refcnt
Definition: tree.h:62
struct expression::expr_union::@18 packet
struct buffer * buffer
Definition: tree.h:78
struct expression * separator
Definition: tree.h:239
Definition: tree.h:180