]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - edns-subnet/subnet-whitelist.h
Vendor import of Unbound 1.6.2.
[FreeBSD/FreeBSD.git] / edns-subnet / subnet-whitelist.h
1 /*
2  * edns-subnet/subnet-whitelist.h - Hosts we actively try to send subnet option
3  * to.
4  *
5  * Copyright (c) 2013, NLnet Labs. All rights reserved.
6  *
7  * This software is open source.
8  * 
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 
13  * Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  * 
16  * Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  * 
20  * Neither the name of the NLNET LABS nor the names of its contributors may
21  * be used to endorse or promote products derived from this software without
22  * specific prior written permission.
23  * 
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
30  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  */
36 /**
37  * \file
38  *
39  * Keep track of the white listed servers for subnet option. Based
40  * on acl_list.c|h
41  */
42
43 #ifndef EDNSSUBNET_WHITELIST_H
44 #define EDNSSUBNET_WHITELIST_H
45 #include "util/storage/dnstree.h"
46
47 struct config_file;
48 struct regional;
49
50 /**
51  * ednssubnet_upstream structure
52  */
53 struct ednssubnet_upstream {
54         /** regional for allocation */
55         struct regional* region;
56         /** 
57          * Tree of the address spans that are whitelisted.
58          * contents of type addr_tree_node. Each node is an address span 
59          * Unbound will append subnet option for.
60          */
61         rbtree_type tree;
62 };
63
64 /**
65  * Create ednssubnet_upstream structure 
66  * @return new structure or NULL on error.
67  */
68 struct ednssubnet_upstream* upstream_create(void);
69
70 /**
71  * Delete ednssubnet_upstream structure.
72  * @param upstream: to delete.
73  */
74 void upstream_delete(struct ednssubnet_upstream* upstream);
75
76 /**
77  * Process ednssubnet_upstream config.
78  * @param upstream: where to store.
79  * @param cfg: config options.
80  * @return 0 on error.
81  */
82 int upstream_apply_cfg(struct ednssubnet_upstream* upstream,
83         struct config_file* cfg);
84
85 /**
86  * See if an address is whitelisted.
87  * @param upstream: structure for address storage.
88  * @param addr: address to check
89  * @param addrlen: length of addr.
90  * @return: true if the address is whitelisted for subnet option. 
91  */
92 int upstream_is_whitelisted(struct ednssubnet_upstream* upstream,
93         struct sockaddr_storage* addr, socklen_t addrlen);
94
95 /**
96  * Get memory used by ednssubnet_upstream structure.
97  * @param upstream: structure for address storage.
98  * @return bytes in use.
99  */
100 size_t upstream_get_mem(struct ednssubnet_upstream* upstream);
101
102 #endif /* EDNSSUBNET_WHITELIST_H */