rpz.c File Reference

#include <config.h>
#include <isc/buffer.h>
#include <isc/mem.h>
#include <isc/net.h>
#include <isc/netaddr.h>
#include <isc/print.h>
#include <isc/stdlib.h>
#include <isc/string.h>
#include <isc/util.h>
#include <dns/db.h>
#include <dns/fixedname.h>
#include <dns/log.h>
#include <dns/rdata.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#include <dns/result.h>
#include <dns/rbt.h>
#include <dns/rpz.h>
#include <dns/view.h>

Go to the source code of this file.

Data Structures

struct  dns_rpz_cidr_key_t
struct  dns_rpz_addr_zbits
struct  dns_rpz_cidr_node
struct  dns_rpz_nm_zbits
struct  dns_rpz_nm_data

Defines

#define DNS_RPZ_CIDR_WORD_BITS   ((int)sizeof(dns_rpz_cidr_word_t)*8)
#define DNS_RPZ_CIDR_KEY_BITS   ((int)sizeof(dns_rpz_cidr_key_t)*8)
#define DNS_RPZ_CIDR_WORDS   (128/DNS_RPZ_CIDR_WORD_BITS)
#define ADDR_V4MAPPED   0xffff
#define KEY_IS_IPV4(prefix, ip)
#define DNS_RPZ_WORD_MASK(b)
#define DNS_RPZ_IP_BIT(ip, n)
#define INET6_ADDRSTRLEN   46
#define SET_TRIG(n, zbit, type)

Typedefs

typedef isc_uint32_t dns_rpz_cidr_word_t
typedef struct dns_rpz_addr_zbits dns_rpz_addr_zbits_t
typedef struct dns_rpz_nm_zbits dns_rpz_nm_zbits_t
typedef struct dns_rpz_nm_data dns_rpz_nm_data_t

Functions

const char * dns_rpz_type2str (dns_rpz_type_t type)
dns_rpz_policy_t dns_rpz_str2policy (const char *str)
const char * dns_rpz_policy2str (dns_rpz_policy_t policy)
static int zbit_to_num (dns_rpz_zbits_t zbit)
static void make_addr_set (dns_rpz_addr_zbits_t *tgt_set, dns_rpz_zbits_t zbits, dns_rpz_type_t type)
static void make_nm_set (dns_rpz_nm_zbits_t *tgt_set, dns_rpz_num_t rpz_num, dns_rpz_type_t type)
static void set_sum_pair (dns_rpz_cidr_node_t *cnode)
static void fix_qname_skip_recurse (dns_rpz_zones_t *rpzs)
static void adj_trigger_cnt (dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, dns_rpz_type_t rpz_type, const dns_rpz_cidr_key_t *tgt_ip, dns_rpz_prefix_t tgt_prefix, isc_boolean_t inc)
static dns_rpz_cidr_node_tnew_node (dns_rpz_zones_t *rpzs, const dns_rpz_cidr_key_t *ip, dns_rpz_prefix_t prefix, const dns_rpz_cidr_node_t *child)
static void badname (int level, dns_name_t *name, const char *str1, const char *str2)
static isc_result_t ip2name (const dns_rpz_cidr_key_t *tgt_ip, dns_rpz_prefix_t tgt_prefix, dns_name_t *base_name, dns_name_t *ip_name)
static dns_rpz_type_t type_from_name (dns_rpz_zone_t *rpz, dns_name_t *name)
static isc_result_t name2ipkey (int log_level, const dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, dns_rpz_type_t rpz_type, dns_name_t *src_name, dns_rpz_cidr_key_t *tgt_ip, dns_rpz_prefix_t *tgt_prefix, dns_rpz_addr_zbits_t *new_set)
static void name2data (dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, dns_rpz_type_t rpz_type, const dns_name_t *src_name, dns_name_t *trig_name, dns_rpz_nm_data_t *new_data)
static int ffs_keybit (dns_rpz_cidr_word_t w)
static int diff_keys (const dns_rpz_cidr_key_t *key1, dns_rpz_prefix_t prefix1, const dns_rpz_cidr_key_t *key2, dns_rpz_prefix_t prefix2)
static dns_rpz_zbits_t trim_zbits (dns_rpz_zbits_t zbits, dns_rpz_zbits_t found)
static isc_result_t search (dns_rpz_zones_t *rpzs, const dns_rpz_cidr_key_t *tgt_ip, dns_rpz_prefix_t tgt_prefix, const dns_rpz_addr_zbits_t *tgt_set, isc_boolean_t create, dns_rpz_cidr_node_t **found)
static isc_result_t add_cidr (dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, dns_rpz_type_t rpz_type, dns_name_t *src_name)
static isc_result_t add_nm (dns_rpz_zones_t *rpzs, dns_name_t *trig_name, const dns_rpz_nm_data_t *new_data)
static isc_result_t add_name (dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, dns_rpz_type_t rpz_type, dns_name_t *src_name)
static void rpz_node_deleter (void *nm_data, void *mctx)
isc_result_t dns_rpz_new_zones (dns_rpz_zones_t **rpzsp, isc_mem_t *mctx)
static void cidr_free (dns_rpz_zones_t *rpzs)
static void rpz_detach (dns_rpz_zone_t **rpzp, dns_rpz_zones_t *rpzs)
void dns_rpz_attach_rpzs (dns_rpz_zones_t *rpzs, dns_rpz_zones_t **rpzsp)
void dns_rpz_detach_rpzs (dns_rpz_zones_t **rpzsp)
isc_result_t dns_rpz_beginload (dns_rpz_zones_t **load_rpzsp, dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num)
static void fix_triggers (dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num)
isc_result_t dns_rpz_ready (dns_rpz_zones_t *rpzs, dns_rpz_zones_t **load_rpzsp, dns_rpz_num_t rpz_num)
isc_result_t dns_rpz_add (dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, dns_name_t *src_name)
static void del_cidr (dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, dns_rpz_type_t rpz_type, dns_name_t *src_name)
static void del_name (dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, dns_rpz_type_t rpz_type, dns_name_t *src_name)
void dns_rpz_delete (dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, dns_name_t *src_name)
dns_rpz_num_t dns_rpz_find_ip (dns_rpz_zones_t *rpzs, dns_rpz_type_t rpz_type, dns_rpz_zbits_t zbits, const isc_netaddr_t *netaddr, dns_name_t *ip_name, dns_rpz_prefix_t *prefixp)
dns_rpz_zbits_t dns_rpz_find_name (dns_rpz_zones_t *rpzs, dns_rpz_type_t rpz_type, dns_rpz_zbits_t zbits, dns_name_t *trig_name)
dns_rpz_policy_t dns_rpz_decode_cname (dns_rpz_zone_t *rpz, dns_rdataset_t *rdataset, dns_name_t *selfname)


