|
||||
File indexing completed on 2025-01-18 09:57:12
0001 /* 0002 * Copyright (c) 2006-2007 Niels Provos <provos@citi.umich.edu> 0003 * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 0004 * 0005 * Redistribution and use in source and binary forms, with or without 0006 * modification, are permitted provided that the following conditions 0007 * are met: 0008 * 1. Redistributions of source code must retain the above copyright 0009 * notice, this list of conditions and the following disclaimer. 0010 * 2. Redistributions in binary form must reproduce the above copyright 0011 * notice, this list of conditions and the following disclaimer in the 0012 * documentation and/or other materials provided with the distribution. 0013 * 3. The name of the author may not be used to endorse or promote products 0014 * derived from this software without specific prior written permission. 0015 * 0016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0017 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0018 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0019 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0020 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0021 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0022 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0023 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0024 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0025 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0026 */ 0027 #ifndef EVENT2_DNS_COMPAT_H_INCLUDED_ 0028 #define EVENT2_DNS_COMPAT_H_INCLUDED_ 0029 0030 /** @file event2/dns_compat.h 0031 0032 Potentially non-threadsafe versions of the functions in dns.h: provided 0033 only for backwards compatibility. 0034 0035 0036 */ 0037 0038 #ifdef __cplusplus 0039 extern "C" { 0040 #endif 0041 0042 #include <event2/event-config.h> 0043 #ifdef EVENT__HAVE_SYS_TYPES_H 0044 #include <sys/types.h> 0045 #endif 0046 #ifdef EVENT__HAVE_SYS_TIME_H 0047 #include <sys/time.h> 0048 #endif 0049 0050 /* For int types. */ 0051 #include <event2/util.h> 0052 #include <event2/visibility.h> 0053 0054 /** 0055 Initialize the asynchronous DNS library. 0056 0057 This function initializes support for non-blocking name resolution by 0058 calling evdns_resolv_conf_parse() on UNIX and 0059 evdns_config_windows_nameservers() on Windows. 0060 0061 @deprecated This function is deprecated because it always uses the current 0062 event base, and is easily confused by multiple calls to event_init(), and 0063 so is not safe for multithreaded use. Additionally, it allocates a global 0064 structure that only one thread can use. The replacement is 0065 evdns_base_new(). 0066 0067 @return 0 if successful, or -1 if an error occurred 0068 @see evdns_shutdown() 0069 */ 0070 EVENT2_EXPORT_SYMBOL 0071 int evdns_init(void); 0072 0073 struct evdns_base; 0074 /** 0075 Return the global evdns_base created by event_init() and used by the other 0076 deprecated functions. 0077 0078 @deprecated This function is deprecated because use of the global 0079 evdns_base is error-prone. 0080 */ 0081 EVENT2_EXPORT_SYMBOL 0082 struct evdns_base *evdns_get_global_base(void); 0083 0084 /** 0085 Shut down the asynchronous DNS resolver and terminate all active requests. 0086 0087 If the 'fail_requests' option is enabled, all active requests will return 0088 an empty result with the error flag set to DNS_ERR_SHUTDOWN. Otherwise, 0089 the requests will be silently discarded. 0090 0091 @deprecated This function is deprecated because it does not allow the 0092 caller to specify which evdns_base it applies to. The recommended 0093 function is evdns_base_shutdown(). 0094 0095 @param fail_requests if zero, active requests will be aborted; if non-zero, 0096 active requests will return DNS_ERR_SHUTDOWN. 0097 @see evdns_init() 0098 */ 0099 EVENT2_EXPORT_SYMBOL 0100 void evdns_shutdown(int fail_requests); 0101 0102 /** 0103 Add a nameserver. 0104 0105 The address should be an IPv4 address in network byte order. 0106 The type of address is chosen so that it matches in_addr.s_addr. 0107 0108 @deprecated This function is deprecated because it does not allow the 0109 caller to specify which evdns_base it applies to. The recommended 0110 function is evdns_base_nameserver_add(). 0111 0112 @param address an IP address in network byte order 0113 @return 0 if successful, or -1 if an error occurred 0114 @see evdns_nameserver_ip_add() 0115 */ 0116 EVENT2_EXPORT_SYMBOL 0117 int evdns_nameserver_add(unsigned long int address); 0118 0119 /** 0120 Get the number of configured nameservers. 0121 0122 This returns the number of configured nameservers (not necessarily the 0123 number of running nameservers). This is useful for double-checking 0124 whether our calls to the various nameserver configuration functions 0125 have been successful. 0126 0127 @deprecated This function is deprecated because it does not allow the 0128 caller to specify which evdns_base it applies to. The recommended 0129 function is evdns_base_count_nameservers(). 0130 0131 @return the number of configured nameservers 0132 @see evdns_nameserver_add() 0133 */ 0134 EVENT2_EXPORT_SYMBOL 0135 int evdns_count_nameservers(void); 0136 0137 /** 0138 Remove all configured nameservers, and suspend all pending resolves. 0139 0140 Resolves will not necessarily be re-attempted until evdns_resume() is called. 0141 0142 @deprecated This function is deprecated because it does not allow the 0143 caller to specify which evdns_base it applies to. The recommended 0144 function is evdns_base_clear_nameservers_and_suspend(). 0145 0146 @return 0 if successful, or -1 if an error occurred 0147 @see evdns_resume() 0148 */ 0149 EVENT2_EXPORT_SYMBOL 0150 int evdns_clear_nameservers_and_suspend(void); 0151 0152 /** 0153 Resume normal operation and continue any suspended resolve requests. 0154 0155 Re-attempt resolves left in limbo after an earlier call to 0156 evdns_clear_nameservers_and_suspend(). 0157 0158 @deprecated This function is deprecated because it does not allow the 0159 caller to specify which evdns_base it applies to. The recommended 0160 function is evdns_base_resume(). 0161 0162 @return 0 if successful, or -1 if an error occurred 0163 @see evdns_clear_nameservers_and_suspend() 0164 */ 0165 EVENT2_EXPORT_SYMBOL 0166 int evdns_resume(void); 0167 0168 /** 0169 Add a nameserver. 0170 0171 This wraps the evdns_nameserver_add() function by parsing a string as an IP 0172 address and adds it as a nameserver. 0173 0174 @deprecated This function is deprecated because it does not allow the 0175 caller to specify which evdns_base it applies to. The recommended 0176 function is evdns_base_nameserver_ip_add(). 0177 0178 @return 0 if successful, or -1 if an error occurred 0179 @see evdns_nameserver_add() 0180 */ 0181 EVENT2_EXPORT_SYMBOL 0182 int evdns_nameserver_ip_add(const char *ip_as_string); 0183 0184 /** 0185 Lookup an A record for a given name. 0186 0187 @deprecated This function is deprecated because it does not allow the 0188 caller to specify which evdns_base it applies to. The recommended 0189 function is evdns_base_resolve_ipv4(). 0190 0191 @param name a DNS hostname 0192 @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query. 0193 @param callback a callback function to invoke when the request is completed 0194 @param ptr an argument to pass to the callback function 0195 @return 0 if successful, or -1 if an error occurred 0196 @see evdns_resolve_ipv6(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6() 0197 */ 0198 EVENT2_EXPORT_SYMBOL 0199 int evdns_resolve_ipv4(const char *name, int flags, evdns_callback_type callback, void *ptr); 0200 0201 /** 0202 Lookup an AAAA record for a given name. 0203 0204 @param name a DNS hostname 0205 @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query. 0206 @param callback a callback function to invoke when the request is completed 0207 @param ptr an argument to pass to the callback function 0208 @return 0 if successful, or -1 if an error occurred 0209 @see evdns_resolve_ipv4(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6() 0210 */ 0211 EVENT2_EXPORT_SYMBOL 0212 int evdns_resolve_ipv6(const char *name, int flags, evdns_callback_type callback, void *ptr); 0213 0214 struct in_addr; 0215 struct in6_addr; 0216 0217 /** 0218 Lookup a PTR record for a given IP address. 0219 0220 @deprecated This function is deprecated because it does not allow the 0221 caller to specify which evdns_base it applies to. The recommended 0222 function is evdns_base_resolve_reverse(). 0223 0224 @param in an IPv4 address 0225 @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query. 0226 @param callback a callback function to invoke when the request is completed 0227 @param ptr an argument to pass to the callback function 0228 @return 0 if successful, or -1 if an error occurred 0229 @see evdns_resolve_reverse_ipv6() 0230 */ 0231 EVENT2_EXPORT_SYMBOL 0232 int evdns_resolve_reverse(const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr); 0233 0234 /** 0235 Lookup a PTR record for a given IPv6 address. 0236 0237 @deprecated This function is deprecated because it does not allow the 0238 caller to specify which evdns_base it applies to. The recommended 0239 function is evdns_base_resolve_reverse_ipv6(). 0240 0241 @param in an IPv6 address 0242 @param flags either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query. 0243 @param callback a callback function to invoke when the request is completed 0244 @param ptr an argument to pass to the callback function 0245 @return 0 if successful, or -1 if an error occurred 0246 @see evdns_resolve_reverse_ipv6() 0247 */ 0248 EVENT2_EXPORT_SYMBOL 0249 int evdns_resolve_reverse_ipv6(const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr); 0250 0251 /** 0252 Set the value of a configuration option. 0253 0254 The currently available configuration options are: 0255 0256 ndots, timeout, max-timeouts, max-inflight, and attempts 0257 0258 @deprecated This function is deprecated because it does not allow the 0259 caller to specify which evdns_base it applies to. The recommended 0260 function is evdns_base_set_option(). 0261 0262 @param option the name of the configuration option to be modified 0263 @param val the value to be set 0264 @param flags Ignored. 0265 @return 0 if successful, or -1 if an error occurred 0266 */ 0267 EVENT2_EXPORT_SYMBOL 0268 int evdns_set_option(const char *option, const char *val, int flags); 0269 0270 /** 0271 Parse a resolv.conf file. 0272 0273 The 'flags' parameter determines what information is parsed from the 0274 resolv.conf file. See the man page for resolv.conf for the format of this 0275 file. 0276 0277 The following directives are not parsed from the file: sortlist, rotate, 0278 no-check-names, inet6, debug. 0279 0280 If this function encounters an error, the possible return values are: 1 = 0281 failed to open file, 2 = failed to stat file, 3 = file too large, 4 = out of 0282 memory, 5 = short read from file, 6 = no nameservers listed in the file 0283 0284 @deprecated This function is deprecated because it does not allow the 0285 caller to specify which evdns_base it applies to. The recommended 0286 function is evdns_base_resolv_conf_parse(). 0287 0288 @param flags any of DNS_OPTION_NAMESERVERS|DNS_OPTION_SEARCH|DNS_OPTION_MISC| 0289 DNS_OPTIONS_ALL 0290 @param filename the path to the resolv.conf file 0291 @return 0 if successful, or various positive error codes if an error 0292 occurred (see above) 0293 @see resolv.conf(3), evdns_config_windows_nameservers() 0294 */ 0295 EVENT2_EXPORT_SYMBOL 0296 int evdns_resolv_conf_parse(int flags, const char *const filename); 0297 0298 /** 0299 Clear the list of search domains. 0300 0301 @deprecated This function is deprecated because it does not allow the 0302 caller to specify which evdns_base it applies to. The recommended 0303 function is evdns_base_search_clear(). 0304 */ 0305 EVENT2_EXPORT_SYMBOL 0306 void evdns_search_clear(void); 0307 0308 /** 0309 Add a domain to the list of search domains 0310 0311 @deprecated This function is deprecated because it does not allow the 0312 caller to specify which evdns_base it applies to. The recommended 0313 function is evdns_base_search_add(). 0314 0315 @param domain the domain to be added to the search list 0316 */ 0317 EVENT2_EXPORT_SYMBOL 0318 void evdns_search_add(const char *domain); 0319 0320 /** 0321 Set the 'ndots' parameter for searches. 0322 0323 Sets the number of dots which, when found in a name, causes 0324 the first query to be without any search domain. 0325 0326 @deprecated This function is deprecated because it does not allow the 0327 caller to specify which evdns_base it applies to. The recommended 0328 function is evdns_base_search_ndots_set(). 0329 0330 @param ndots the new ndots parameter 0331 */ 0332 EVENT2_EXPORT_SYMBOL 0333 void evdns_search_ndots_set(const int ndots); 0334 0335 /** 0336 As evdns_server_new_with_base. 0337 0338 @deprecated This function is deprecated because it does not allow the 0339 caller to specify which even_base it uses. The recommended 0340 function is evdns_add_server_port_with_base(). 0341 0342 */ 0343 EVENT2_EXPORT_SYMBOL 0344 struct evdns_server_port * 0345 evdns_add_server_port(evutil_socket_t socket, int flags, 0346 evdns_request_callback_fn_type callback, void *user_data); 0347 0348 #ifdef _WIN32 0349 EVENT2_EXPORT_SYMBOL 0350 int evdns_config_windows_nameservers(void); 0351 #define EVDNS_CONFIG_WINDOWS_NAMESERVERS_IMPLEMENTED 0352 #endif 0353 0354 #ifdef __cplusplus 0355 } 0356 #endif 0357 0358 #endif /* EVENT2_EVENT_COMPAT_H_INCLUDED_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |