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