1 /*	$NetBSD: byaddr.h,v 1.4 2014/12/10 04:37:58 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2004-2007  Internet Systems Consortium, Inc. ("ISC")
5  * Copyright (C) 2000-2003  Internet Software Consortium.
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /* Id: byaddr.h,v 1.22 2007/06/19 23:47:16 tbox Exp  */
21 
22 #ifndef DNS_BYADDR_H
23 #define DNS_BYADDR_H 1
24 
25 /*****
26  ***** Module Info
27  *****/
28 
29 /*! \file dns/byaddr.h
30  * \brief
31  * The byaddr module provides reverse lookup services for IPv4 and IPv6
32  * addresses.
33  *
34  * MP:
35  *\li	The module ensures appropriate synchronization of data structures it
36  *	creates and manipulates.
37  *
38  * Reliability:
39  *\li	No anticipated impact.
40  *
41  * Resources:
42  *\li	TBS
43  *
44  * Security:
45  *\li	No anticipated impact.
46  *
47  * Standards:
48  *\li	RFCs:	1034, 1035, 2181, TBS
49  *\li	Drafts:	TBS
50  */
51 
52 #include <isc/lang.h>
53 #include <isc/event.h>
54 
55 #include <dns/types.h>
56 
57 ISC_LANG_BEGINDECLS
58 
59 /*%
60  * A 'dns_byaddrevent_t' is returned when a byaddr completes.
61  * The sender field will be set to the byaddr that completed.  If 'result'
62  * is ISC_R_SUCCESS, then 'names' will contain a list of names associated
63  * with the address.  The recipient of the event must not change the list
64  * and must not refer to any of the name data after the event is freed.
65  */
66 typedef struct dns_byaddrevent {
67 	ISC_EVENT_COMMON(struct dns_byaddrevent);
68 	isc_result_t			result;
69 	dns_namelist_t			names;
70 } dns_byaddrevent_t;
71 
72 /*
73  * This option is deprecated since we now only consider nibbles.
74 #define DNS_BYADDROPT_IPV6NIBBLE	0x0001
75  */
76 /*% Note DNS_BYADDROPT_IPV6NIBBLE is now deprecated. */
77 #define DNS_BYADDROPT_IPV6INT		0x0002
78 
79 isc_result_t
80 dns_byaddr_create(isc_mem_t *mctx, isc_netaddr_t *address, dns_view_t *view,
81 		  unsigned int options, isc_task_t *task,
82 		  isc_taskaction_t action, void *arg, dns_byaddr_t **byaddrp);
83 /*%<
84  * Find the domain name of 'address'.
85  *
86  * Notes:
87  *
88  *\li	There is a reverse lookup format for IPv6 addresses, 'nibble'
89  *
90  *\li	The 'nibble' format for that address is
91  *
92  * \code
93  *   1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa.
94  * \endcode
95  *
96  *\li	#DNS_BYADDROPT_IPV6INT can be used to get nibble lookups under ip6.int.
97  *
98  * Requires:
99  *
100  *\li	'mctx' is a valid mctx.
101  *
102  *\li	'address' is a valid IPv4 or IPv6 address.
103  *
104  *\li	'view' is a valid view which has a resolver.
105  *
106  *\li	'task' is a valid task.
107  *
108  *\li	byaddrp != NULL && *byaddrp == NULL
109  *
110  * Returns:
111  *
112  *\li	#ISC_R_SUCCESS
113  *\li	#ISC_R_NOMEMORY
114  *
115  *\li	Any resolver-related error (e.g. #ISC_R_SHUTTINGDOWN) may also be
116  *	returned.
117  */
118 
119 void
120 dns_byaddr_cancel(dns_byaddr_t *byaddr);
121 /*%<
122  * Cancel 'byaddr'.
123  *
124  * Notes:
125  *
126  *\li	If 'byaddr' has not completed, post its #DNS_EVENT_BYADDRDONE
127  *	event with a result code of #ISC_R_CANCELED.
128  *
129  * Requires:
130  *
131  *\li	'byaddr' is a valid byaddr.
132  */
133 
134 void
135 dns_byaddr_destroy(dns_byaddr_t **byaddrp);
136 /*%<
137  * Destroy 'byaddr'.
138  *
139  * Requires:
140  *
141  *\li	'*byaddrp' is a valid byaddr.
142  *
143  *\li	The caller has received the #DNS_EVENT_BYADDRDONE event (either because
144  *	the byaddr completed or because dns_byaddr_cancel() was called).
145  *
146  * Ensures:
147  *
148  *\li	*byaddrp == NULL.
149  */
150 
151 isc_result_t
152 dns_byaddr_createptrname(isc_netaddr_t *address, isc_boolean_t nibble,
153 			 dns_name_t *name);
154 
155 isc_result_t
156 dns_byaddr_createptrname2(isc_netaddr_t *address, unsigned int options,
157 			  dns_name_t *name);
158 /*%<
159  * Creates a name that would be used in a PTR query for this address.  The
160  * nibble flag indicates that the 'nibble' format is to be used if an IPv6
161  * address is provided, instead of the 'bitstring' format.  Since we dropped
162  * the support of the bitstring labels, it is expected that the flag is always
163  * set.  'options' are the same as for dns_byaddr_create().
164  *
165  * Requires:
166  *
167  * \li	'address' is a valid address.
168  * \li	'name' is a valid name with a dedicated buffer.
169  */
170 
171 ISC_LANG_ENDDECLS
172 
173 #endif /* DNS_BYADDR_H */
174