iter_donotq.h revision 256281
161931Scokane/* 261931Scokane * iterator/iter_donotq.h - iterative resolver donotqueryaddresses storage. 361931Scokane * 461931Scokane * Copyright (c) 2007, NLnet Labs. All rights reserved. 561931Scokane * 661931Scokane * This software is open source. 761931Scokane * 861931Scokane * Redistribution and use in source and binary forms, with or without 961931Scokane * modification, are permitted provided that the following conditions 1061931Scokane * are met: 1161931Scokane * 1261931Scokane * Redistributions of source code must retain the above copyright notice, 1361931Scokane * this list of conditions and the following disclaimer. 1461931Scokane * 1561931Scokane * Redistributions in binary form must reproduce the above copyright notice, 1661931Scokane * this list of conditions and the following disclaimer in the documentation 1761931Scokane * and/or other materials provided with the distribution. 1861931Scokane * 1961931Scokane * Neither the name of the NLNET LABS nor the names of its contributors may 2061931Scokane * be used to endorse or promote products derived from this software without 2161931Scokane * specific prior written permission. 2261931Scokane * 2361931Scokane * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2461931Scokane * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2561931Scokane * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2661931Scokane * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 2761931Scokane * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2861931Scokane * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2961931Scokane * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 3061931Scokane * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3161931Scokane * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3261931Scokane * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3361931Scokane * POSSIBILITY OF SUCH DAMAGE. 3461911Scokane */ 3561911Scokane 3661931Scokane/** 3761911Scokane * \file 3861911Scokane * 3961911Scokane * This file contains functions to assist the iterator module. 4061911Scokane * Keep track of the donotquery addresses and lookup fast. 4161911Scokane */ 4261911Scokane 4361911Scokane#ifndef ITERATOR_ITER_DONOTQ_H 4461911Scokane#define ITERATOR_ITER_DONOTQ_H 4561911Scokane#include "util/storage/dnstree.h" 4661911Scokanestruct iter_env; 4761911Scokanestruct config_file; 4861911Scokanestruct regional; 4961911Scokane 5061911Scokane/** 5161911Scokane * Iterator donotqueryaddresses structure 5261911Scokane */ 5361911Scokanestruct iter_donotq { 5461911Scokane /** regional for allocation */ 5561911Scokane struct regional* region; 5661911Scokane /** 5761911Scokane * Tree of the address spans that are blocked. 5861911Scokane * contents of type addr_tree_node. Each node is an address span 5961911Scokane * that must not be used to send queries to. 6061911Scokane */ 6161911Scokane rbtree_t tree; 6261911Scokane}; 6361911Scokane 6461911Scokane/** 6561911Scokane * Create donotqueryaddresses structure 6661911Scokane * @return new structure or NULL on error. 6761911Scokane */ 6861911Scokanestruct iter_donotq* donotq_create(void); 6961911Scokane 7061911Scokane/** 7161911Scokane * Delete donotqueryaddresses structure. 7261911Scokane * @param donotq: to delete. 7361911Scokane */ 7461911Scokanevoid donotq_delete(struct iter_donotq* donotq); 7561911Scokane 7661911Scokane/** 7761931Scokane * Process donotqueryaddresses config. 7861931Scokane * @param donotq: where to store. 7961931Scokane * @param cfg: config options. 8061911Scokane * @return 0 on error. 8161911Scokane */ 8261911Scokaneint donotq_apply_cfg(struct iter_donotq* donotq, struct config_file* cfg); 8361911Scokane 8461911Scokane/** 8561911Scokane * See if an address is blocked. 8661911Scokane * @param donotq: structure for address storage. 8761911Scokane * @param addr: address to check 8861911Scokane * @param addrlen: length of addr. 8961911Scokane * @return: true if the address must not be queried. false if unlisted. 9061911Scokane */ 9161911Scokaneint donotq_lookup(struct iter_donotq* donotq, struct sockaddr_storage* addr, 9261911Scokane socklen_t addrlen); 9361911Scokane 9461911Scokane/** 9561911Scokane * Get memory used by donotqueryaddresses structure. 9661911Scokane * @param donotq: structure for address storage. 9761911Scokane * @return bytes in use. 9861911Scokane */ 9961911Scokanesize_t donotq_get_mem(struct iter_donotq* donotq); 10061911Scokane 10161911Scokane#endif /* ITERATOR_ITER_DONOTQ_H */ 10261911Scokane