acl.h revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 1999-2002, 2004-2007, 2009, 2011, 2013, 2014, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: acl.h,v 1.35 2011/06/17 23:47:49 tbox Exp $ */
#ifndef DNS_ACL_H
#define DNS_ACL_H 1
/*****
***** Module Info
*****/
* \brief
* Address match list handling.
*/
/***
*** Imports
***/
#include <isc/refcount.h>
#ifdef HAVE_GEOIP
#endif
#ifdef HAVE_GEOIP
#include <GeoIP.h>
#endif
/***
*** Types
***/
typedef enum {
#ifdef HAVE_GEOIP
#endif /* HAVE_GEOIP */
typedef struct dns_aclipprefix dns_aclipprefix_t;
struct dns_aclipprefix {
unsigned int prefixlen;
};
struct dns_aclelement {
#ifdef HAVE_GEOIP
#endif /* HAVE_GEOIP */
int node_num;
};
struct dns_acl {
unsigned int magic;
unsigned int alloc; /*%< Elements allocated */
unsigned int length; /*%< Elements initialized */
char *name; /*%< Temporary use only */
};
struct dns_aclenv {
#ifdef HAVE_GEOIP
#endif
};
/***
*** Functions
***/
/*%<
* Create a new ACL, including an IP table and an array with room
* for 'n' ACL elements. The elements are uninitialized and the
* length is 0.
*/
/*%<
* Create a new ACL that matches everything.
*/
/*%<
* Create a new ACL that matches nothing.
*/
/*%<
* Test whether ACL is set to "{ any; }"
*/
/*%<
* Test whether ACL is set to "{ none; }"
*/
/*%<
* Merge the contents of one ACL into another. Call dns_iptable_merge()
* for the IP tables, then concatenate the element arrays.
*
* If pos is set to false, then the nested ACL is to be negated. This
* means reverse the sense of each *positive* element or IP table node,
* but leave negatives alone, so as to prevent a double-negative causing
* an unexpected positive match in the parent ACL.
*/
void
/*%<
* Attach to acl 'source'.
*
* Requires:
*\li 'source' to be a valid acl.
*\li 'target' to be non NULL and '*target' to be NULL.
*/
void
/*%<
* Detach the acl. On final detach the acl must not be linked on any
* list.
*
* Requires:
*\li '*aclp' to be a valid acl.
*
* Insists:
*\li '*aclp' is not linked on final detach.
*/
dns_acl_isinsecure(const dns_acl_t *a);
/*%<
* Return #ISC_TRUE iff the acl 'a' is considered insecure, that is,
* if it contains IP addresses other than those of the local host.
* This is intended for applications such as printing warning
* messages for suspect ACLs; it is not intended for making access
* control decisions. We make no guarantee that an ACL for which
* this function returns #ISC_FALSE is safe.
*/
/*%<
* Initialize ACL environment, setting up localhost and localnets ACLs
*/
void
void
const dns_name_t *reqsigner,
const dns_aclenv_t *env,
int *match,
const dns_aclelement_t **matchelt);
const dns_name_t *reqsigner,
const isc_netaddr_t *ecs,
const dns_aclenv_t *env,
int *match,
const dns_aclelement_t **matchelt);
/*%<
* General, low-level ACL matching. This is expected to
* be useful even for weird stuff like the topology and sortlist statements.
*
* Match the address 'reqaddr', and optionally the key name 'reqsigner',
* and optionally the client prefix 'ecs' of length 'ecslen'
* (reported via EDNS client subnet option) against 'acl'.
*
* 'reqsigner' and 'ecs' may be NULL. If an ACL matches against 'ecs'
* and 'ecslen', then 'scope' will be set to indicate the netmask that
* matched.
*
* If there is a match, '*match' will be set to an integer whose absolute
* value corresponds to the order in which the matching value was inserted
* into the ACL. For a positive match, this value will be positive; for a
* negative match, it will be negative.
*
* If there is no match, *match will be set to zero.
*
* If there is a match in the element list (either positive or negative)
* and 'matchelt' is non-NULL, *matchelt will be pointed to the matching
* element.
*
* 'env' points to the current ACL environment, including the
* current values of localhost and localnets and (if applicable)
* the GeoIP context.
*
* Returns:
*\li #ISC_R_SUCCESS Always succeeds.
*/
const dns_name_t *reqsigner,
const dns_aclelement_t *e,
const dns_aclenv_t *env,
const dns_aclelement_t **matchelt);
const dns_name_t *reqsigner,
const isc_netaddr_t *ecs,
const dns_aclelement_t *e,
const dns_aclenv_t *env,
const dns_aclelement_t **matchelt);
/*%<
* Like dns_acl_match, but matches against the single ACL element 'e'
* rather than a complete ACL, and returns ISC_TRUE iff it matched.
*
* To determine whether the match was positive or negative, the
* caller should examine e->negative. Since the element 'e' may be
* a reference to a named ACL or a nested ACL, a matching element
* returned through 'matchelt' is not necessarily 'e' itself.
*/
#endif /* DNS_ACL_H */