MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
evdns.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006 Niels Provos <provos@citi.umich.edu>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 /*
29  * The original DNS code is due to Adam Langley with heavy
30  * modifications by Nick Mathewson. Adam put his DNS software in the
31  * public domain. You can find his original copyright below. Please,
32  * aware that the code as part of libevent is governed by the 3-clause
33  * BSD license above.
34  *
35  * This software is Public Domain. To view a copy of the public domain dedication,
36  * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
37  * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
38  *
39  * I ask and expect, but do not require, that all derivative works contain an
40  * attribution similar to:
41  * Parts developed by Adam Langley <agl@imperialviolet.org>
42  *
43  * You may wish to replace the word "Parts" with something else depending on
44  * the amount of original code.
45  *
46  * (Derivative works does not include programs which link against, run or include
47  * the source verbatim in their source distributions)
48  */
49 
160 #ifndef EVENTDNS_H
161 #define EVENTDNS_H
162 
163 #ifdef __cplusplus
164 extern "C" {
165 #endif
166 
167 /* For integer types. */
168 #include <evutil.h>
169 
171 #define DNS_ERR_NONE 0
172 
173 #define DNS_ERR_FORMAT 1
174 
176 #define DNS_ERR_SERVERFAILED 2
177 
178 #define DNS_ERR_NOTEXIST 3
179 
180 #define DNS_ERR_NOTIMPL 4
181 
183 #define DNS_ERR_REFUSED 5
184 
185 #define DNS_ERR_TRUNCATED 65
186 
187 #define DNS_ERR_UNKNOWN 66
188 
189 #define DNS_ERR_TIMEOUT 67
190 
191 #define DNS_ERR_SHUTDOWN 68
192 
193 #define DNS_IPv4_A 1
194 #define DNS_PTR 2
195 #define DNS_IPv6_AAAA 3
196 
197 #define DNS_QUERY_NO_SEARCH 1
198 
199 #define DNS_OPTION_SEARCH 1
200 #define DNS_OPTION_NAMESERVERS 2
201 #define DNS_OPTION_MISC 4
202 #define DNS_OPTIONS_ALL 7
203 
211 typedef void (*evdns_callback_type) (int result, char type, int count, int ttl, void *addresses, void *arg);
212 
223 int evdns_init(void);
224 
225 
237 void evdns_shutdown(int fail_requests);
238 
239 
246 const char *evdns_err_to_string(int err);
247 
248 
259 int evdns_nameserver_add(unsigned long int address);
260 
261 
273 int evdns_count_nameservers(void);
274 
275 
284 int evdns_clear_nameservers_and_suspend(void);
285 
286 
296 int evdns_resume(void);
297 
298 
308 int evdns_nameserver_ip_add(const char *ip_as_string);
309 
310 
321 int evdns_resolve_ipv4(const char *name, int flags, evdns_callback_type callback, void *ptr);
322 
323 
334 int evdns_resolve_ipv6(const char *name, int flags, evdns_callback_type callback, void *ptr);
335 
336 struct in_addr;
337 struct in6_addr;
338 
349 int evdns_resolve_reverse(const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr);
350 
351 
362 int evdns_resolve_reverse_ipv6(const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr);
363 
364 
377 int evdns_set_option(const char *option, const char *val, int flags);
378 
379 
401 int evdns_resolv_conf_parse(int flags, const char *const filename);
402 
403 
414 #ifdef WIN32
415 int evdns_config_windows_nameservers(void);
416 #endif
417 
418 
422 void evdns_search_clear(void);
423 
424 
430 void evdns_search_add(const char *domain);
431 
432 
441 void evdns_search_ndots_set(const int ndots);
442 
449 typedef void (*evdns_debug_log_fn_type)(int is_warning, const char *msg);
450 
451 
457 void evdns_set_log_fn(evdns_debug_log_fn_type fn);
458 
465 void evdns_set_transaction_id_fn(ev_uint16_t (*fn)(void));
466 
467 #define DNS_NO_SEARCH 1
468 
469 /*
470  * Structures and functions used to implement a DNS server.
471  */
472 
474  int flags;
475  int nquestions;
476  struct evdns_server_question **questions;
477 };
479  int type;
480 #ifdef __cplusplus
481  int dns_question_class;
482 #else
483  /* You should refer to this field as "dns_question_class". The
484  * name "class" works in C for backward compatibility, and will be
485  * removed in a future version. (1.5 or later). */
486  int class;
487 #define dns_question_class class
488 #endif
489  char name[1];
490 };
491 typedef void (*evdns_request_callback_fn_type)(struct evdns_server_request *, void *);
492 #define EVDNS_ANSWER_SECTION 0
493 #define EVDNS_AUTHORITY_SECTION 1
494 #define EVDNS_ADDITIONAL_SECTION 2
495 
496 #define EVDNS_TYPE_A 1
497 #define EVDNS_TYPE_NS 2
498 #define EVDNS_TYPE_CNAME 5
499 #define EVDNS_TYPE_SOA 6
500 #define EVDNS_TYPE_PTR 12
501 #define EVDNS_TYPE_MX 15
502 #define EVDNS_TYPE_TXT 16
503 #define EVDNS_TYPE_AAAA 28
504 
505 #define EVDNS_QTYPE_AXFR 252
506 #define EVDNS_QTYPE_ALL 255
507 
508 #define EVDNS_CLASS_INET 1
509 
510 struct evdns_server_port *evdns_add_server_port(int socket, int is_tcp, evdns_request_callback_fn_type callback, void *user_data);
511 void evdns_close_server_port(struct evdns_server_port *port);
512 
513 int evdns_server_request_add_reply(struct evdns_server_request *req, int section, const char *name, int type, int dns_class, int ttl, int datalen, int is_name, const char *data);
514 int evdns_server_request_add_a_reply(struct evdns_server_request *req, const char *name, int n, void *addrs, int ttl);
515 int evdns_server_request_add_aaaa_reply(struct evdns_server_request *req, const char *name, int n, void *addrs, int ttl);
516 int evdns_server_request_add_ptr_reply(struct evdns_server_request *req, struct in_addr *in, const char *inaddr_name, const char *hostname, int ttl);
517 int evdns_server_request_add_cname_reply(struct evdns_server_request *req, const char *name, const char *cname, int ttl);
518 
519 int evdns_server_request_respond(struct evdns_server_request *req, int err);
520 int evdns_server_request_drop(struct evdns_server_request *req);
521 struct sockaddr;
522 int evdns_server_request_get_requesting_addr(struct evdns_server_request *_req, struct sockaddr *sa, int addr_len);
523 
524 #ifdef __cplusplus
525 }
526 #endif
527 
528 #endif /* !EVENTDNS_H */