1135446Strhodes/*
2193149Sdougb * Copyright (C) 2004-2007, 2009  Internet Systems Consortium, Inc. ("ISC")
3135446Strhodes * Copyright (C) 2000, 2001  Internet Software Consortium.
4135446Strhodes *
5193149Sdougb * Permission to use, copy, modify, and/or distribute this software for any
6135446Strhodes * purpose with or without fee is hereby granted, provided that the above
7135446Strhodes * copyright notice and this permission notice appear in all copies.
8135446Strhodes *
9135446Strhodes * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10135446Strhodes * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11135446Strhodes * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12135446Strhodes * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13135446Strhodes * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14135446Strhodes * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15135446Strhodes * PERFORMANCE OF THIS SOFTWARE.
16135446Strhodes */
17135446Strhodes
18234010Sdougb/* $Id: lookup.h,v 1.14 2009/01/17 23:47:43 tbox Exp $ */
19135446Strhodes
20135446Strhodes#ifndef DNS_LOOKUP_H
21135446Strhodes#define DNS_LOOKUP_H 1
22135446Strhodes
23135446Strhodes/*****
24135446Strhodes ***** Module Info
25135446Strhodes *****/
26135446Strhodes
27193149Sdougb/*! \file dns/lookup.h
28170222Sdougb * \brief
29135446Strhodes * The lookup module performs simple DNS lookups.  It implements
30193149Sdougb * the full resolver algorithm, both looking for local data and
31193149Sdougb * resolving external names as necessary.
32135446Strhodes *
33135446Strhodes * MP:
34170222Sdougb *\li	The module ensures appropriate synchronization of data structures it
35135446Strhodes *	creates and manipulates.
36135446Strhodes *
37135446Strhodes * Reliability:
38170222Sdougb *\li	No anticipated impact.
39135446Strhodes *
40135446Strhodes * Resources:
41170222Sdougb *\li	TBS
42135446Strhodes *
43135446Strhodes * Security:
44170222Sdougb *\li	No anticipated impact.
45135446Strhodes *
46135446Strhodes * Standards:
47170222Sdougb *\li	RFCs:	1034, 1035, 2181, TBS
48170222Sdougb *\li	Drafts:	TBS
49135446Strhodes */
50135446Strhodes
51135446Strhodes#include <isc/lang.h>
52135446Strhodes#include <isc/event.h>
53135446Strhodes
54135446Strhodes#include <dns/types.h>
55135446Strhodes
56135446StrhodesISC_LANG_BEGINDECLS
57135446Strhodes
58170222Sdougb/*%
59135446Strhodes * A 'dns_lookupevent_t' is returned when a lookup completes.
60135446Strhodes * The sender field will be set to the lookup that completed.  If 'result'
61135446Strhodes * is ISC_R_SUCCESS, then 'names' will contain a list of names associated
62135446Strhodes * with the address.  The recipient of the event must not change the list
63135446Strhodes * and must not refer to any of the name data after the event is freed.
64135446Strhodes */
65135446Strhodestypedef struct dns_lookupevent {
66135446Strhodes	ISC_EVENT_COMMON(struct dns_lookupevent);
67135446Strhodes	isc_result_t			result;
68135446Strhodes	dns_name_t			*name;
69135446Strhodes	dns_rdataset_t			*rdataset;
70135446Strhodes	dns_rdataset_t			*sigrdataset;
71135446Strhodes	dns_db_t			*db;
72135446Strhodes	dns_dbnode_t			*node;
73135446Strhodes} dns_lookupevent_t;
74135446Strhodes
75135446Strhodesisc_result_t
76135446Strhodesdns_lookup_create(isc_mem_t *mctx, dns_name_t *name, dns_rdatatype_t type,
77135446Strhodes		  dns_view_t *view, unsigned int options, isc_task_t *task,
78135446Strhodes		  isc_taskaction_t action, void *arg, dns_lookup_t **lookupp);
79170222Sdougb/*%<
80135446Strhodes * Finds the rrsets matching 'name' and 'type'.
81135446Strhodes *
82135446Strhodes * Requires:
83135446Strhodes *
84170222Sdougb *\li	'mctx' is a valid mctx.
85135446Strhodes *
86170222Sdougb *\li	'name' is a valid name.
87135446Strhodes *
88170222Sdougb *\li	'view' is a valid view which has a resolver.
89135446Strhodes *
90170222Sdougb *\li	'task' is a valid task.
91135446Strhodes *
92170222Sdougb *\li	lookupp != NULL && *lookupp == NULL
93135446Strhodes *
94135446Strhodes * Returns:
95135446Strhodes *
96170222Sdougb *\li	ISC_R_SUCCESS
97170222Sdougb *\li	ISC_R_NOMEMORY
98135446Strhodes *
99170222Sdougb *\li	Any resolver-related error (e.g. ISC_R_SHUTTINGDOWN) may also be
100135446Strhodes *	returned.
101135446Strhodes */
102135446Strhodes
103135446Strhodesvoid
104135446Strhodesdns_lookup_cancel(dns_lookup_t *lookup);
105170222Sdougb/*%<
106135446Strhodes * Cancel 'lookup'.
107135446Strhodes *
108135446Strhodes * Notes:
109135446Strhodes *
110170222Sdougb *\li	If 'lookup' has not completed, post its LOOKUPDONE event with a
111135446Strhodes *	result code of ISC_R_CANCELED.
112135446Strhodes *
113135446Strhodes * Requires:
114135446Strhodes *
115170222Sdougb *\li	'lookup' is a valid lookup.
116135446Strhodes */
117135446Strhodes
118135446Strhodesvoid
119135446Strhodesdns_lookup_destroy(dns_lookup_t **lookupp);
120170222Sdougb/*%<
121135446Strhodes * Destroy 'lookup'.
122135446Strhodes *
123135446Strhodes * Requires:
124135446Strhodes *
125170222Sdougb *\li	'*lookupp' is a valid lookup.
126135446Strhodes *
127170222Sdougb *\li	The caller has received the LOOKUPDONE event (either because the
128135446Strhodes *	lookup completed or because dns_lookup_cancel() was called).
129135446Strhodes *
130135446Strhodes * Ensures:
131135446Strhodes *
132170222Sdougb *\li	*lookupp == NULL.
133135446Strhodes */
134135446Strhodes
135135446StrhodesISC_LANG_ENDDECLS
136135446Strhodes
137135446Strhodes#endif /* DNS_LOOKUP_H */
138