1 /* $NetBSD: dns_compat.h,v 1.1.1.2 2015/01/29 06:38:27 spz Exp $ */
2 /* $NetBSD: dns_compat.h,v 1.1.1.2 2015/01/29 06:38:27 spz Exp $ */
4 * Copyright (c) 2006-2007 Niels Provos <provos@citi.umich.edu>
5 * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef _EVENT2_DNS_COMPAT_H_
30 #define _EVENT2_DNS_COMPAT_H_
32 /** @file event2/dns_compat.h
34 Potentially non-threadsafe versions of the functions in dns.h: provided
35 only for backwards compatibility.
44 #include <event2/event-config.h>
45 #ifdef _EVENT_HAVE_SYS_TYPES_H
46 #include <sys/types.h>
48 #ifdef _EVENT_HAVE_SYS_TIME_H
53 #include <event2/util.h>
56 Initialize the asynchronous DNS library.
58 This function initializes support for non-blocking name resolution by
59 calling evdns_resolv_conf_parse() on UNIX and
60 evdns_config_windows_nameservers() on Windows.
62 @deprecated This function is deprecated because it always uses the current
63 event base, and is easily confused by multiple calls to event_init(), and
64 so is not safe for multithreaded use. Additionally, it allocates a global
65 structure that only one thread can use. The replacement is
68 @return 0 if successful, or -1 if an error occurred
75 Return the global evdns_base created by event_init() and used by the other
78 @deprecated This function is deprecated because use of the global
79 evdns_base is error-prone.
81 struct evdns_base
*evdns_get_global_base(void);
84 Shut down the asynchronous DNS resolver and terminate all active requests.
86 If the 'fail_requests' option is enabled, all active requests will return
87 an empty result with the error flag set to DNS_ERR_SHUTDOWN. Otherwise,
88 the requests will be silently discarded.
90 @deprecated This function is deprecated because it does not allow the
91 caller to specify which evdns_base it applies to. The recommended
92 function is evdns_base_shutdown().
94 @param fail_requests if zero, active requests will be aborted; if non-zero,
95 active requests will return DNS_ERR_SHUTDOWN.
98 void evdns_shutdown(int fail_requests
);
103 The address should be an IPv4 address in network byte order.
104 The type of address is chosen so that it matches in_addr.s_addr.
106 @deprecated This function is deprecated because it does not allow the
107 caller to specify which evdns_base it applies to. The recommended
108 function is evdns_base_nameserver_add().
110 @param address an IP address in network byte order
111 @return 0 if successful, or -1 if an error occurred
112 @see evdns_nameserver_ip_add()
114 int evdns_nameserver_add(unsigned long int address
);
117 Get the number of configured nameservers.
119 This returns the number of configured nameservers (not necessarily the
120 number of running nameservers). This is useful for double-checking
121 whether our calls to the various nameserver configuration functions
122 have been successful.
124 @deprecated This function is deprecated because it does not allow the
125 caller to specify which evdns_base it applies to. The recommended
126 function is evdns_base_count_nameservers().
128 @return the number of configured nameservers
129 @see evdns_nameserver_add()
131 int evdns_count_nameservers(void);
134 Remove all configured nameservers, and suspend all pending resolves.
136 Resolves will not necessarily be re-attempted until evdns_resume() is called.
138 @deprecated This function is deprecated because it does not allow the
139 caller to specify which evdns_base it applies to. The recommended
140 function is evdns_base_clear_nameservers_and_suspend().
142 @return 0 if successful, or -1 if an error occurred
145 int evdns_clear_nameservers_and_suspend(void);
148 Resume normal operation and continue any suspended resolve requests.
150 Re-attempt resolves left in limbo after an earlier call to
151 evdns_clear_nameservers_and_suspend().
153 @deprecated This function is deprecated because it does not allow the
154 caller to specify which evdns_base it applies to. The recommended
155 function is evdns_base_resume().
157 @return 0 if successful, or -1 if an error occurred
158 @see evdns_clear_nameservers_and_suspend()
160 int evdns_resume(void);
165 This wraps the evdns_nameserver_add() function by parsing a string as an IP
166 address and adds it as a nameserver.
168 @deprecated This function is deprecated because it does not allow the
169 caller to specify which evdns_base it applies to. The recommended
170 function is evdns_base_nameserver_ip_add().
172 @return 0 if successful, or -1 if an error occurred
173 @see evdns_nameserver_add()
175 int evdns_nameserver_ip_add(const char *ip_as_string
);
178 Lookup an A record for a given name.
180 @deprecated This function is deprecated because it does not allow the
181 caller to specify which evdns_base it applies to. The recommended
182 function is evdns_base_resolve_ipv4().
184 @param name a DNS hostname
185 @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query.
186 @param callback a callback function to invoke when the request is completed
187 @param ptr an argument to pass to the callback function
188 @return 0 if successful, or -1 if an error occurred
189 @see evdns_resolve_ipv6(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6()
191 int evdns_resolve_ipv4(const char *name
, int flags
, evdns_callback_type callback
, void *ptr
);
194 Lookup an AAAA record for a given name.
196 @param name a DNS hostname
197 @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query.
198 @param callback a callback function to invoke when the request is completed
199 @param ptr an argument to pass to the callback function
200 @return 0 if successful, or -1 if an error occurred
201 @see evdns_resolve_ipv4(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6()
203 int evdns_resolve_ipv6(const char *name
, int flags
, evdns_callback_type callback
, void *ptr
);
209 Lookup a PTR record for a given IP address.
211 @deprecated This function is deprecated because it does not allow the
212 caller to specify which evdns_base it applies to. The recommended
213 function is evdns_base_resolve_reverse().
215 @param in an IPv4 address
216 @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query.
217 @param callback a callback function to invoke when the request is completed
218 @param ptr an argument to pass to the callback function
219 @return 0 if successful, or -1 if an error occurred
220 @see evdns_resolve_reverse_ipv6()
222 int evdns_resolve_reverse(const struct in_addr
*in
, int flags
, evdns_callback_type callback
, void *ptr
);
225 Lookup a PTR record for a given IPv6 address.
227 @deprecated This function is deprecated because it does not allow the
228 caller to specify which evdns_base it applies to. The recommended
229 function is evdns_base_resolve_reverse_ipv6().
231 @param in an IPv6 address
232 @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query.
233 @param callback a callback function to invoke when the request is completed
234 @param ptr an argument to pass to the callback function
235 @return 0 if successful, or -1 if an error occurred
236 @see evdns_resolve_reverse_ipv6()
238 int evdns_resolve_reverse_ipv6(const struct in6_addr
*in
, int flags
, evdns_callback_type callback
, void *ptr
);
241 Set the value of a configuration option.
243 The currently available configuration options are:
245 ndots, timeout, max-timeouts, max-inflight, and attempts
247 @deprecated This function is deprecated because it does not allow the
248 caller to specify which evdns_base it applies to. The recommended
249 function is evdns_base_set_option().
251 @param option the name of the configuration option to be modified
252 @param val the value to be set
253 @param flags Ignored.
254 @return 0 if successful, or -1 if an error occurred
256 int evdns_set_option(const char *option
, const char *val
, int flags
);
259 Parse a resolv.conf file.
261 The 'flags' parameter determines what information is parsed from the
262 resolv.conf file. See the man page for resolv.conf for the format of this
265 The following directives are not parsed from the file: sortlist, rotate,
266 no-check-names, inet6, debug.
268 If this function encounters an error, the possible return values are: 1 =
269 failed to open file, 2 = failed to stat file, 3 = file too large, 4 = out of
270 memory, 5 = short read from file, 6 = no nameservers listed in the file
272 @deprecated This function is deprecated because it does not allow the
273 caller to specify which evdns_base it applies to. The recommended
274 function is evdns_base_resolv_conf_parse().
276 @param flags any of DNS_OPTION_NAMESERVERS|DNS_OPTION_SEARCH|DNS_OPTION_MISC|
278 @param filename the path to the resolv.conf file
279 @return 0 if successful, or various positive error codes if an error
281 @see resolv.conf(3), evdns_config_windows_nameservers()
283 int evdns_resolv_conf_parse(int flags
, const char *const filename
);
286 Clear the list of search domains.
288 @deprecated This function is deprecated because it does not allow the
289 caller to specify which evdns_base it applies to. The recommended
290 function is evdns_base_search_clear().
292 void evdns_search_clear(void);
295 Add a domain to the list of search domains
297 @deprecated This function is deprecated because it does not allow the
298 caller to specify which evdns_base it applies to. The recommended
299 function is evdns_base_search_add().
301 @param domain the domain to be added to the search list
303 void evdns_search_add(const char *domain
);
306 Set the 'ndots' parameter for searches.
308 Sets the number of dots which, when found in a name, causes
309 the first query to be without any search domain.
311 @deprecated This function is deprecated because it does not allow the
312 caller to specify which evdns_base it applies to. The recommended
313 function is evdns_base_search_ndots_set().
315 @param ndots the new ndots parameter
317 void evdns_search_ndots_set(const int ndots
);
320 As evdns_server_new_with_base.
322 @deprecated This function is deprecated because it does not allow the
323 caller to specify which even_base it uses. The recommended
324 function is evdns_add_server_port_with_base().
327 struct evdns_server_port
*evdns_add_server_port(evutil_socket_t socket
, int flags
, evdns_request_callback_fn_type callback
, void *user_data
);
330 int evdns_config_windows_nameservers(void);
331 #define EVDNS_CONFIG_WINDOWS_NAMESERVERS_IMPLEMENTED
338 #endif /* _EVENT2_EVENT_COMPAT_H_ */