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

154 lines
3.5 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. */
/* 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;
int len;
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,
expr_const_int,
expr_exists,
};
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 {
struct expression *offset;
struct expression *len;
} packet;
struct data_string const_data;
1998-11-06 00:14:47 +00:00
struct expression *extract_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;
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 data_string; /* forward */
struct packet; /* forward */
struct option_state; /* forward */
1998-11-06 00:14:47 +00:00
struct decoded_option_state; /* forward */
1995-11-29 07:40:04 +00:00
struct universe {
char *name;
1998-11-06 00:14:47 +00:00
int (*lookup_func)
PROTO ((struct data_string *,
struct option_state *, int));
void (*set_func) PROTO ((struct option_state *,
struct option_cache *,
enum statement_op));
1995-11-29 07:40:04 +00:00
struct hash_table *hash;
struct option *options [256];
};
struct option {
char *name;
char *format;
struct universe *universe;
unsigned char code;
};
1998-11-06 00:14:47 +00:00
enum expression_context {
context_any,
context_boolean,
context_data,
context_numeric
};