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