Detailed Description

Definition in file rpz.c.


Define Documentation

#define DNS_RPZ_CIDR_WORD_BITS   ((int)sizeof(dns_rpz_cidr_word_t)*8)

Definition at line 91 of file rpz.c.

Referenced by diff_keys(), ffs_keybit(), name2ipkey(), and new_node().

#define DNS_RPZ_CIDR_KEY_BITS   ((int)sizeof(dns_rpz_cidr_key_t)*8)

Definition at line 92 of file rpz.c.

Referenced by name2ipkey().

#define DNS_RPZ_CIDR_WORDS   (128/DNS_RPZ_CIDR_WORD_BITS)

Definition at line 93 of file rpz.c.

Referenced by ip2name(), name2ipkey(), and new_node().

#define ADDR_V4MAPPED   0xffff

Definition at line 98 of file rpz.c.

Referenced by dns_rpz_find_ip(), and name2ipkey().

#define KEY_IS_IPV4 ( prefix,
ip   ) 

Value:

((prefix) >= 96 && (ip)->w[0] == 0 &&   \
                                (ip)->w[1] == 0 && (ip)->w[2] == ADDR_V4MAPPED)

Definition at line 99 of file rpz.c.

Referenced by adj_trigger_cnt(), and ip2name().

#define DNS_RPZ_WORD_MASK (  ) 

Value:

((b) == 0 ? (dns_rpz_cidr_word_t)(-1)   \
                              : ((dns_rpz_cidr_word_t)(-1)              \
                                 << (DNS_RPZ_CIDR_WORD_BITS - (b))))

Definition at line 102 of file rpz.c.

Referenced by name2ipkey(), and new_node().

#define DNS_RPZ_IP_BIT ( ip,
 ) 

Value:

(1 & ((ip)->w[(n)/DNS_RPZ_CIDR_WORD_BITS] >>  \
                                    (DNS_RPZ_CIDR_WORD_BITS                 \
                                     - 1 - ((n) % DNS_RPZ_CIDR_WORD_BITS))))

Definition at line 109 of file rpz.c.

Referenced by search().

#define INET6_ADDRSTRLEN   46

Referenced by ip2name().

#define SET_TRIG ( n,
zbit,
type   ) 

Value:

if (rpzs->triggers[n].type == 0) {                              \
                rpzs->have.type &= ~zbit;                               \
        } else {                                                        \
                rpzs->total_triggers.type += rpzs->triggers[n].type;    \
                rpzs->have.type |= zbit;                                \
        }

Referenced by fix_triggers().


Typedef Documentation

typedef isc_uint32_t dns_rpz_cidr_word_t

Definition at line 90 of file rpz.c.

typedef struct dns_rpz_addr_zbits dns_rpz_addr_zbits_t

Definition at line 117 of file rpz.c.

typedef struct dns_rpz_nm_zbits dns_rpz_nm_zbits_t

