2 * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: ssu.h,v 1.21 2007/06/19 23:47:17 tbox Exp $ */
23 /*! \file dns/ssu.h */
27 #include <dns/types.h>
31 #define DNS_SSUMATCHTYPE_NAME 0
32 #define DNS_SSUMATCHTYPE_SUBDOMAIN 1
33 #define DNS_SSUMATCHTYPE_WILDCARD 2
34 #define DNS_SSUMATCHTYPE_SELF 3
35 #define DNS_SSUMATCHTYPE_SELFSUB 4
36 #define DNS_SSUMATCHTYPE_SELFWILD 5
37 #define DNS_SSUMATCHTYPE_SELFKRB5 6
38 #define DNS_SSUMATCHTYPE_SELFMS 7
39 #define DNS_SSUMATCHTYPE_SUBDOMAINMS 8
40 #define DNS_SSUMATCHTYPE_SUBDOMAINKRB5 9
41 #define DNS_SSUMATCHTYPE_MAX 9 /* max value */
44 dns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **table);
46 * Creates a table that will be used to store simple-secure-update rules.
47 * Note: all locking must be provided by the client.
50 *\li 'mctx' is a valid memory context
51 *\li 'table' is not NULL, and '*table' is NULL
59 dns_ssutable_attach(dns_ssutable_t *source, dns_ssutable_t **targetp);
61 * Attach '*targetp' to 'source'.
64 *\li 'source' is a valid SSU table
65 *\li 'targetp' points to a NULL dns_ssutable_t *.
68 *\li *targetp is attached to source.
72 dns_ssutable_detach(dns_ssutable_t **tablep);
74 * Detach '*tablep' from its simple-secure-update rule table.
77 *\li 'tablep' points to a valid dns_ssutable_t
81 *\li If '*tablep' is the last reference to the SSU table, all
82 * resources used by the table will be freed.
86 dns_ssutable_addrule(dns_ssutable_t *table, isc_boolean_t grant,
87 dns_name_t *identity, unsigned int matchtype,
88 dns_name_t *name, unsigned int ntypes,
89 dns_rdatatype_t *types);
91 * Adds a new rule to a simple-secure-update rule table. The rule
92 * either grants or denies update privileges of an identity (or set of
93 * identities) to modify a name (or set of names) or certain types present
97 *\li If 'matchtype' is of SELF type, this rule only matches if the
98 * name to be updated matches the signing identity.
100 *\li If 'ntypes' is 0, this rule applies to all types except
101 * NS, SOA, RRSIG, and NSEC.
103 *\li If 'types' includes ANY, this rule applies to all types
107 *\li 'table' is a valid SSU table
108 *\li 'identity' is a valid absolute name
109 *\li 'matchtype' must be one of the defined constants.
110 *\li 'name' is a valid absolute name
111 *\li If 'ntypes' > 0, 'types' must not be NULL
119 dns_ssutable_checkrules(dns_ssutable_t *table, dns_name_t *signer,
120 dns_name_t *name, dns_rdatatype_t type);
122 * Checks that the attempted update of (name, type) is allowed according
123 * to the rules specified in the simple-secure-update rule table. If
124 * no rules are matched, access is denied. If signer is NULL, access
128 *\li 'table' is a valid SSU table
129 *\li 'signer' is NULL or a valid absolute name
130 *\li 'name' is a valid absolute name
134 /*% Accessor functions to extract rule components */
135 isc_boolean_t dns_ssurule_isgrant(const dns_ssurule_t *rule);
136 /*% Accessor functions to extract rule components */
137 dns_name_t * dns_ssurule_identity(const dns_ssurule_t *rule);
138 /*% Accessor functions to extract rule components */
139 unsigned int dns_ssurule_matchtype(const dns_ssurule_t *rule);
140 /*% Accessor functions to extract rule components */
141 dns_name_t * dns_ssurule_name(const dns_ssurule_t *rule);
142 /*% Accessor functions to extract rule components */
143 unsigned int dns_ssurule_types(const dns_ssurule_t *rule,
144 dns_rdatatype_t **types);
146 isc_result_t dns_ssutable_firstrule(const dns_ssutable_t *table,
147 dns_ssurule_t **rule);
149 * Initiates a rule iterator. There is no need to maintain any state.
156 isc_result_t dns_ssutable_nextrule(dns_ssurule_t *rule,
157 dns_ssurule_t **nextrule);
159 * Returns the next rule in the table.
168 #endif /* DNS_SSU_H */