2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-23 10:28:08 +00:00

238 lines
5.8 KiB
C
Raw Normal View History

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
#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
/* 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;
const unsigned char *data;
unsigned len; /* Does not include NUL terminator, if any. */
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,
expr_encapsulate,
expr_known,
expr_reverse,
expr_leased_address,
expr_binary_to_ascii,
expr_config_option,
expr_host_decl_name,
expr_pick_first_value,
expr_lease_time,
2000-01-05 18:09:34 +00:00
expr_dns_transaction,
expr_static,
expr_ns_add,
2000-01-05 18:09:34 +00:00
expr_ns_delete,
expr_ns_exists,
expr_ns_not_exists,
expr_not_equal,
expr_null,
expr_variable_exists,
expr_variable_reference
1998-11-06 00:14:47 +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 {
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;
struct option *config_option;
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;
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;
struct data_string encapsulate;
struct {
struct expression *base;
struct expression *width;
struct expression *seperator;
struct expression *buffer;
} b2a;
struct {
struct expression *width;
struct expression *buffer;
} reverse;
struct {
struct expression *car;
struct expression *cdr;
} pick_first_value;
2000-01-05 18:09:34 +00:00
struct {
struct expression *car;
struct expression *cdr;
} dns_transaction;
struct {
2000-01-05 18:09:34 +00:00
unsigned rrclass;
unsigned rrtype;
1999-11-20 18:36:32 +00:00
struct expression *rrname;
struct expression *rrdata;
struct expression *ttl;
} ns_add;
2000-01-05 18:09:34 +00:00
struct {
unsigned rrclass;
unsigned rrtype;
struct expression *rrname;
struct expression *rrdata;
} ns_delete, ns_exists, ns_not_exists;
char *variable;
1995-11-29 07:40:04 +00:00
} data;
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 */
struct packet; /* forward */
struct option_state; /* forward */
1998-11-06 00:14:47 +00:00
struct decoded_option_state; /* forward */
struct lease; /* forward */
1995-11-29 07:40:04 +00:00
struct universe {
const char *name;
struct option_cache *(*lookup_func) PROTO ((struct universe *,
struct option_state *,
unsigned));
void (*save_func) PROTO ((struct universe *, struct option_state *,
struct option_cache *));
int (*get_func) PROTO ((struct data_string *, struct universe *,
struct packet *, struct lease *,
struct option_state *, struct option_state *,
struct option_state *, unsigned));
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 packet *,
struct lease *, struct option_state *,
struct option_state *, struct universe *));
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];
int index;
1995-11-29 07:40:04 +00:00
};
struct option {
const char *name;
const char *format;
1995-11-29 07:40:04 +00:00
struct universe *universe;
unsigned 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,
2000-01-05 18:09:34 +00:00
context_numeric,
context_dns,
context_data_or_numeric
};
struct binding {
struct binding *next;
char *name;
struct data_string value;
1998-11-06 00:14:47 +00:00
};