Definition at line 145 of file rpz.c.

typedef struct dns_rpz_nm_data dns_rpz_nm_data_t

Definition at line 151 of file rpz.c.


Function Documentation

const char* dns_rpz_type2str ( dns_rpz_type_t  type  ) 

Definition at line 177 of file rpz.c.

References DNS_RPZ_TYPE_BAD, DNS_RPZ_TYPE_CLIENT_IP, DNS_RPZ_TYPE_IP, DNS_RPZ_TYPE_NSDNAME, DNS_RPZ_TYPE_NSIP, DNS_RPZ_TYPE_QNAME, and FATAL_ERROR.

Referenced by rpz_getdb(), rpz_log_fail(), and rpz_log_rewrite().

dns_rpz_policy_t dns_rpz_str2policy ( const char *  str  ) 

Definition at line 197 of file rpz.c.

References DNS_RPZ_POLICY_CNAME, DNS_RPZ_POLICY_DISABLED, DNS_RPZ_POLICY_DROP, DNS_RPZ_POLICY_ERROR, DNS_RPZ_POLICY_GIVEN, DNS_RPZ_POLICY_NODATA, DNS_RPZ_POLICY_NXDOMAIN, DNS_RPZ_POLICY_PASSTHRU, and DNS_RPZ_POLICY_TCP_ONLY.

Referenced by configure_rpz_zone().

const char* dns_rpz_policy2str ( dns_rpz_policy_t  policy  ) 

Definition at line 224 of file rpz.c.

References DNS_RPZ_POLICY_CNAME, DNS_RPZ_POLICY_DROP, DNS_RPZ_POLICY_MISS, DNS_RPZ_POLICY_NODATA, DNS_RPZ_POLICY_NXDOMAIN, DNS_RPZ_POLICY_PASSTHRU, DNS_RPZ_POLICY_RECORD, DNS_RPZ_POLICY_TCP_ONLY, DNS_RPZ_POLICY_WILDCNAME, INSIST, POST, and str.

Referenced by rpz_log_rewrite().

static int zbit_to_num ( dns_rpz_zbits_t  zbit  )  [static]

Definition at line 262 of file rpz.c.

References INSIST.

Referenced by dns_rpz_find_ip(), and fix_qname_skip_recurse().

static void make_addr_set ( dns_rpz_addr_zbits_t tgt_set,
dns_rpz_zbits_t  zbits,
dns_rpz_type_t  type 
) [static]

Definition at line 298 of file rpz.c.

References dns_rpz_addr_zbits::client_ip, DNS_RPZ_TYPE_CLIENT_IP, DNS_RPZ_TYPE_IP, DNS_RPZ_TYPE_NSIP, INSIST, dns_rpz_addr_zbits::ip, and dns_rpz_addr_zbits::nsip.

Referenced by dns_rpz_find_ip(), and name2ipkey().

static void make_nm_set ( dns_rpz_nm_zbits_t tgt_set,
dns_rpz_num_t  rpz_num,
dns_rpz_type_t  type 
) [static]

Definition at line 324 of file rpz.c.

References DNS_RPZ_TYPE_NSDNAME, DNS_RPZ_TYPE_QNAME, DNS_RPZ_ZBIT, INSIST, dns_rpz_nm_zbits::ns, and dns_rpz_nm_zbits::qname.

Referenced by name2data().

static void set_sum_pair ( dns_rpz_cidr_node_t cnode  )  [static]

Definition at line 346 of file rpz.c.

References dns_rpz_cidr_node::child, dns_rpz_addr_zbits::client_ip, dns_rpz_addr_zbits::ip, dns_rpz_addr_zbits::nsip, dns_rpz_cidr_node::parent, dns_rpz_cidr_node::set, and dns_rpz_cidr_node::sum.

Referenced by del_cidr(), and search().

static void fix_qname_skip_recurse ( dns_rpz_zones_t rpzs  )  [static]

Definition at line 377 of file rpz.c.

References dns_rpz_zones::client_ip, dns_rpz_zones::client_ipv4, dns_rpz_zones::client_ipv6, DNS_RPZ_ALL_ZBITS, DNS_RPZ_ZMASK, dns_rpz_zones::have, dns_rpz_zones::ip, dns_rpz_zones::ipv4, dns_rpz_zones::ipv6, dns_rpz_zones::nsdname, dns_rpz_zones::nsip, dns_rpz_zones::nsipv4, dns_rpz_zones::nsipv6, dns_rpz_zones::p, dns_rpz_zones::qname_skip_recurse, dns_rpz_zones::qname_wait_recurse, and zbit_to_num().

Referenced by adj_trigger_cnt(), and fix_triggers().

static void adj_trigger_cnt ( dns_rpz_zones_t rpzs,
dns_rpz_num_t  rpz_num,
dns_rpz_type_t  rpz_type,
const dns_rpz_cidr_key_t tgt_ip,
dns_rpz_prefix_t  tgt_prefix,
isc_boolean_t  inc 
) [static]

