1238106Sdes/* 2238106Sdes * iterator/iter_priv.h - iterative resolver private address and domain store 3238106Sdes * 4238106Sdes * Copyright (c) 2008, NLnet Labs. All rights reserved. 5238106Sdes * 6238106Sdes * This software is open source. 7238106Sdes * 8238106Sdes * Redistribution and use in source and binary forms, with or without 9238106Sdes * modification, are permitted provided that the following conditions 10238106Sdes * are met: 11238106Sdes * 12238106Sdes * Redistributions of source code must retain the above copyright notice, 13238106Sdes * this list of conditions and the following disclaimer. 14238106Sdes * 15238106Sdes * Redistributions in binary form must reproduce the above copyright notice, 16238106Sdes * this list of conditions and the following disclaimer in the documentation 17238106Sdes * and/or other materials provided with the distribution. 18238106Sdes * 19238106Sdes * Neither the name of the NLNET LABS nor the names of its contributors may 20238106Sdes * be used to endorse or promote products derived from this software without 21238106Sdes * specific prior written permission. 22238106Sdes * 23238106Sdes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24269257Sdes * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25269257Sdes * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26269257Sdes * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27269257Sdes * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28269257Sdes * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29269257Sdes * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30269257Sdes * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31269257Sdes * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32269257Sdes * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33269257Sdes * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34238106Sdes */ 35238106Sdes 36238106Sdes/** 37238106Sdes * \file 38238106Sdes * 39238106Sdes * This file contains functions to assist the iterator module. 40238106Sdes * Keep track of the private addresses and lookup fast. 41238106Sdes */ 42238106Sdes 43238106Sdes#ifndef ITERATOR_ITER_PRIV_H 44238106Sdes#define ITERATOR_ITER_PRIV_H 45238106Sdes#include "util/rbtree.h" 46269257Sdesstruct sldns_buffer; 47238106Sdesstruct iter_env; 48238106Sdesstruct config_file; 49238106Sdesstruct regional; 50238106Sdesstruct rrset_parse; 51238106Sdes 52238106Sdes/** 53238106Sdes * Iterator priv structure 54238106Sdes */ 55238106Sdesstruct iter_priv { 56238106Sdes /** regional for allocation */ 57238106Sdes struct regional* region; 58238106Sdes /** 59238106Sdes * Tree of the address spans that are blocked. 60238106Sdes * contents of type addr_tree_node. 61238106Sdes * No further data need, only presence or absence. 62238106Sdes */ 63238106Sdes rbtree_t a; 64238106Sdes /** 65238106Sdes * Tree of the domains spans that are allowed to contain 66238106Sdes * the blocked address spans. 67238106Sdes * contents of type name_tree_node. 68238106Sdes * No further data need, only presence or absence. 69238106Sdes */ 70238106Sdes rbtree_t n; 71238106Sdes}; 72238106Sdes 73238106Sdes/** 74238106Sdes * Create priv structure 75238106Sdes * @return new structure or NULL on error. 76238106Sdes */ 77238106Sdesstruct iter_priv* priv_create(void); 78238106Sdes 79238106Sdes/** 80238106Sdes * Delete priv structure. 81238106Sdes * @param priv: to delete. 82238106Sdes */ 83238106Sdesvoid priv_delete(struct iter_priv* priv); 84238106Sdes 85238106Sdes/** 86238106Sdes * Process priv config. 87238106Sdes * @param priv: where to store. 88238106Sdes * @param cfg: config options. 89238106Sdes * @return 0 on error. 90238106Sdes */ 91238106Sdesint priv_apply_cfg(struct iter_priv* priv, struct config_file* cfg); 92238106Sdes 93238106Sdes/** 94238106Sdes * See if rrset is bad. 95269257Sdes * Will remove individual RRs that are bad (if possible) to 96269257Sdes * sanitize the RRset without removing it completely. 97238106Sdes * @param priv: structure for private address storage. 98238106Sdes * @param pkt: packet to decompress rrset name in. 99238106Sdes * @param rrset: the rrset to examine, A or AAAA. 100238106Sdes * @return true if the rrset is bad and should be removed. 101238106Sdes */ 102269257Sdesint priv_rrset_bad(struct iter_priv* priv, struct sldns_buffer* pkt, 103238106Sdes struct rrset_parse* rrset); 104238106Sdes 105238106Sdes/** 106238106Sdes * Get memory used by priv structure. 107238106Sdes * @param priv: structure for address storage. 108238106Sdes * @return bytes in use. 109238106Sdes */ 110238106Sdessize_t priv_get_mem(struct iter_priv* priv); 111238106Sdes 112238106Sdes#endif /* ITERATOR_ITER_PRIV_H */ 113