2 * Copyright (C) 2004-2008 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.24 2008/01/18 23:46:58 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_TCPSELF 10
42 #define DNS_SSUMATCHTYPE_6TO4SELF 11
43 #define DNS_SSUMATCHTYPE_MAX 11 /* max value */
46 dns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **table);
48 * Creates a table that will be used to store simple-secure-update rules.
49 * Note: all locking must be provided by the client.
52 *\li 'mctx' is a valid memory context
53 *\li 'table' is not NULL, and '*table' is NULL
61 dns_ssutable_attach(dns_ssutable_t *source, dns_ssutable_t **targetp);
63 * Attach '*targetp' to 'source'.
66 *\li 'source' is a valid SSU table
67 *\li 'targetp' points to a NULL dns_ssutable_t *.
70 *\li *targetp is attached to source.
74 dns_ssutable_detach(dns_ssutable_t **tablep);
76 * Detach '*tablep' from its simple-secure-update rule table.
79 *\li 'tablep' points to a valid dns_ssutable_t
83 *\li If '*tablep' is the last reference to the SSU table, all
84 * resources used by the table will be freed.
88 dns_ssutable_addrule(dns_ssutable_t *table, isc_boolean_t grant,
89 dns_name_t *identity, unsigned int matchtype,
90 dns_name_t *name, unsigned int ntypes,
91 dns_rdatatype_t *types);
93 * Adds a new rule to a simple-secure-update rule table. The rule
94 * either grants or denies update privileges of an identity (or set of
95 * identities) to modify a name (or set of names) or certain types present
99 *\li If 'matchtype' is of SELF type, this rule only matches if the
100 * name to be updated matches the signing identity.
102 *\li If 'ntypes' is 0, this rule applies to all types except
103 * NS, SOA, RRSIG, and NSEC.
105 *\li If 'types' includes ANY, this rule applies to all types
109 *\li 'table' is a valid SSU table
110 *\li 'identity' is a valid absolute name
111 *\li 'matchtype' must be one of the defined constants.
112 *\li 'name' is a valid absolute name
113 *\li If 'ntypes' > 0, 'types' must not be NULL
121 dns_ssutable_checkrules(dns_ssutable_t *table, dns_name_t *signer,
122 dns_name_t *name, isc_netaddr_t *tcpaddr,
123 dns_rdatatype_t type);
125 * Checks that the attempted update of (name, type) is allowed according
126 * to the rules specified in the simple-secure-update rule table. If
127 * no rules are matched, access is denied.
130 * 'tcpaddr' should only be set if the request received
131 * via TCP. This provides a weak assurance that the
132 * request was not spoofed. 'tcpaddr' is to to validate
133 * DNS_SSUMATCHTYPE_TCPSELF and DNS_SSUMATCHTYPE_6TO4SELF
136 * For DNS_SSUMATCHTYPE_TCPSELF the addresses are mapped to
137 * the standard reverse names under IN-ADDR.ARPA and IP6.ARPA.
138 * RFC 1035, Section 3.5, "IN-ADDR.ARPA domain" and RFC 3596,
139 * Section 2.5, "IP6.ARPA Domain".
141 * For DNS_SSUMATCHTYPE_6TO4SELF, IPv4 address are converted
142 * to a 6to4 prefix (48 bits) per the rules in RFC 3056. Only
143 * the top 48 bits of the IPv6 address are mapped to the reverse
144 * name. This is independent of whether the most significant 16
145 * bits match 2002::/16, assigned for 6to4 prefixes, or not.
148 *\li 'table' is a valid SSU table
149 *\li 'signer' is NULL or a valid absolute name
150 *\li 'tcpaddr' is NULL or a valid network address.
151 *\li 'name' is a valid absolute name
155 /*% Accessor functions to extract rule components */
156 isc_boolean_t dns_ssurule_isgrant(const dns_ssurule_t *rule);
157 /*% Accessor functions to extract rule components */
158 dns_name_t * dns_ssurule_identity(const dns_ssurule_t *rule);
159 /*% Accessor functions to extract rule components */
160 unsigned int dns_ssurule_matchtype(const dns_ssurule_t *rule);
161 /*% Accessor functions to extract rule components */
162 dns_name_t * dns_ssurule_name(const dns_ssurule_t *rule);
163 /*% Accessor functions to extract rule components */
164 unsigned int dns_ssurule_types(const dns_ssurule_t *rule,
165 dns_rdatatype_t **types);
167 isc_result_t dns_ssutable_firstrule(const dns_ssutable_t *table,
168 dns_ssurule_t **rule);
170 * Initiates a rule iterator. There is no need to maintain any state.
177 isc_result_t dns_ssutable_nextrule(dns_ssurule_t *rule,
178 dns_ssurule_t **nextrule);
180 * Returns the next rule in the table.
189 #endif /* DNS_SSU_H */