Definition at line 405 of file rpz.c.

References dns_rpz_zones::client_ipv4, dns_rpz_triggers::client_ipv4, dns_rpz_zones::client_ipv6, dns_rpz_triggers::client_ipv6, DNS_RPZ_TYPE_CLIENT_IP, DNS_RPZ_TYPE_IP, DNS_RPZ_TYPE_NSDNAME, DNS_RPZ_TYPE_NSIP, DNS_RPZ_TYPE_QNAME, DNS_RPZ_ZBIT, fix_qname_skip_recurse(), dns_rpz_zones::have, INSIST, dns_rpz_zones::ipv4, dns_rpz_triggers::ipv4, dns_rpz_zones::ipv6, dns_rpz_triggers::ipv6, KEY_IS_IPV4, dns_rpz_zones::nsdname, dns_rpz_triggers::nsdname, dns_rpz_zones::nsipv4, dns_rpz_triggers::nsipv4, dns_rpz_zones::nsipv6, dns_rpz_triggers::nsipv6, dns_rpz_zones::qname, dns_rpz_triggers::qname, REQUIRE, and dns_rpz_zones::triggers.

Referenced by add_cidr(), add_name(), del_cidr(), and del_name().

static dns_rpz_cidr_node_t* new_node ( dns_rpz_zones_t rpzs,
const dns_rpz_cidr_key_t ip,
dns_rpz_prefix_t  prefix,
const dns_rpz_cidr_node_t child 
) [static]

Definition at line 471 of file rpz.c.

References DNS_RPZ_CIDR_WORD_BITS, DNS_RPZ_CIDR_WORDS, DNS_RPZ_WORD_MASK, isc_mem_get, dns_rpz_zones::mctx, dns_rpz_cidr_node::sum, and dns_rpz_cidr_key_t::w.

Referenced by dns_iptable_merge(), isc_radix_insert(), and search().

static void badname ( int  level,
dns_name_t name,
const char *  str1,
const char *  str2 
) [static]

Definition at line 505 of file rpz.c.

References dns_lctx, DNS_LOGCATEGORY_RPZ, DNS_LOGMODULE_RBTDB, dns_name_format(), DNS_NAME_FORMATSIZE, DNS_RPZ_DEBUG_QUIET, isc_log_wouldlog(), isc_log_write(), and namebuf.

Referenced by name2ipkey().

static isc_result_t ip2name ( const dns_rpz_cidr_key_t tgt_ip,
dns_rpz_prefix_t  tgt_prefix,
dns_name_t base_name,
dns_name_t ip_name 
) [static]

Definition at line 527 of file rpz.c.

References buffer, dns_name_fromtext(), DNS_RPZ_CIDR_WORDS, INET6_ADDRSTRLEN, INSIST, isc_buffer_add, isc_buffer_init, ISC_FALSE, ISC_R_FAILURE, ISC_TRUE, KEY_IS_IPV4, str, dns_rpz_cidr_key_t::w, and zeros.

Referenced by dns_rpz_find_ip(), and name2ipkey().

static dns_rpz_type_t type_from_name ( dns_rpz_zone_t rpz,
dns_name_t name 
) [static]

Definition at line 597 of file rpz.c.

References dns_rpz_zone::client_ip, dns_name_issubdomain(), DNS_RPZ_TYPE_CLIENT_IP, DNS_RPZ_TYPE_IP, DNS_RPZ_TYPE_NSDNAME, DNS_RPZ_TYPE_NSIP, DNS_RPZ_TYPE_QNAME, dns_rpz_zone::ip, dns_rpz_zone::nsdname, and dns_rpz_zone::nsip.

Referenced by dns_rpz_add(), and dns_rpz_delete().

static isc_result_t name2ipkey ( int  log_level,
const dns_rpz_zones_t rpzs,
dns_rpz_num_t  rpz_num,
dns_rpz_type_t  rpz_type,
dns_name_t src_name,
dns_rpz_cidr_key_t tgt_ip,
dns_rpz_prefix_t tgt_prefix,
dns_rpz_addr_zbits_t new_set 
) [static]

Definition at line 624 of file rpz.c.

References ADDR_V4MAPPED, badname(), dns_fixedname_init, dns_fixedname_name, dns_name_countlabels(), dns_name_equal(), dns_name_format(), DNS_NAME_FORMATSIZE, dns_name_getlabelsequence(), dns_name_init(), DNS_RPZ_CIDR_KEY_BITS, DNS_RPZ_CIDR_WORD_BITS, DNS_RPZ_CIDR_WORDS, DNS_RPZ_TYPE_QNAME, DNS_RPZ_WORD_MASK, DNS_RPZ_ZBIT, ip2name(), ISC_R_FAILURE, ISC_R_SUCCESS, make_addr_set(), dns_rpz_zone::nsdname, dns_rpz_zones::num_zones, dns_rpz_zone::origin, REQUIRE, dns_rpz_cidr_key_t::w, and dns_rpz_zones::zones.

