1995-11-29 07:40:04 +00:00
|
|
|
/* tree.h
|
|
|
|
|
|
|
|
Definitions for address trees... */
|
|
|
|
|
|
|
|
/*
|
1999-03-16 05:50:46 +00:00
|
|
|
* Copyright (c) 1996-1999 Internet Software Consortium.
|
|
|
|
* Use is subject to license terms which appear in the file named
|
|
|
|
* ISC-LICENSE that should have accompanied this file when you
|
|
|
|
* received it. If a file named ISC-LICENSE did not accompany this
|
|
|
|
* file, or you are not sure the one you have is correct, you may
|
|
|
|
* obtain an applicable copy of the license at:
|
1995-11-29 07:40:04 +00:00
|
|
|
*
|
1999-03-16 05:50:46 +00:00
|
|
|
* http://www.isc.org/isc-license-1.0.html.
|
1995-11-29 07:40:04 +00:00
|
|
|
*
|
1999-03-16 05:50:46 +00:00
|
|
|
* This file is part of the ISC DHCP distribution. The documentation
|
|
|
|
* associated with this file is listed in the file DOCUMENTATION,
|
|
|
|
* included in the top-level directory of this release.
|
1995-11-29 07:40:04 +00:00
|
|
|
*
|
1999-03-16 05:50:46 +00:00
|
|
|
* Support and other services are available for ISC products - see
|
|
|
|
* http://www.isc.org for more information.
|
1995-11-29 07:40:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* A pair of pointers, suitable for making a linked list. */
|
|
|
|
typedef struct _pair {
|
|
|
|
caddr_t car;
|
|
|
|
struct _pair *cdr;
|
|
|
|
} *pair;
|
|
|
|
|
|
|
|
/* Tree node types... */
|
|
|
|
#define TREE_CONCAT 1
|
|
|
|
#define TREE_HOST_LOOKUP 2
|
|
|
|
#define TREE_CONST 3
|
|
|
|
#define TREE_LIMIT 4
|
1998-06-25 03:35:31 +00:00
|
|
|
#define TREE_DATA_EXPR 5
|
1995-11-29 07:40:04 +00:00
|
|
|
|
1998-11-06 00:14:47 +00:00
|
|
|
/* A data buffer with a reference count. */
|
|
|
|
struct buffer {
|
|
|
|
int refcnt;
|
1999-03-16 06:37:55 +00:00
|
|
|
unsigned char data [1];
|
1998-11-06 00:14:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* XXX The mechanism by which data strings are returned is currently
|
|
|
|
XXX broken: rather than returning an ephemeral pointer, we create
|
|
|
|
XXX a reference to the data in the caller's space, which the caller
|
|
|
|
XXX then has to dereference - instead, the reference should be
|
|
|
|
XXX ephemeral by default and be made a persistent reference explicitly. */
|
1999-05-27 14:53:01 +00:00
|
|
|
/* XXX on the other hand, it seems to work pretty nicely, so maybe the
|
|
|
|
XXX above comment is meshuggenah. */
|
1998-11-06 00:14:47 +00:00
|
|
|
|
1998-06-25 03:35:31 +00:00
|
|
|
/* A string of data bytes, possibly accompanied by a larger buffer. */
|
|
|
|
struct data_string {
|
1998-11-06 00:14:47 +00:00
|
|
|
struct buffer *buffer;
|
|
|
|
unsigned char *data;
|
1999-07-20 17:59:14 +00:00
|
|
|
int len; /* Does not include NUL terminator, if any. */
|
1998-06-25 03:35:31 +00:00
|
|
|
int terminated;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Expression tree structure. */
|
|
|
|
|
1998-11-06 00:14:47 +00:00
|
|
|
enum expr_op {
|
|
|
|
expr_none,
|
|
|
|
expr_match,
|
|
|
|
expr_check,
|
|
|
|
expr_equal,
|
|
|
|
expr_substring,
|
|
|
|
expr_suffix,
|
|
|
|
expr_concat,
|
|
|
|
expr_host_lookup,
|
|
|
|
expr_and,
|
|
|
|
expr_or,
|
|
|
|
expr_not,
|
|
|
|
expr_option,
|
|
|
|
expr_hardware,
|
|
|
|
expr_packet,
|
|
|
|
expr_const_data,
|
|
|
|
expr_extract_int8,
|
|
|
|
expr_extract_int16,
|
|
|
|
expr_extract_int32,
|
1999-05-27 14:53:01 +00:00
|
|
|
expr_encode_int8,
|
|
|
|
expr_encode_int16,
|
|
|
|
expr_encode_int32,
|
1998-11-06 00:14:47 +00:00
|
|
|
expr_const_int,
|
|
|
|
expr_exists,
|
1999-04-05 14:54:38 +00:00
|
|
|
expr_encapsulate,
|
1999-04-12 22:14:36 +00:00
|
|
|
expr_known,
|
1999-07-02 20:58:48 +00:00
|
|
|
expr_reverse,
|
|
|
|
expr_leased_address,
|
|
|
|
expr_binary_to_ascii,
|
1999-07-16 21:34:14 +00:00
|
|
|
expr_config_option,
|
|
|
|
expr_host_decl_name,
|
|
|
|
expr_pick_first_value,
|
1999-07-19 01:15:22 +00:00
|
|
|
expr_lease_time,
|
|
|
|
expr_dns_update,
|
1998-11-06 00:14:47 +00:00
|
|
|
};
|
|
|
|
|
1998-06-25 03:35:31 +00:00
|
|
|
struct expression {
|
1998-11-06 00:14:47 +00:00
|
|
|
int refcnt;
|
|
|
|
enum expr_op op;
|
1995-11-29 07:40:04 +00:00
|
|
|
union {
|
1998-06-25 03:35:31 +00:00
|
|
|
struct {
|
|
|
|
struct expression *expr;
|
|
|
|
struct expression *offset;
|
|
|
|
struct expression *len;
|
|
|
|
} substring;
|
|
|
|
struct expression *equal [2];
|
|
|
|
struct expression *and [2];
|
|
|
|
struct expression *or [2];
|
|
|
|
struct expression *not;
|
|
|
|
struct collection *check;
|
|
|
|
struct {
|
|
|
|
struct expression *expr;
|
|
|
|
struct expression *len;
|
|
|
|
} suffix;
|
|
|
|
struct option *option;
|
1999-07-16 21:34:14 +00:00
|
|
|
struct option *config_option;
|
1998-06-25 03:35:31 +00:00
|
|
|
struct {
|
|
|
|
struct expression *offset;
|
|
|
|
struct expression *len;
|
|
|
|
} packet;
|
|
|
|
struct data_string const_data;
|
1998-11-06 00:14:47 +00:00
|
|
|
struct expression *extract_int;
|
1999-05-27 14:53:01 +00:00
|
|
|
struct expression *encode_int;
|
1998-06-25 03:35:31 +00:00
|
|
|
unsigned long const_int;
|
|
|
|
struct expression *concat [2];
|
|
|
|
struct dns_host_entry *host_lookup;
|
1998-11-06 00:14:47 +00:00
|
|
|
struct option *exists;
|
1999-04-05 14:54:38 +00:00
|
|
|
struct data_string encapsulate;
|
1999-07-02 20:58:48 +00:00
|
|
|
struct {
|
|
|
|
struct expression *base;
|
|
|
|
struct expression *width;
|
|
|
|
struct expression *seperator;
|
|
|
|
struct expression *buffer;
|
|
|
|
} b2a;
|
|
|
|
struct {
|
|
|
|
struct expression *width;
|
|
|
|
struct expression *buffer;
|
|
|
|
} reverse;
|
1999-07-16 21:34:14 +00:00
|
|
|
struct {
|
|
|
|
struct expression *car;
|
|
|
|
struct expression *cdr;
|
|
|
|
} pick_first_value;
|
1999-07-19 01:15:22 +00:00
|
|
|
struct {
|
|
|
|
struct expression *type;
|
|
|
|
struct expression *expr1;
|
|
|
|
struct expression *expr2;
|
|
|
|
struct expression *ttl;
|
|
|
|
} dns_update;
|
1995-11-29 07:40:04 +00:00
|
|
|
} data;
|
1998-06-25 03:35:31 +00:00
|
|
|
int flags;
|
|
|
|
# define EXPR_EPHEMERAL 1
|
|
|
|
};
|
1995-11-29 07:40:04 +00:00
|
|
|
|
|
|
|
/* DNS host entry structure... */
|
|
|
|
struct dns_host_entry {
|
1998-11-06 00:14:47 +00:00
|
|
|
int refcnt;
|
1995-11-29 07:40:04 +00:00
|
|
|
TIME timeout;
|
1998-11-06 00:14:47 +00:00
|
|
|
struct data_string data;
|
|
|
|
char hostname [1];
|
1995-11-29 07:40:04 +00:00
|
|
|
};
|
|
|
|
|
1998-11-06 00:14:47 +00:00
|
|
|
struct option_cache; /* forward */
|
1998-04-19 23:23:34 +00:00
|
|
|
struct packet; /* forward */
|
1998-06-25 03:35:31 +00:00
|
|
|
struct option_state; /* forward */
|
1998-11-06 00:14:47 +00:00
|
|
|
struct decoded_option_state; /* forward */
|
1999-07-02 20:58:48 +00:00
|
|
|
struct lease; /* forward */
|
1998-04-19 23:23:34 +00:00
|
|
|
|
1995-11-29 07:40:04 +00:00
|
|
|
struct universe {
|
|
|
|
char *name;
|
1999-04-05 14:54:38 +00:00
|
|
|
struct option_cache *(*lookup_func) PROTO ((struct universe *,
|
|
|
|
struct option_state *,
|
|
|
|
int));
|
|
|
|
void (*save_func) PROTO ((struct universe *, struct option_state *,
|
|
|
|
struct option_cache *));
|
|
|
|
int (*get_func) PROTO ((struct data_string *, struct universe *,
|
1999-07-02 20:58:48 +00:00
|
|
|
struct packet *, struct lease *,
|
1999-04-05 14:54:38 +00:00
|
|
|
struct option_state *, int));
|
|
|
|
void (*set_func) PROTO ((struct universe *, struct option_state *,
|
|
|
|
struct option_cache *, enum statement_op));
|
|
|
|
|
|
|
|
void (*delete_func) PROTO ((struct universe *universe,
|
|
|
|
struct option_state *, int));
|
|
|
|
int (*option_state_dereference) PROTO ((struct universe *,
|
|
|
|
struct option_state *));
|
|
|
|
int (*encapsulate) PROTO ((struct data_string *, struct option_state *,
|
1999-07-02 20:58:48 +00:00
|
|
|
struct lease *, struct universe *));
|
1999-04-05 14:54:38 +00:00
|
|
|
void (*store_tag) PROTO ((unsigned char *, u_int32_t));
|
|
|
|
void (*store_length) PROTO ((unsigned char *, u_int32_t));
|
|
|
|
int tag_size, length_size;
|
1995-11-29 07:40:04 +00:00
|
|
|
struct hash_table *hash;
|
|
|
|
struct option *options [256];
|
1999-04-05 14:54:38 +00:00
|
|
|
int index;
|
1995-11-29 07:40:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct option {
|
|
|
|
char *name;
|
|
|
|
char *format;
|
|
|
|
struct universe *universe;
|
1999-03-25 22:03:44 +00:00
|
|
|
int code;
|
1995-11-29 07:40:04 +00:00
|
|
|
};
|
1998-11-06 00:14:47 +00:00
|
|
|
|
|
|
|
enum expression_context {
|
|
|
|
context_any,
|
|
|
|
context_boolean,
|
|
|
|
context_data,
|
|
|
|
context_numeric
|
|
|
|
};
|