iter_priv.h revision 249140
10SN/A/*
20SN/A * iterator/iter_priv.h - iterative resolver private address and domain store
30SN/A *
40SN/A * Copyright (c) 2008, NLnet Labs. All rights reserved.
57636SN/A *
67636SN/A * This software is open source.
77636SN/A *
87636SN/A * Redistribution and use in source and binary forms, with or without
97636SN/A * modification, are permitted provided that the following conditions
107636SN/A * are met:
117636SN/A *
127636SN/A * Redistributions of source code must retain the above copyright notice,
130SN/A * this list of conditions and the following disclaimer.
147636SN/A *
150SN/A * Redistributions in binary form must reproduce the above copyright notice,
167636SN/A * this list of conditions and the following disclaimer in the documentation
177636SN/A * and/or other materials provided with the distribution.
187636SN/A *
197636SN/A * Neither the name of the NLNET LABS nor the names of its contributors may
207636SN/A * be used to endorse or promote products derived from this software without
217636SN/A * specific prior written permission.
220SN/A *
230SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
240SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
250SN/A * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
260SN/A * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
270SN/A * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
280SN/A * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2912623Savstepan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
300SN/A * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
310SN/A * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
320SN/A * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
330SN/A * POSSIBILITY OF SUCH DAMAGE.
3412623Savstepan */
350SN/A
360SN/A/**
370SN/A * \file
380SN/A *
390SN/A * This file contains functions to assist the iterator module.
400SN/A * Keep track of the private addresses and lookup fast.
410SN/A */
420SN/A
4312623Savstepan#ifndef ITERATOR_ITER_PRIV_H
440SN/A#define ITERATOR_ITER_PRIV_H
450SN/A#include "util/rbtree.h"
460SN/A#include <ldns/buffer.h>
470SN/Astruct iter_env;
480SN/Astruct config_file;
490SN/Astruct regional;
500SN/Astruct rrset_parse;
510SN/A
520SN/A/**
530SN/A * Iterator priv structure
540SN/A */
550SN/Astruct iter_priv {
560SN/A	/** regional for allocation */
570SN/A	struct regional* region;
580SN/A	/**
590SN/A	 * Tree of the address spans that are blocked.
600SN/A	 * contents of type addr_tree_node.
610SN/A	 * No further data need, only presence or absence.
620SN/A	 */
630SN/A	rbtree_t a;
640SN/A	/**
650SN/A	 * Tree of the domains spans that are allowed to contain
660SN/A	 * the blocked address spans.
670SN/A	 * contents of type name_tree_node.
680SN/A	 * No further data need, only presence or absence.
690SN/A	 */
700SN/A	rbtree_t n;
7111099Smartin};
720SN/A
730SN/A/**
740SN/A * Create priv structure
750SN/A * @return new structure or NULL on error.
760SN/A */
770SN/Astruct iter_priv* priv_create(void);
780SN/A
790SN/A/**
800SN/A * Delete priv structure.
810SN/A * @param priv: to delete.
820SN/A */
830SN/Avoid priv_delete(struct iter_priv* priv);
840SN/A
850SN/A/**
867636SN/A * Process priv config.
877636SN/A * @param priv: where to store.
887636SN/A * @param cfg: config options.
897636SN/A * @return 0 on error.
907636SN/A */
917636SN/Aint priv_apply_cfg(struct iter_priv* priv, struct config_file* cfg);
927636SN/A
937636SN/A/**
947636SN/A * See if rrset is bad.
957636SN/A * @param priv: structure for private address storage.
967636SN/A * @param pkt: packet to decompress rrset name in.
977636SN/A * @param rrset: the rrset to examine, A or AAAA.
987636SN/A * @return true if the rrset is bad and should be removed.
997636SN/A */
1007636SN/Aint priv_rrset_bad(struct iter_priv* priv, ldns_buffer* pkt,
1017636SN/A	struct rrset_parse* rrset);
1027636SN/A
1037636SN/A/**
1047636SN/A * Get memory used by priv structure.
1057636SN/A * @param priv: structure for address storage.
1067636SN/A * @return bytes in use.
1077636SN/A */
1087636SN/Asize_t priv_get_mem(struct iter_priv* priv);
1097636SN/A
1100SN/A#endif /* ITERATOR_ITER_PRIV_H */
11112623Savstepan