Referenced by add_cidr(), and del_cidr().

static void name2data ( dns_rpz_zones_t rpzs,
dns_rpz_num_t  rpz_num,
dns_rpz_type_t  rpz_type,
const dns_name_t src_name,
dns_name_t trig_name,
dns_rpz_nm_data_t new_data 
) [static]

Definition at line 789 of file rpz.c.

References dns_name_concatenate(), dns_name_countlabels(), dns_name_getlabelsequence(), dns_name_init(), dns_name_iswildcard(), dns_rootname, DNS_RPZ_TYPE_QNAME, make_nm_set(), dns_rpz_zone::nsdname, dns_rpz_zones::num_zones, dns_rpz_zone::origin, REQUIRE, dns_rpz_nm_data::set, dns_rpz_nm_data::wild, and dns_rpz_zones::zones.

Referenced by add_name(), and del_name().

static int ffs_keybit ( dns_rpz_cidr_word_t  w  )  [inline, static]

Definition at line 832 of file rpz.c.

References DNS_RPZ_CIDR_WORD_BITS.

Referenced by diff_keys().

static int diff_keys ( const dns_rpz_cidr_key_t key1,
dns_rpz_prefix_t  prefix1,
const dns_rpz_cidr_key_t key2,
dns_rpz_prefix_t  prefix2 
) [static]

Definition at line 861 of file rpz.c.

References DNS_RPZ_CIDR_WORD_BITS, ffs_keybit(), ISC_MIN, and dns_rpz_cidr_key_t::w.

Referenced by search().

static dns_rpz_zbits_t trim_zbits ( dns_rpz_zbits_t  zbits,
dns_rpz_zbits_t  found 
) [inline, static]

Definition at line 891 of file rpz.c.

Referenced by search().

static isc_result_t search ( dns_rpz_zones_t rpzs,
const dns_rpz_cidr_key_t tgt_ip,
dns_rpz_prefix_t  tgt_prefix,
const dns_rpz_addr_zbits_t tgt_set,
isc_boolean_t  create,
dns_rpz_cidr_node_t **  found 
) [static]

Definition at line 913 of file rpz.c.

References dns_rpz_cidr_node::child, dns_rpz_zones::cidr, dns_rpz_addr_zbits::client_ip, diff_keys(), DNS_R_PARTIALMATCH, DNS_RPZ_IP_BIT, dns_rpz_cidr_node::ip, dns_rpz_addr_zbits::ip, isc_mem_put, ISC_R_EXISTS, ISC_R_NOMEMORY, ISC_R_NOTFOUND, ISC_R_SUCCESS, dns_rpz_zones::mctx, new_node(), dns_rpz_addr_zbits::nsip, dns_rpz_cidr_node::parent, dns_rpz_cidr_node::prefix, dns_rpz_cidr_node::set, set_sum_pair(), dns_rpz_cidr_node::sum, and trim_zbits().

Referenced by add_cidr(), cache_find(), cache_findzonecut(), cache_zonecut_callback(), clear_searchlist(), configure_view(), create_search_list(), del_cidr(), dns_rpz_find_ip(), dns_rpz_ready(), findext(), make_searchlist_entry(), next_origin(), ns_lwdmanager_create(), send_tcp_connect(), set_search_domain(), zone_find(), and zone_zonecut_callback().

static isc_result_t add_cidr ( dns_rpz_zones_t rpzs,
dns_rpz_num_t  rpz_num,
dns_rpz_type_t  rpz_type,
dns_name_t src_name 
) [static]

Definition at line 1096 of file rpz.c.

References adj_trigger_cnt(), dns_lctx, DNS_LOGCATEGORY_RPZ, DNS_LOGMODULE_RBTDB, dns_name_format(), DNS_NAME_FORMATSIZE, DNS_RPZ_ERROR_LEVEL, isc_log_write(), ISC_R_EXISTS, ISC_R_SUCCESS, isc_result_totext(), ISC_TRUE, name2ipkey(), namebuf, and search().

Referenced by dns_rpz_add().

static isc_result_t add_nm ( dns_rpz_zones_t rpzs,
dns_name_t trig_name,
const dns_rpz_nm_data_t new_data 
) [static]

Definition at line 1140 of file rpz.c.

References dns_rbtnode::data, dns_rbt_addnode(), isc_mem_get, ISC_R_EXISTS, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_rpz_zones::mctx, dns_rpz_nm_zbits::ns, dns_rpz_nm_zbits::qname, dns_rpz_zones::rbt, dns_rpz_nm_data::set, and dns_rpz_nm_data::wild.

Referenced by add_name(), and dns_rpz_ready().

