iter_donotq.h revision 256281
1251877Speter/* 2251877Speter * iterator/iter_donotq.h - iterative resolver donotqueryaddresses storage. 3251877Speter * 4251877Speter * Copyright (c) 2007, NLnet Labs. All rights reserved. 5251877Speter * 6251877Speter * This software is open source. 7251877Speter * 8251877Speter * Redistribution and use in source and binary forms, with or without 9251877Speter * modification, are permitted provided that the following conditions 10251877Speter * are met: 11251877Speter * 12251877Speter * Redistributions of source code must retain the above copyright notice, 13251877Speter * this list of conditions and the following disclaimer. 14251877Speter * 15251877Speter * Redistributions in binary form must reproduce the above copyright notice, 16251877Speter * this list of conditions and the following disclaimer in the documentation 17251877Speter * and/or other materials provided with the distribution. 18251877Speter * 19251877Speter * Neither the name of the NLNET LABS nor the names of its contributors may 20251877Speter * be used to endorse or promote products derived from this software without 21251877Speter * specific prior written permission. 22251877Speter * 23251877Speter * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24251877Speter * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 25251877Speter * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26253895Speter * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 27253895Speter * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28251877Speter * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29251877Speter * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30251877Speter * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31251877Speter * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32251877Speter * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33251877Speter * POSSIBILITY OF SUCH DAMAGE. 34251877Speter */ 35251877Speter 36251877Speter/** 37251877Speter * \file 38251877Speter * 39251877Speter * This file contains functions to assist the iterator module. 40251877Speter * Keep track of the donotquery addresses and lookup fast. 41251877Speter */ 42251877Speter 43251877Speter#ifndef ITERATOR_ITER_DONOTQ_H 44251877Speter#define ITERATOR_ITER_DONOTQ_H 45251877Speter#include "util/storage/dnstree.h" 46253895Speterstruct iter_env; 47253895Speterstruct config_file; 48251877Speterstruct regional; 49251877Speter 50253895Speter/** 51262339Speter * Iterator donotqueryaddresses structure 52251877Speter */ 53251877Speterstruct iter_donotq { 54251877Speter /** regional for allocation */ 55251877Speter struct regional* region; 56251877Speter /** 57251877Speter * Tree of the address spans that are blocked. 58251877Speter * contents of type addr_tree_node. Each node is an address span 59253895Speter * that must not be used to send queries to. 60253895Speter */ 61253895Speter rbtree_t tree; 62253895Speter}; 63253895Speter 64253895Speter/** 65251877Speter * Create donotqueryaddresses structure 66253895Speter * @return new structure or NULL on error. 67253895Speter */ 68251877Speterstruct iter_donotq* donotq_create(void); 69253895Speter 70253895Speter/** 71253895Speter * Delete donotqueryaddresses structure. 72253895Speter * @param donotq: to delete. 73253895Speter */ 74253895Spetervoid donotq_delete(struct iter_donotq* donotq); 75253895Speter 76253895Speter/** 77253895Speter * Process donotqueryaddresses config. 78251877Speter * @param donotq: where to store. 79251877Speter * @param cfg: config options. 80251877Speter * @return 0 on error. 81251877Speter */ 82251877Speterint donotq_apply_cfg(struct iter_donotq* donotq, struct config_file* cfg); 83251877Speter 84251877Speter/** 85253895Speter * See if an address is blocked. 86253895Speter * @param donotq: structure for address storage. 87253895Speter * @param addr: address to check 88251877Speter * @param addrlen: length of addr. 89251877Speter * @return: true if the address must not be queried. false if unlisted. 90251877Speter */ 91251877Speterint donotq_lookup(struct iter_donotq* donotq, struct sockaddr_storage* addr, 92253895Speter socklen_t addrlen); 93253895Speter 94253895Speter/** 95253895Speter * Get memory used by donotqueryaddresses structure. 96253895Speter * @param donotq: structure for address storage. 97251877Speter * @return bytes in use. 98251877Speter */ 99251877Spetersize_t donotq_get_mem(struct iter_donotq* donotq); 100251877Speter 101251877Speter#endif /* ITERATOR_ITER_DONOTQ_H */ 102251877Speter