xref: /openbsd-src/usr.sbin/unbound/ipsecmod/ipsecmod-whitelist.h (revision 2be9e038cdf8e9bb60fc3afb4a2f01fcd3263713)
1*2be9e038Ssthen /*
2*2be9e038Ssthen  * ipsecmod/ipsecmod-whitelist.h - White listed domains for the ipsecmod to
3*2be9e038Ssthen  * operate on.
4*2be9e038Ssthen  *
5*2be9e038Ssthen  * Copyright (c) 2017, NLnet Labs. All rights reserved.
6*2be9e038Ssthen  *
7*2be9e038Ssthen  * This software is open source.
8*2be9e038Ssthen  *
9*2be9e038Ssthen  * Redistribution and use in source and binary forms, with or without
10*2be9e038Ssthen  * modification, are permitted provided that the following conditions
11*2be9e038Ssthen  * are met:
12*2be9e038Ssthen  *
13*2be9e038Ssthen  * Redistributions of source code must retain the above copyright notice,
14*2be9e038Ssthen  * this list of conditions and the following disclaimer.
15*2be9e038Ssthen  *
16*2be9e038Ssthen  * Redistributions in binary form must reproduce the above copyright notice,
17*2be9e038Ssthen  * this list of conditions and the following disclaimer in the documentation
18*2be9e038Ssthen  * and/or other materials provided with the distribution.
19*2be9e038Ssthen  *
20*2be9e038Ssthen  * Neither the name of the NLNET LABS nor the names of its contributors may
21*2be9e038Ssthen  * be used to endorse or promote products derived from this software without
22*2be9e038Ssthen  * specific prior written permission.
23*2be9e038Ssthen  *
24*2be9e038Ssthen  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25*2be9e038Ssthen  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26*2be9e038Ssthen  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27*2be9e038Ssthen  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28*2be9e038Ssthen  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29*2be9e038Ssthen  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
30*2be9e038Ssthen  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31*2be9e038Ssthen  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32*2be9e038Ssthen  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33*2be9e038Ssthen  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34*2be9e038Ssthen  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35*2be9e038Ssthen  */
36*2be9e038Ssthen /**
37*2be9e038Ssthen  * \file
38*2be9e038Ssthen  *
39*2be9e038Ssthen  * Keep track of the white listed domains for ipsecmod.
40*2be9e038Ssthen  */
41*2be9e038Ssthen 
42*2be9e038Ssthen #ifndef IPSECMOD_WHITELIST_H
43*2be9e038Ssthen #define IPSECMOD_WHITELIST_H
44*2be9e038Ssthen #include "util/storage/dnstree.h"
45*2be9e038Ssthen 
46*2be9e038Ssthen struct config_file;
47*2be9e038Ssthen struct regional;
48*2be9e038Ssthen 
49*2be9e038Ssthen /**
50*2be9e038Ssthen  * Process ipsecmod_whitelist config.
51*2be9e038Ssthen  * @param ie: ipsecmod environment.
52*2be9e038Ssthen  * @param cfg: config options.
53*2be9e038Ssthen  * @return 0 on error.
54*2be9e038Ssthen  */
55*2be9e038Ssthen int ipsecmod_whitelist_apply_cfg(struct ipsecmod_env* ie,
56*2be9e038Ssthen 	struct config_file* cfg);
57*2be9e038Ssthen 
58*2be9e038Ssthen /**
59*2be9e038Ssthen  * Delete the ipsecmod whitelist.
60*2be9e038Ssthen  * @param whitelist: ipsecmod whitelist.
61*2be9e038Ssthen  */
62*2be9e038Ssthen void ipsecmod_whitelist_delete(rbtree_type* whitelist);
63*2be9e038Ssthen 
64*2be9e038Ssthen /**
65*2be9e038Ssthen  * See if a domain is whitelisted.
66*2be9e038Ssthen  * @param ie: ipsecmod environment.
67*2be9e038Ssthen  * @param dname: domain name to check.
68*2be9e038Ssthen  * @param dname_len: length of domain name.
69*2be9e038Ssthen  * @param qclass: query CLASS.
70*2be9e038Ssthen  * @return: true if the domain is whitelisted for the ipsecmod.
71*2be9e038Ssthen  */
72*2be9e038Ssthen int ipsecmod_domain_is_whitelisted(struct ipsecmod_env* ie, uint8_t* dname,
73*2be9e038Ssthen 	size_t dname_len, uint16_t qclass);
74*2be9e038Ssthen 
75*2be9e038Ssthen /**
76*2be9e038Ssthen  * Get memory used by ipsecmod whitelist.
77*2be9e038Ssthen  * @param whitelist: structure for domain storage.
78*2be9e038Ssthen  * @return bytes in use.
79*2be9e038Ssthen  */
80*2be9e038Ssthen size_t ipsecmod_whitelist_get_mem(rbtree_type* whitelist);
81*2be9e038Ssthen 
82*2be9e038Ssthen #endif /* IPSECMOD_WHITELIST_H */
83