static isc_result_t add_name ( dns_rpz_zones_t rpzs,
dns_rpz_num_t  rpz_num,
dns_rpz_type_t  rpz_type,
dns_name_t src_name 
) [static]

Definition at line 1183 of file rpz.c.

References add_nm(), adj_trigger_cnt(), dns_fixedname_init, dns_fixedname_name, ISC_R_EXISTS, ISC_R_SUCCESS, ISC_TRUE, name2data(), dns_rpz_zones::num_zones, and dns_rpz_zones::p.

Referenced by addonlevel(), dns_rbt_addnode(), and dns_rpz_add().

static void rpz_node_deleter ( void *  nm_data,
void *  mctx 
) [static]

Definition at line 1220 of file rpz.c.

References isc_mem_put.

Referenced by dns_rpz_new_zones().

isc_result_t dns_rpz_new_zones ( dns_rpz_zones_t **  rpzsp,
isc_mem_t mctx 
)

Definition at line 1228 of file rpz.c.

References DESTROYLOCK, dns_rbt_create(), isc_mem_attach(), isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_refcount_decrement, isc_refcount_destroy, isc_refcount_init(), REQUIRE, and rpz_node_deleter().

Referenced by configure_rpz(), and dns_rpz_beginload().

static void cidr_free ( dns_rpz_zones_t rpzs  )  [static]

Definition at line 1282 of file rpz.c.

References dns_rpz_cidr_node::child, dns_rpz_zones::cidr, isc_mem_put, dns_rpz_zones::mctx, and dns_rpz_cidr_node::parent.

Referenced by dns_rpz_detach_rpzs().

static void rpz_detach ( dns_rpz_zone_t **  rpzp,
dns_rpz_zones_t rpzs 
) [static]

Definition at line 1315 of file rpz.c.

References dns_rpz_zone::client_ip, dns_rpz_zone::cname, dns_name_dynamic(), dns_name_free(), dns_rpz_zone::drop, dns_rpz_zone::ip, isc_mem_put, isc_refcount_decrement, isc_refcount_destroy, dns_rpz_zones::mctx, dns_rpz_zone::nsdname, dns_rpz_zone::nsip, dns_rpz_zone::origin, dns_rpz_zone::passthru, dns_rpz_zone::refs, and dns_rpz_zone::tcp_only.

Referenced by dns_rpz_detach_rpzs().

void dns_rpz_attach_rpzs ( dns_rpz_zones_t rpzs,
dns_rpz_zones_t **  rpzsp 
)

Definition at line 1349 of file rpz.c.

References isc_refcount_increment, dns_rpz_zones::refs, and REQUIRE.

Referenced by configure_rpz(), dns_rpz_beginload(), dns_zone_rpz_enable(), and rpz_attach().

void dns_rpz_detach_rpzs ( dns_rpz_zones_t **  rpzsp  ) 

Definition at line 1359 of file rpz.c.

References cidr_free(), DESTROYLOCK, dns_rbt_destroy(), DNS_RPZ_MAX_ZONES, isc_mem_putanddetach, isc_refcount_decrement, isc_refcount_destroy, dns_rpz_zones::maint_lock, dns_rpz_zones::mctx, dns_rpz_zones::rbt, dns_rpz_zones::refs, REQUIRE, rpz_detach(), dns_rpz_zones::search_lock, and dns_rpz_zones::zones.

Referenced by configure_rpz(), destroy(), dns_rpz_ready(), free_rbtdb(), and zone_free().

isc_result_t dns_rpz_beginload ( dns_rpz_zones_t **  load_rpzsp,
dns_rpz_zones_t rpzs,
dns_rpz_num_t  rpz_num 
)

Definition at line 1397 of file rpz.c.

References dns_rpz_attach_rpzs(), dns_rpz_new_zones(), DNS_RPZ_ZBIT, ISC_R_SUCCESS, isc_refcount_increment, dns_rpz_zones::load_begun, LOCK, dns_rpz_zones::maint_lock, dns_rpz_zones::mctx, dns_rpz_zones::num_zones, dns_rpz_zones::p, dns_rpz_zone::refs, REQUIRE, dns_rpz_zones::search_lock, dns_rpz_zones::total_triggers, dns_rpz_zones::triggers, UNLOCK, and dns_rpz_zones::zones.

Referenced by beginload().

static void fix_triggers ( dns_rpz_zones_t rpzs,
dns_rpz_num_t  rpz_num 
) [static]

Definition at line 1461 of file rpz.c.

References dns_lctx, DNS_LOGCATEGORY_RPZ, DNS_LOGMODULE_RBTDB, dns_name_format(), DNS_NAME_FORMATSIZE, DNS_RPZ_INFO_LEVEL, DNS_RPZ_ZBIT, fix_qname_skip_recurse(), dns_rpz_triggers::ipv4, dns_rpz_triggers::ipv6, isc_log_write(), namebuf, dns_rpz_triggers::nsdname, dns_rpz_triggers::nsipv4, dns_rpz_triggers::nsipv6, dns_rpz_zones::num_zones, dns_rpz_zone::origin, dns_rpz_zones::p, dns_rpz_triggers::qname, SET_TRIG, dns_rpz_zones::total_triggers, and dns_rpz_zones::zones.

