Merge from vendor branch INTEL_ACPICA:
[dragonfly.git] / contrib / bind-9.3 / lib / dns / include / dns / validator.h
1 /*
2  * Copyright (C) 2004, 2005  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 2000-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: validator.h,v 1.18.12.9 2005/09/06 02:12:41 marka Exp $ */
19
20 #ifndef DNS_VALIDATOR_H
21 #define DNS_VALIDATOR_H 1
22
23 /*****
24  ***** Module Info
25  *****/
26
27 /*
28  * DNS Validator
29  *
30  * XXX <TBS> XXX
31  *
32  * MP:
33  *      The module ensures appropriate synchronization of data structures it
34  *      creates and manipulates.
35  *
36  * Reliability:
37  *      No anticipated impact.
38  *
39  * Resources:
40  *      <TBS>
41  *
42  * Security:
43  *      No anticipated impact.
44  *
45  * Standards:
46  *      RFCs:   1034, 1035, 2181, 2535, <TBS>
47  *      Drafts: <TBS>
48  */
49
50 #include <isc/lang.h>
51 #include <isc/event.h>
52 #include <isc/mutex.h>
53
54 #include <dns/fixedname.h>
55 #include <dns/types.h>
56 #include <dns/rdataset.h>
57 #include <dns/rdatastruct.h> /* for dns_rdata_rrsig_t */
58
59 #include <dst/dst.h>
60
61 /*
62  * A dns_validatorevent_t is sent when a 'validation' completes.
63  *
64  * 'name', 'rdataset', 'sigrdataset', and 'message' are the values that were
65  * supplied when dns_validator_create() was called.  They are returned to the
66  * caller so that they may be freed.
67  */
68 typedef struct dns_validatorevent {
69         ISC_EVENT_COMMON(struct dns_validatorevent);
70         dns_validator_t *               validator;
71         isc_result_t                    result;
72         dns_name_t *                    name;
73         dns_rdatatype_t                 type;
74         dns_rdataset_t *                rdataset;
75         dns_rdataset_t *                sigrdataset;
76         dns_message_t *                 message;
77         dns_name_t *                    proofs[3];
78 } dns_validatorevent_t;
79
80 #define DNS_VALIDATOR_NOQNAMEPROOF 0
81 #define DNS_VALIDATOR_NODATAPROOF 1
82 #define DNS_VALIDATOR_NOWILDCARDPROOF 2
83
84 /*
85  * A validator object represents a validation in procgress.
86  *
87  * Clients are strongly discouraged from using this type directly, with
88  * the exception of the 'link' field, which may be used directly for
89  * whatever purpose the client desires.
90  */
91 struct dns_validator {
92         /* Unlocked. */
93         unsigned int                    magic;
94         isc_mutex_t                     lock;
95         dns_view_t *                    view;
96         /* Locked by lock. */
97         unsigned int                    options;
98         unsigned int                    attributes;
99         dns_validatorevent_t *          event;
100         dns_fetch_t *                   fetch;
101         dns_validator_t *               subvalidator;
102         dns_validator_t *               parent;
103         dns_keytable_t *                keytable;
104         dns_keynode_t *                 keynode;
105         dst_key_t *                     key;
106         dns_rdata_rrsig_t *             siginfo;
107         isc_task_t *                    task;
108         isc_taskaction_t                action;
109         void *                          arg;
110         unsigned int                    labels;
111         dns_rdataset_t *                currentset;
112         isc_boolean_t                   seensig;
113         dns_rdataset_t *                keyset;
114         dns_rdataset_t *                dsset;
115         dns_rdataset_t *                soaset;
116         dns_rdataset_t *                nsecset;
117         dns_name_t *                    soaname;
118         dns_rdataset_t                  frdataset;
119         dns_rdataset_t                  fsigrdataset;
120         dns_fixedname_t                 fname;
121         dns_fixedname_t                 wild;
122         ISC_LINK(dns_validator_t)       link;
123         dns_rdataset_t                  dlv;
124         dns_fixedname_t                 dlvsep;
125         isc_boolean_t                   havedlvsep;
126         isc_boolean_t                   mustbesecure;
127         unsigned int                    dlvlabels;
128         unsigned int                    depth;
129 };
130
131 #define DNS_VALIDATOR_DLV 1
132
133 ISC_LANG_BEGINDECLS
134
135 isc_result_t
136 dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
137                      dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset,
138                      dns_message_t *message, unsigned int options,
139                      isc_task_t *task, isc_taskaction_t action, void *arg,
140                      dns_validator_t **validatorp);
141 /*
142  * Start a DNSSEC validation.
143  *
144  * This validates a response to the question given by
145  * 'name' and 'type'.
146  *
147  * To validate a positive response, the response data is
148  * given by 'rdataset' and 'sigrdataset'.  If 'sigrdataset'
149  * is NULL, the data is presumed insecure and an attempt
150  * is made to prove its insecurity by finding the appropriate
151  * null key.
152  *
153  * The complete response message may be given in 'message',
154  * to make available any authority section NSECs that may be
155  * needed for validation of a response resulting from a
156  * wildcard expansion (though no such wildcard validation
157  * is implemented yet).  If the complete response message
158  * is not available, 'message' is NULL.
159  *
160  * To validate a negative response, the complete negative response
161  * message is given in 'message'.  The 'rdataset', and
162  * 'sigrdataset' arguments must be NULL, but the 'name' and 'type'
163  * arguments must be provided.
164  *
165  * The validation is performed in the context of 'view'.
166  * 'options' must be zero.
167  *
168  * When the validation finishes, a dns_validatorevent_t with
169  * the given 'action' and 'arg' are sent to 'task'.
170  * Its 'result' field will be ISC_R_SUCCESS iff the
171  * response was successfully proven to be either secure or
172  * part of a known insecure domain.
173  */
174
175 void
176 dns_validator_cancel(dns_validator_t *validator);
177 /*
178  * Cancel a DNSSEC validation in progress.
179  *
180  * Requires:
181  *      'validator' points to a valid DNSSEC validator, which
182  *      may or may not already have completed.
183  *
184  * Ensures:
185  *      It the validator has not already sent its completion
186  *      event, it will send it with result code ISC_R_CANCELED.
187  */
188
189 void
190 dns_validator_destroy(dns_validator_t **validatorp);
191 /*
192  * Destroy a DNSSEC validator.
193  *
194  * Requires:
195  *      '*validatorp' points to a valid DNSSEC validator.
196  *      The validator must have completed and sent its completion
197  *      event.
198  *
199  * Ensures:
200  *      All resources used by the validator are freed.
201  */
202
203 ISC_LANG_ENDDECLS
204
205 #endif /* DNS_VALIDATOR_H */