Merge branch 'vendor/OPENSSL'
[dragonfly.git] / contrib / bind-9.3 / lib / dns / include / dns / ssu.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 2000, 2001, 2003  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and 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.11.206.3 2004/03/08 09:04:39 marka Exp $ */
19
20 #ifndef DNS_SSU_H
21 #define DNS_SSU_H 1
22
23 #include <isc/lang.h>
24
25 #include <dns/types.h>
26
27 ISC_LANG_BEGINDECLS
28
29 #define DNS_SSUMATCHTYPE_NAME 0
30 #define DNS_SSUMATCHTYPE_SUBDOMAIN 1
31 #define DNS_SSUMATCHTYPE_WILDCARD 2
32 #define DNS_SSUMATCHTYPE_SELF 3
33
34 isc_result_t
35 dns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **table);
36 /*
37  *      Creates a table that will be used to store simple-secure-update rules.
38  *      Note: all locking must be provided by the client.
39  *
40  *      Requires:
41  *              'mctx' is a valid memory context
42  *              'table' is not NULL, and '*table' is NULL
43  *
44  *      Returns:
45  *              ISC_R_SUCCESS
46  *              ISC_R_NOMEMORY
47  */
48
49 void
50 dns_ssutable_attach(dns_ssutable_t *source, dns_ssutable_t **targetp);
51 /*
52  *      Attach '*targetp' to 'source'.
53  *
54  *      Requires:
55  *              'source' is a valid SSU table
56  *              'targetp' points to a NULL dns_ssutable_t *.
57  *
58  *      Ensures:
59  *              *targetp is attached to source.
60  */
61
62 void
63 dns_ssutable_detach(dns_ssutable_t **tablep);
64 /*
65  *      Detach '*tablep' from its simple-secure-update rule table.
66  *
67  *      Requires:
68  *              'tablep' points to a valid dns_ssutable_t
69  *
70  *      Ensures:
71  *              *tablep is NULL
72  *              If '*tablep' is the last reference to the SSU table, all
73  *                      resources used by the table will be freed.
74  */
75
76 isc_result_t
77 dns_ssutable_addrule(dns_ssutable_t *table, isc_boolean_t grant,
78                      dns_name_t *identity, unsigned int matchtype,
79                      dns_name_t *name, unsigned int ntypes,
80                      dns_rdatatype_t *types);
81 /*
82  *      Adds a new rule to a simple-secure-update rule table.  The rule
83  *      either grants or denies update privileges of an identity (or set of
84  *      identities) to modify a name (or set of names) or certain types present
85  *      at that name.
86  *
87  *      Notes:
88  *              If 'matchtype' is SELF, this rule only matches if the name
89  *              to be updated matches the signing identity.
90  *
91  *              If 'ntypes' is 0, this rule applies to all types except
92  *              NS, SOA, RRSIG, and NSEC.
93  *
94  *              If 'types' includes ANY, this rule applies to all types
95  *              except NSEC.
96  *
97  *      Requires:
98  *              'table' is a valid SSU table
99  *              'identity' is a valid absolute name
100  *              'matchtype' must be one of the defined constants.
101  *              'name' is a valid absolute name
102  *              If 'ntypes' > 0, 'types' must not be NULL
103  *
104  *      Returns:
105  *              ISC_R_SUCCESS
106  *              ISC_R_NOMEMORY
107  */
108
109 isc_boolean_t
110 dns_ssutable_checkrules(dns_ssutable_t *table, dns_name_t *signer,
111                         dns_name_t *name, dns_rdatatype_t type);
112 /*
113  *      Checks that the attempted update of (name, type) is allowed according
114  *      to the rules specified in the simple-secure-update rule table.  If
115  *      no rules are matched, access is denied.  If signer is NULL, access
116  *      is denied.
117  *
118  *      Requires:
119  *              'table' is a valid SSU table
120  *              'signer' is NULL or a valid absolute name
121  *              'name' is a valid absolute name
122  */
123
124
125 isc_boolean_t   dns_ssurule_isgrant(const dns_ssurule_t *rule);
126 dns_name_t *    dns_ssurule_identity(const dns_ssurule_t *rule);
127 unsigned int    dns_ssurule_matchtype(const dns_ssurule_t *rule);
128 dns_name_t *    dns_ssurule_name(const dns_ssurule_t *rule);
129 unsigned int    dns_ssurule_types(const dns_ssurule_t *rule,
130                                   dns_rdatatype_t **types);
131 /*
132  * Accessor functions to extract rule components
133  */
134
135 isc_result_t    dns_ssutable_firstrule(const dns_ssutable_t *table,
136                                        dns_ssurule_t **rule);
137 /*
138  * Initiates a rule iterator.  There is no need to maintain any state.
139  *
140  * Returns:
141  *      ISC_R_SUCCESS
142  *      ISC_R_NOMORE
143  */
144
145 isc_result_t    dns_ssutable_nextrule(dns_ssurule_t *rule,
146                                       dns_ssurule_t **nextrule);
147 /*
148  * Returns the next rule in the table.
149  *
150  * Returns:
151  *      ISC_R_SUCCESS
152  *      ISC_R_NOMORE
153  */
154
155 ISC_LANG_ENDDECLS
156
157 #endif /* DNS_SSU_H */