Referenced by dns_rpz_ready().

isc_result_t dns_rpz_ready ( dns_rpz_zones_t rpzs,
dns_rpz_zones_t **  load_rpzsp,
dns_rpz_num_t  rpz_num 
)

Definition at line 1514 of file rpz.c.

References add_nm(), dns_rpz_cidr_node::child, dns_rpz_zones::cidr, dns_rpz_addr_zbits::client_ip, dns_rbtnode::data, dns_fixedname_init, dns_fixedname_name, dns_lctx, DNS_LOGCATEGORY_RPZ, DNS_LOGMODULE_RBTDB, dns_name_concatenate(), DNS_R_NEWORIGIN, dns_rbtnodechain_current(), dns_rbtnodechain_first(), dns_rbtnodechain_init(), dns_rbtnodechain_next(), dns_rpz_detach_rpzs(), DNS_RPZ_ERROR_LEVEL, DNS_RPZ_ZBIT, fix_triggers(), dns_rpz_zones::have, INSIST, dns_rpz_cidr_node::ip, dns_rpz_addr_zbits::ip, isc_log_write(), ISC_R_NOMEMORY, ISC_R_NOMORE, ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_result_totext(), ISC_TRUE, LOCK, dns_rpz_zones::maint_lock, name, dns_rpz_nm_zbits::ns, dns_rpz_addr_zbits::nsip, dns_rpz_zones::num_zones, origin, dns_rpz_zones::p, dns_rpz_cidr_node::parent, dns_rpz_cidr_node::prefix, dns_rpz_nm_zbits::qname, dns_rpz_zones::rbt, search(), dns_rpz_zones::search_lock, dns_rpz_nm_data::set, dns_rpz_cidr_node::set, dns_rpz_zones::total_triggers, UNLOCK, and dns_rpz_nm_data::wild.

Referenced by rpz_ready().

isc_result_t dns_rpz_add ( dns_rpz_zones_t rpzs,
dns_rpz_num_t  rpz_num,
dns_name_t src_name 
)

Definition at line 1677 of file rpz.c.

References add_cidr(), add_name(), DNS_RPZ_TYPE_BAD, DNS_RPZ_TYPE_CLIENT_IP, DNS_RPZ_TYPE_IP, DNS_RPZ_TYPE_NSDNAME, DNS_RPZ_TYPE_NSIP, DNS_RPZ_TYPE_QNAME, ISC_R_FAILURE, LOCK, dns_rpz_zones::maint_lock, dns_rpz_zones::num_zones, REQUIRE, dns_rpz_zones::search_lock, type_from_name(), UNLOCK, and dns_rpz_zones::zones.

Referenced by findnodeintree(), and loadnode().

static void del_cidr ( dns_rpz_zones_t rpzs,
dns_rpz_num_t  rpz_num,
dns_rpz_type_t  rpz_type,
dns_name_t src_name 
) [static]

Definition at line 1715 of file rpz.c.

References adj_trigger_cnt(), dns_rpz_cidr_node::child, dns_rpz_zones::cidr, dns_rpz_addr_zbits::client_ip, DNS_R_PARTIALMATCH, DNS_RPZ_DEBUG_QUIET, INSIST, dns_rpz_addr_zbits::ip, ISC_FALSE, isc_mem_put, ISC_R_NOTFOUND, ISC_R_SUCCESS, dns_rpz_zones::mctx, name2ipkey(), dns_rpz_addr_zbits::nsip, dns_rpz_cidr_node::parent, search(), dns_rpz_cidr_node::set, and set_sum_pair().

Referenced by dns_rpz_delete().

static void del_name ( dns_rpz_zones_t rpzs,
dns_rpz_num_t  rpz_num,
dns_rpz_type_t  rpz_type,
dns_name_t src_name 
) [static]

Definition at line 1802 of file rpz.c.

References adj_trigger_cnt(), dns_rbtnode::data, dns_fixedname_init, dns_fixedname_name, dns_lctx, DNS_LOGCATEGORY_RPZ, DNS_LOGMODULE_RBTDB, dns_name_format(), DNS_NAME_FORMATSIZE, DNS_R_PARTIALMATCH, dns_rbt_deletenode(), dns_rbt_findnode(), DNS_RPZ_ERROR_LEVEL, INSIST, ISC_FALSE, isc_log_write(), ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_result_totext(), name2data(), namebuf, dns_rpz_nm_zbits::ns, dns_rpz_zones::num_zones, dns_rpz_zones::p, dns_rpz_nm_zbits::qname, dns_rpz_zones::rbt, dns_rpz_nm_data::set, and dns_rpz_nm_data::wild.

