1238106Sdes/* 2238106Sdes * iterator/iter_donotq.h - iterative resolver donotqueryaddresses storage. 3238106Sdes * 4238106Sdes * Copyright (c) 2007, 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 donotquery addresses and lookup fast. 41238106Sdes */ 42238106Sdes 43238106Sdes#ifndef ITERATOR_ITER_DONOTQ_H 44238106Sdes#define ITERATOR_ITER_DONOTQ_H 45238106Sdes#include "util/storage/dnstree.h" 46238106Sdesstruct iter_env; 47238106Sdesstruct config_file; 48238106Sdesstruct regional; 49238106Sdes 50238106Sdes/** 51238106Sdes * Iterator donotqueryaddresses structure 52238106Sdes */ 53238106Sdesstruct iter_donotq { 54238106Sdes /** regional for allocation */ 55238106Sdes struct regional* region; 56238106Sdes /** 57238106Sdes * Tree of the address spans that are blocked. 58238106Sdes * contents of type addr_tree_node. Each node is an address span 59238106Sdes * that must not be used to send queries to. 60238106Sdes */ 61238106Sdes rbtree_t tree; 62238106Sdes}; 63238106Sdes 64238106Sdes/** 65238106Sdes * Create donotqueryaddresses structure 66238106Sdes * @return new structure or NULL on error. 67238106Sdes */ 68238106Sdesstruct iter_donotq* donotq_create(void); 69238106Sdes 70238106Sdes/** 71238106Sdes * Delete donotqueryaddresses structure. 72238106Sdes * @param donotq: to delete. 73238106Sdes */ 74238106Sdesvoid donotq_delete(struct iter_donotq* donotq); 75238106Sdes 76238106Sdes/** 77238106Sdes * Process donotqueryaddresses config. 78238106Sdes * @param donotq: where to store. 79238106Sdes * @param cfg: config options. 80238106Sdes * @return 0 on error. 81238106Sdes */ 82238106Sdesint donotq_apply_cfg(struct iter_donotq* donotq, struct config_file* cfg); 83238106Sdes 84238106Sdes/** 85238106Sdes * See if an address is blocked. 86238106Sdes * @param donotq: structure for address storage. 87238106Sdes * @param addr: address to check 88238106Sdes * @param addrlen: length of addr. 89238106Sdes * @return: true if the address must not be queried. false if unlisted. 90238106Sdes */ 91238106Sdesint donotq_lookup(struct iter_donotq* donotq, struct sockaddr_storage* addr, 92238106Sdes socklen_t addrlen); 93238106Sdes 94238106Sdes/** 95238106Sdes * Get memory used by donotqueryaddresses structure. 96238106Sdes * @param donotq: structure for address storage. 97238106Sdes * @return bytes in use. 98238106Sdes */ 99238106Sdessize_t donotq_get_mem(struct iter_donotq* donotq); 100238106Sdes 101238106Sdes#endif /* ITERATOR_ITER_DONOTQ_H */ 102