2006-06-03 21:49:42 +02:00
|
|
|
/* This software is Public Domain. To view a copy of the public domain dedication,
|
|
|
|
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
|
|
|
|
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
|
|
|
|
*
|
|
|
|
* I ask and expect, but do not require, that all derivative works contain an
|
|
|
|
* attribution similar to:
|
|
|
|
* Parts developed by Adam Langley <agl@imperialviolet.org>
|
|
|
|
*
|
|
|
|
* You may wish to replace the word "Parts" with something else depending on
|
|
|
|
* the amount of original code.
|
|
|
|
*
|
|
|
|
* (Derivative works does not include programs which link against, run or include
|
|
|
|
* the source verbatim in their source distributions)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EVENTDNS_H
|
|
|
|
#define EVENTDNS_H
|
|
|
|
|
2006-06-13 23:49:56 +02:00
|
|
|
/* Error codes 0-5 are as described in RFC 1035. */
|
2006-06-03 21:49:42 +02:00
|
|
|
#define DNS_ERR_NONE 0
|
2006-06-13 23:49:56 +02:00
|
|
|
/* The name server was unable to interpret the query */
|
2006-06-03 21:49:42 +02:00
|
|
|
#define DNS_ERR_FORMAT 1
|
2006-06-13 23:49:56 +02:00
|
|
|
/* The name server was unable to process this query due to a problem with the
|
|
|
|
* name server */
|
2006-06-03 21:49:42 +02:00
|
|
|
#define DNS_ERR_SERVERFAILED 2
|
2006-06-13 23:49:56 +02:00
|
|
|
/* The domain name does not exist */
|
2006-06-03 21:49:42 +02:00
|
|
|
#define DNS_ERR_NOTEXIST 3
|
2006-06-13 23:49:56 +02:00
|
|
|
/* The name server does not support the requested kind of query */
|
2006-06-03 21:49:42 +02:00
|
|
|
#define DNS_ERR_NOTIMPL 4
|
2006-06-13 23:49:56 +02:00
|
|
|
/* The name server refuses to reform the specified operation for policy
|
|
|
|
* reasons */
|
2006-06-03 21:49:42 +02:00
|
|
|
#define DNS_ERR_REFUSED 5
|
2006-06-13 23:49:56 +02:00
|
|
|
/* The reply was truncated or ill-formated */
|
2006-06-03 21:49:42 +02:00
|
|
|
#define DNS_ERR_TRUNCATED 65
|
2006-06-13 23:49:56 +02:00
|
|
|
/* An unknown error occurred */
|
2006-06-03 21:49:42 +02:00
|
|
|
#define DNS_ERR_UNKNOWN 66
|
2006-06-13 23:49:56 +02:00
|
|
|
/* Communication with the server timed out */
|
2006-06-03 21:49:42 +02:00
|
|
|
#define DNS_ERR_TIMEOUT 67
|
2006-09-25 22:38:58 +02:00
|
|
|
/* The request was canceled because the DNS subsystem was shut down. */
|
|
|
|
#define DNS_ERR_SHUTDOWN 68
|
2006-06-03 21:49:42 +02:00
|
|
|
|
|
|
|
#define DNS_IPv4_A 1
|
2006-09-24 19:52:23 +02:00
|
|
|
#define DNS_PTR 2
|
2006-06-03 21:49:42 +02:00
|
|
|
|
|
|
|
#define DNS_QUERY_NO_SEARCH 1
|
|
|
|
|
|
|
|
#define DNS_OPTION_SEARCH 1
|
|
|
|
#define DNS_OPTION_NAMESERVERS 2
|
|
|
|
#define DNS_OPTION_MISC 4
|
|
|
|
#define DNS_OPTIONS_ALL 7
|
|
|
|
|
2006-09-24 19:52:23 +02:00
|
|
|
typedef void (*evdns_callback_type) (int result, char type, int count, int ttl, void *addresses, void *arg);
|
2006-06-03 21:49:42 +02:00
|
|
|
|
2006-09-24 19:52:23 +02:00
|
|
|
int evdns_init(void);
|
2006-09-25 22:38:58 +02:00
|
|
|
void evdns_shutdown(int fail_requests);
|
2006-09-29 20:13:33 +02:00
|
|
|
const char * evdns_err_to_string(int err);
|
2006-09-24 19:52:23 +02:00
|
|
|
int evdns_nameserver_add(unsigned long int address);
|
|
|
|
int evdns_count_nameservers(void);
|
|
|
|
int evdns_clear_nameservers_and_suspend(void);
|
|
|
|
int evdns_resume(void);
|
|
|
|
int evdns_nameserver_ip_add(const char *ip_as_string);
|
|
|
|
int evdns_resolve_ipv4(const char *name, int flags, evdns_callback_type callback, void *ptr);
|
2006-08-16 20:47:24 +02:00
|
|
|
struct in_addr;
|
2006-09-24 19:52:23 +02:00
|
|
|
int evdns_resolve_reverse(struct in_addr *addr, int flags, evdns_callback_type callback, void *ptr);
|
|
|
|
int evdns_resolv_conf_parse(int flags, const char *);
|
2006-08-04 20:24:25 +02:00
|
|
|
#ifdef MS_WINDOWS
|
2006-09-24 19:52:23 +02:00
|
|
|
int evdns_config_windows_nameservers(void);
|
2006-08-04 20:24:25 +02:00
|
|
|
#endif
|
2006-09-24 19:52:23 +02:00
|
|
|
void evdns_search_clear(void);
|
|
|
|
void evdns_search_add(const char *domain);
|
|
|
|
void evdns_search_ndots_set(const int ndots);
|
2006-06-03 21:49:42 +02:00
|
|
|
|
2006-09-24 19:52:23 +02:00
|
|
|
typedef void (*evdns_debug_log_fn_type)(int warn, const char *msg);
|
|
|
|
void evdns_set_log_fn(evdns_debug_log_fn_type fn);
|
2006-07-05 23:28:37 +02:00
|
|
|
|
2006-06-03 21:49:42 +02:00
|
|
|
#define DNS_NO_SEARCH 1
|
|
|
|
|
2006-12-12 03:56:20 +01:00
|
|
|
struct evdns_server_request {
|
2006-12-12 03:49:45 +01:00
|
|
|
int flags;
|
|
|
|
int nquestions;
|
2006-12-12 03:56:20 +01:00
|
|
|
struct evdns_server_question **questions;
|
2006-12-12 03:49:45 +01:00
|
|
|
};
|
2006-12-12 03:56:20 +01:00
|
|
|
struct evdns_server_question {
|
2006-12-12 03:49:45 +01:00
|
|
|
int type;
|
|
|
|
int class;
|
|
|
|
char name[1];
|
|
|
|
};
|
2006-12-12 03:56:20 +01:00
|
|
|
typedef void (*evdns_request_callback_fn_type)(struct evdns_server_request *, void *);
|
2006-12-12 03:49:45 +01:00
|
|
|
#define EVDNS_ANSWER_SECTION 0
|
|
|
|
#define EVDNS_AUTHORITY_SECTION 1
|
|
|
|
#define EVDNS_ADDITIONAL_SECTION 2
|
2006-12-12 03:56:35 +01:00
|
|
|
|
|
|
|
#define EVDNS_TYPE_A 1
|
|
|
|
#define EVDNS_TYPE_NS 2
|
|
|
|
#define EVDNS_TYPE_CNAME 5
|
|
|
|
#define EVDNS_TYPE_SOA 6
|
|
|
|
#define EVDNS_TYPE_PTR 12
|
|
|
|
#define EVDNS_TYPE_MX 15
|
|
|
|
#define EVDNS_TYPE_TXT 16
|
|
|
|
#define EVDNS_TYPE_AAAA 28
|
|
|
|
|
|
|
|
#define EVDNS_QTYPE_AXFR 252
|
|
|
|
#define EVDNS_QTYPE_ALL 255
|
|
|
|
|
|
|
|
#define EVDNS_CLASS_INET 1
|
|
|
|
|
2006-12-12 03:56:20 +01:00
|
|
|
struct evdns_server_port *evdns_add_server_port(int socket, int is_tcp, evdns_request_callback_fn_type callback, void *user_data);
|
|
|
|
void evdns_close_server_port(struct evdns_server_port *port);
|
|
|
|
|
|
|
|
int evdns_request_add_reply(struct evdns_server_request *req, int section, const char *name, int type, int class, int ttl, int datalen, int is_name, const char *data);
|
|
|
|
int evdns_request_add_a_reply(struct evdns_server_request *req, const char *name, int n, void *addrs, int ttl);
|
|
|
|
int evdns_request_add_aaaa_reply(struct evdns_server_request *req, const char *name, int n, void *addrs, int ttl);
|
2006-12-12 03:56:28 +01:00
|
|
|
int evdns_request_add_ptr_reply(struct evdns_server_request *req, struct in_addr *in, const char *inaddr_name, const char *hostname, int ttl);
|
2006-12-12 03:56:20 +01:00
|
|
|
int evdns_request_add_cname_reply(struct evdns_server_request *req, const char *name, const char *cname, int ttl);
|
|
|
|
|
|
|
|
int evdns_request_respond(struct evdns_server_request *req, int flags);
|
|
|
|
int evdns_request_drop(struct evdns_server_request *req);
|
2006-12-12 03:49:45 +01:00
|
|
|
|
2006-06-03 21:49:42 +02:00
|
|
|
#endif // !EVENTDNS_H
|