1/* 2 * Copyright (C) 2007 Internet Systems Consortium, Inc. ("ISC") 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 10 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 14 * PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17/* $Id: iptable.h,v 1.4 2007/09/14 01:46:05 marka Exp $ */ 18 19#ifndef DNS_IPTABLE_H 20#define DNS_IPTABLE_H 1 21 22#include <isc/lang.h> 23#include <isc/magic.h> 24#include <isc/radix.h> 25 26struct dns_iptable { 27 unsigned int magic; 28 isc_mem_t *mctx; 29 isc_refcount_t refcount; 30 isc_radix_tree_t *radix; 31 ISC_LINK(dns_iptable_t) nextincache; 32}; 33 34#define DNS_IPTABLE_MAGIC ISC_MAGIC('T','a','b','l') 35#define DNS_IPTABLE_VALID(a) ISC_MAGIC_VALID(a, DNS_IPTABLE_MAGIC) 36 37/*** 38 *** Functions 39 ***/ 40 41ISC_LANG_BEGINDECLS 42 43isc_result_t 44dns_iptable_create(isc_mem_t *mctx, dns_iptable_t **target); 45/* 46 * Create a new IP table and the underlying radix structure 47 */ 48 49isc_result_t 50dns_iptable_addprefix(dns_iptable_t *tab, isc_netaddr_t *addr, 51 isc_uint16_t bitlen, isc_boolean_t pos); 52/* 53 * Add an IP prefix to an existing IP table 54 */ 55 56isc_result_t 57dns_iptable_merge(dns_iptable_t *tab, dns_iptable_t *source, isc_boolean_t pos); 58/* 59 * Merge one IP table into another one. 60 */ 61 62void 63dns_iptable_attach(dns_iptable_t *source, dns_iptable_t **target); 64 65void 66dns_iptable_detach(dns_iptable_t **tabp); 67 68ISC_LANG_ENDDECLS 69 70#endif /* DNS_IPTABLE_H */ 71