]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Merge tree struct into expression struct. tree_cache -> option_cache. Move data_s...
authorTed Lemon <source@isc.org>
Thu, 25 Jun 1998 03:35:31 +0000 (03:35 +0000)
committerTed Lemon <source@isc.org>
Thu, 25 Jun 1998 03:35:31 +0000 (03:35 +0000)
includes/tree.h

index e5440ef9e9339021272cf7d764693a8d3750e400..e4a62841497ac5b283c2066f346c21f26c12c832 100644 (file)
@@ -3,7 +3,8 @@
    Definitions for address trees... */
 
 /*
- * Copyright (c) 1995 The Internet Software Consortium.  All rights reserved.
+ * Copyright (c) 1995, 1998 The Internet Software Consortium.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -50,55 +51,95 @@ typedef struct _pair {
 #define TREE_HOST_LOOKUP       2
 #define TREE_CONST             3
 #define TREE_LIMIT             4
+#define TREE_DATA_EXPR         5
 
-/* Tree structure for deferred evaluation of changing values. */
-struct tree {
-       int op;
+/* A string of data bytes, possibly accompanied by a larger buffer. */
+struct data_string {
+       unsigned char *data, *buffer;
+       int len;
+       int terminated;
+};
+
+/* Expression tree structure. */
+
+struct expression {
+       enum {
+               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,
+       } op;
        union {
-               struct concat {
-                       struct tree *left;
-                       struct tree *right;
-               } concat;
-               struct host_lookup {
-                       struct dns_host_entry *host;
-               } host_lookup;
-               struct const_val {
-                       unsigned char *data;
-                       int len;
-               } const_val;
-               struct limit {
-                       struct tree *tree;
-                       int limit;
-               } limit;
+               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;
+               struct {
+                       struct expression *expr;
+                       struct expression *width;
+               } extract_int;
+               unsigned long const_int;
+               struct expression *concat [2];
+               struct dns_host_entry *host_lookup;
        } data;
-};
+       int flags;
+#      define EXPR_EPHEMERAL   1
+};             
 
 /* DNS host entry structure... */
 struct dns_host_entry {
        char *hostname;
-       unsigned char *data;
-       int data_len;
+       char *buffer;
        int buf_len;
+       int data_len;
        TIME timeout;
 };
 
-struct tree_cache {
-       unsigned char *value;
-       int len;
-       int buf_size;
-       TIME timeout;
-       struct tree *tree;
-       int flags;
-#define        TC_AWAITING_RESOLUTION  1
-#define TC_TEMPORARY           2
+struct option_cache {
+       struct expression *expression;
+       struct option *option;
 };
 
 struct data_string; /* forward */
 struct packet; /* forward */
+struct option_state; /* forward */
+enum statement_op; /* forward */
 
 struct universe {
        char *name;
        struct data_string (*lookup_func) PROTO ((struct packet *, int));
+       void (*set_func) PROTO ((struct option_state *,
+                                struct option_cache *,
+                                enum statement_op));
        struct hash_table *hash;
        struct option *options [256];
 };