2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-09-02 15:25:48 +00:00

Add more expression evaluation goo.

This commit is contained in:
Ted Lemon
1998-11-06 00:14:47 +00:00
parent c4763f5f3f
commit a461fb50b6

View File

@@ -53,35 +53,54 @@ typedef struct _pair {
#define TREE_LIMIT 4 #define TREE_LIMIT 4
#define TREE_DATA_EXPR 5 #define TREE_DATA_EXPR 5
/* A data buffer with a reference count. */
struct buffer {
int refcnt;
char data [1];
};
/* 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. */
/* A string of data bytes, possibly accompanied by a larger buffer. */ /* A string of data bytes, possibly accompanied by a larger buffer. */
struct data_string { struct data_string {
unsigned char *data, *buffer; struct buffer *buffer;
unsigned char *data;
int len; int len;
int terminated; int terminated;
}; };
/* Expression tree structure. */ /* Expression tree structure. */
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,
expr_const_int,
expr_exists,
};
struct expression { struct expression {
enum { int refcnt;
expr_check, enum expr_op op;
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,
expr_const_int,
} op;
union { union {
struct { struct {
struct expression *expr; struct expression *expr;
@@ -103,13 +122,11 @@ struct expression {
struct expression *len; struct expression *len;
} packet; } packet;
struct data_string const_data; struct data_string const_data;
struct { struct expression *extract_int;
struct expression *expr;
struct expression *width;
} extract_int;
unsigned long const_int; unsigned long const_int;
struct expression *concat [2]; struct expression *concat [2];
struct dns_host_entry *host_lookup; struct dns_host_entry *host_lookup;
struct option *exists;
} data; } data;
int flags; int flags;
# define EXPR_EPHEMERAL 1 # define EXPR_EPHEMERAL 1
@@ -117,26 +134,24 @@ struct expression {
/* DNS host entry structure... */ /* DNS host entry structure... */
struct dns_host_entry { struct dns_host_entry {
char *hostname; int refcnt;
char *buffer;
int buf_len;
int data_len;
TIME timeout; TIME timeout;
struct data_string data;
char hostname [1];
}; };
struct option_cache { struct option_cache; /* forward */
struct expression *expression;
struct option *option;
};
struct data_string; /* forward */ struct data_string; /* forward */
struct packet; /* forward */ struct packet; /* forward */
struct option_state; /* forward */ struct option_state; /* forward */
struct decoded_option_state; /* forward */
enum statement_op; /* forward */ enum statement_op; /* forward */
struct universe { struct universe {
char *name; char *name;
struct data_string (*lookup_func) PROTO ((struct packet *, int)); int (*lookup_func)
PROTO ((struct data_string *,
struct option_state *, int));
void (*set_func) PROTO ((struct option_state *, void (*set_func) PROTO ((struct option_state *,
struct option_cache *, struct option_cache *,
enum statement_op)); enum statement_op));
@@ -150,3 +165,10 @@ struct option {
struct universe *universe; struct universe *universe;
unsigned char code; unsigned char code;
}; };
enum expression_context {
context_any,
context_boolean,
context_data,
context_numeric
};