xref: /openbsd-src/usr.sbin/dhcpd/tree.h (revision 0795b38919d5e1a9797bb5628fbd00cbe8824b7d)
1 /*	$OpenBSD: tree.h,v 1.5 2004/09/16 18:35:43 deraadt Exp $	*/
2 
3 /* Definitions for address trees... */
4 
5 /*
6  * Copyright (c) 1995 The Internet Software Consortium.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. Neither the name of The Internet Software Consortium nor the names
18  *    of its contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
22  * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED.  IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
29  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  * This software has been written for the Internet Software Consortium
36  * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
37  * Enterprises.  To learn more about the Internet Software Consortium,
38  * see ``http://www.vix.com/isc''.  To learn more about Vixie
39  * Enterprises, see ``http://www.vix.com''.
40  */
41 
42 /* A pair of pointers, suitable for making a linked list. */
43 typedef struct _pair {
44 	caddr_t		 car;
45 	struct _pair	*cdr;
46 } *pair;
47 
48 /* Tree node types... */
49 #define TREE_CONCAT		1
50 #define TREE_HOST_LOOKUP	2
51 #define TREE_CONST		3
52 #define TREE_LIMIT		4
53 
54 /* Tree structure for deferred evaluation of changing values. */
55 struct tree {
56 	int	op;
57 	union {
58 		struct concat {
59 			struct tree	*left;
60 			struct tree	*right;
61 		} concat;
62 		struct host_lookup {
63 			struct dns_host_entry *host;
64 		} host_lookup;
65 		struct const_val {
66 			unsigned char	*data;
67 			int		 len;
68 		} const_val;
69 		struct limit {
70 			struct tree	*tree;
71 			int		 limit;
72 		} limit;
73 	} data;
74 };
75 
76 /* DNS host entry structure... */
77 struct dns_host_entry {
78 	char		*hostname;
79 	unsigned char	*data;
80 	int		 data_len;
81 	int		 buf_len;
82 	time_t		 timeout;
83 };
84 
85 struct tree_cache {
86 	unsigned char	*value;
87 	int		 len;
88 	unsigned int	 buf_size;
89 	time_t		 timeout;
90 	struct tree	*tree;
91 	int		 flags;
92 #define	TC_AWAITING_RESOLUTION	1
93 #define TC_TEMPORARY		2
94 };
95 
96 struct universe {
97 	char		*name;
98 	struct hash_table *hash;
99 	struct option	*options[256];
100 };
101 
102 struct option {
103 	char		*name;
104 	char		*format;
105 	struct universe	*universe;
106 	unsigned char	code;
107 };
108