Referenced by dns_rpz_delete().

void dns_rpz_delete ( dns_rpz_zones_t rpzs,
dns_rpz_num_t  rpz_num,
dns_name_t src_name 
)

Definition at line 1884 of file rpz.c.

References del_cidr(), del_name(), DNS_RPZ_TYPE_BAD, DNS_RPZ_TYPE_CLIENT_IP, DNS_RPZ_TYPE_IP, DNS_RPZ_TYPE_NSDNAME, DNS_RPZ_TYPE_NSIP, DNS_RPZ_TYPE_QNAME, LOCK, dns_rpz_zones::maint_lock, dns_rpz_zones::num_zones, REQUIRE, dns_rpz_zones::search_lock, type_from_name(), UNLOCK, and dns_rpz_zones::zones.

Referenced by delete_node(), and loadnode().

dns_rpz_num_t dns_rpz_find_ip ( dns_rpz_zones_t rpzs,
dns_rpz_type_t  rpz_type,
dns_rpz_zbits_t  zbits,
const isc_netaddr_t netaddr,
dns_name_t ip_name,
dns_rpz_prefix_t prefixp 
)

Definition at line 1925 of file rpz.c.

References ADDR_V4MAPPED, AF_INET6, dns_rpz_addr_zbits::client_ip, dns_rpz_zones::client_ipv4, dns_rpz_zones::client_ipv6, dns_lctx, DNS_LOGCATEGORY_RPZ, DNS_LOGMODULE_RBTDB, dns_rootname, DNS_RPZ_ERROR_LEVEL, DNS_RPZ_INVALID_NUM, DNS_RPZ_TYPE_CLIENT_IP, DNS_RPZ_TYPE_IP, DNS_RPZ_TYPE_NSIP, isc_netaddr::family, dns_rpz_zones::have, isc_netaddr::in, isc_netaddr::in6, INSIST, dns_rpz_cidr_node::ip, dns_rpz_addr_zbits::ip, ip2name(), dns_rpz_zones::ipv4, dns_rpz_zones::ipv6, ISC_FALSE, isc_log_write(), ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_result_totext(), LOCK, make_addr_set(), dns_rpz_addr_zbits::nsip, dns_rpz_zones::nsipv4, dns_rpz_zones::nsipv6, dns_rpz_cidr_node::prefix, search(), dns_rpz_zones::search_lock, dns_rpz_cidr_node::set, isc_netaddr::type, UNLOCK, dns_rpz_cidr_key_t::w, and zbit_to_num().

Referenced by rpz_rewrite_ip().

dns_rpz_zbits_t dns_rpz_find_name ( dns_rpz_zones_t rpzs,
dns_rpz_type_t  rpz_type,
dns_rpz_zbits_t  zbits,
dns_name_t trig_name 
)

Definition at line 2041 of file rpz.c.

References dns_rbtnode::data, dns_lctx, DNS_LOGCATEGORY_RPZ, DNS_LOGMODULE_RBTDB, dns_name_format(), DNS_NAME_FORMATSIZE, DNS_R_PARTIALMATCH, dns_rbt_findnode(), DNS_RBTFIND_EMPTYDATA, DNS_RPZ_ERROR_LEVEL, DNS_RPZ_TYPE_QNAME, isc_log_write(), ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_result_totext(), LOCK, namebuf, dns_rpz_nm_zbits::ns, dns_rbtnode::parent, dns_rpz_nm_zbits::qname, dns_rpz_zones::rbt, dns_rpz_zones::search_lock, dns_rpz_nm_data::set, UNLOCK, and dns_rpz_nm_data::wild.

Referenced by rpz_rewrite_name().

dns_rpz_policy_t dns_rpz_decode_cname ( dns_rpz_zone_t rpz,
dns_rdataset_t rdataset,
dns_name_t selfname 
)

Definition at line 2107 of file rpz.c.

References dns_name_countlabels(), dns_name_equal(), dns_name_iswildcard(), DNS_RDATA_INIT, dns_rdata_reset(), dns_rdata_tostruct(), dns_rdataset_current(), dns_rdataset_first(), dns_rootname, DNS_RPZ_POLICY_DROP, DNS_RPZ_POLICY_NODATA, DNS_RPZ_POLICY_NXDOMAIN, DNS_RPZ_POLICY_PASSTHRU, DNS_RPZ_POLICY_RECORD, DNS_RPZ_POLICY_TCP_ONLY, DNS_RPZ_POLICY_WILDCNAME, dns_rpz_zone::drop, INSIST, ISC_R_SUCCESS, dns_rpz_zone::passthru, and dns_rpz_zone::tcp_only.

Referenced by rpz_find_p().


Generated on Tue Apr 28 17:41:13 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha