]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - contrib/bind9/lib/dns/include/dns/ssu.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / contrib / bind9 / lib / dns / include / dns / ssu.h
1 /*
2  * Copyright (C) 2004-2008  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 2000, 2001, 2003  Internet Software Consortium.
4  *
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.
8  *
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.
16  */
17
18 /* $Id: ssu.h,v 1.24 2008/01/18 23:46:58 tbox Exp $ */
19
20 #ifndef DNS_SSU_H
21 #define DNS_SSU_H 1
22
23 /*! \file dns/ssu.h */
24
25 #include <isc/lang.h>
26
27 #include <dns/types.h>
28
29 ISC_LANG_BEGINDECLS
30
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 */
44
45 isc_result_t
46 dns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **table);
47 /*%<
48  *      Creates a table that will be used to store simple-secure-update rules.
49  *      Note: all locking must be provided by the client.
50  *
51  *      Requires:
52  *\li           'mctx' is a valid memory context
53  *\li           'table' is not NULL, and '*table' is NULL
54  *
55  *      Returns:
56  *\li           ISC_R_SUCCESS
57  *\li           ISC_R_NOMEMORY
58  */
59
60 void
61 dns_ssutable_attach(dns_ssutable_t *source, dns_ssutable_t **targetp);
62 /*%<
63  *      Attach '*targetp' to 'source'.
64  *
65  *      Requires:
66  *\li           'source' is a valid SSU table
67  *\li           'targetp' points to a NULL dns_ssutable_t *.
68  *
69  *      Ensures:
70  *\li           *targetp is attached to source.
71  */
72
73 void
74 dns_ssutable_detach(dns_ssutable_t **tablep);
75 /*%<
76  *      Detach '*tablep' from its simple-secure-update rule table.
77  *
78  *      Requires:
79  *\li           'tablep' points to a valid dns_ssutable_t
80  *
81  *      Ensures:
82  *\li           *tablep is NULL
83  *\li           If '*tablep' is the last reference to the SSU table, all
84  *                      resources used by the table will be freed.
85  */
86
87 isc_result_t
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);
92 /*%<
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
96  *      at that name.
97  *
98  *      Notes:
99  *\li           If 'matchtype' is of SELF type, this rule only matches if the
100  *              name to be updated matches the signing identity.
101  *
102  *\li           If 'ntypes' is 0, this rule applies to all types except
103  *              NS, SOA, RRSIG, and NSEC.
104  *
105  *\li           If 'types' includes ANY, this rule applies to all types
106  *              except NSEC.
107  *
108  *      Requires:
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
114  *
115  *      Returns:
116  *\li           ISC_R_SUCCESS
117  *\li           ISC_R_NOMEMORY
118  */
119
120 isc_boolean_t
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);
124 /*%<
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.
128  *
129  *      Notes:
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
134  *              rules.
135  *
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".
140  *
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.
146  *
147  *      Requires:
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
152  */
153
154
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);
166
167 isc_result_t    dns_ssutable_firstrule(const dns_ssutable_t *table,
168                                        dns_ssurule_t **rule);
169 /*%<
170  * Initiates a rule iterator.  There is no need to maintain any state.
171  *
172  * Returns:
173  *\li   #ISC_R_SUCCESS
174  *\li   #ISC_R_NOMORE
175  */
176
177 isc_result_t    dns_ssutable_nextrule(dns_ssurule_t *rule,
178                                       dns_ssurule_t **nextrule);
179 /*%<
180  * Returns the next rule in the table.
181  *
182  * Returns:
183  *\li   #ISC_R_SUCCESS
184  *\li   #ISC_R_NOMORE
185  */
186
187 ISC_LANG_ENDDECLS
188
189 #endif /* DNS_SSU_H */