Home | History | Annotate | Line # | Download | only in dns
      1 /*	$NetBSD: iptable.h,v 1.1 2024/02/18 20:57:36 christos Exp $	*/
      2 
      3 /*
      4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
      5  *
      6  * SPDX-License-Identifier: MPL-2.0
      7  *
      8  * This Source Code Form is subject to the terms of the Mozilla Public
      9  * License, v. 2.0. If a copy of the MPL was not distributed with this
     10  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
     11  *
     12  * See the COPYRIGHT file distributed with this work for additional
     13  * information regarding copyright ownership.
     14  */
     15 
     16 #ifndef DNS_IPTABLE_H
     17 #define DNS_IPTABLE_H 1
     18 
     19 #include <inttypes.h>
     20 #include <stdbool.h>
     21 
     22 #include <isc/lang.h>
     23 #include <isc/magic.h>
     24 #include <isc/radix.h>
     25 
     26 #include <dns/types.h>
     27 
     28 struct dns_iptable {
     29 	unsigned int	  magic;
     30 	isc_mem_t	 *mctx;
     31 	isc_refcount_t	  refcount;
     32 	isc_radix_tree_t *radix;
     33 	ISC_LINK(dns_iptable_t) nextincache;
     34 };
     35 
     36 #define DNS_IPTABLE_MAGIC    ISC_MAGIC('T', 'a', 'b', 'l')
     37 #define DNS_IPTABLE_VALID(a) ISC_MAGIC_VALID(a, DNS_IPTABLE_MAGIC)
     38 
     39 /***
     40  *** Functions
     41  ***/
     42 
     43 ISC_LANG_BEGINDECLS
     44 
     45 isc_result_t
     46 dns_iptable_create(isc_mem_t *mctx, dns_iptable_t **target);
     47 /*
     48  * Create a new IP table and the underlying radix structure
     49  */
     50 
     51 isc_result_t
     52 dns_iptable_addprefix(dns_iptable_t *tab, const isc_netaddr_t *addr,
     53 		      uint16_t bitlen, bool pos);
     54 /*
     55  * Add an IP prefix to an existing IP table
     56  */
     57 
     58 isc_result_t
     59 dns_iptable_merge(dns_iptable_t *tab, dns_iptable_t *source, bool pos);
     60 /*
     61  * Merge one IP table into another one.
     62  */
     63 
     64 void
     65 dns_iptable_attach(dns_iptable_t *source, dns_iptable_t **target);
     66 
     67 void
     68 dns_iptable_detach(dns_iptable_t **tabp);
     69 
     70 ISC_LANG_ENDDECLS
     71 
     72 #endif /* DNS_IPTABLE_H */
     73