libevent
2.2.1
Event notification library
|
Go to the documentation of this file.
141 #ifndef EVENT2_DNS_H_INCLUDED_
142 #define EVENT2_DNS_H_INCLUDED_
144 #include <event2/visibility.h>
154 #define DNS_ERR_NONE 0
156 #define DNS_ERR_FORMAT 1
159 #define DNS_ERR_SERVERFAILED 2
161 #define DNS_ERR_NOTEXIST 3
163 #define DNS_ERR_NOTIMPL 4
166 #define DNS_ERR_REFUSED 5
168 #define DNS_ERR_TRUNCATED 65
170 #define DNS_ERR_UNKNOWN 66
172 #define DNS_ERR_TIMEOUT 67
174 #define DNS_ERR_SHUTDOWN 68
176 #define DNS_ERR_CANCEL 69
180 #define DNS_ERR_NODATA 70
184 #define DNS_IPv6_AAAA 3
188 #define DNS_QUERY_NO_SEARCH 0x01
190 #define DNS_QUERY_USEVC 0x02
192 #define DNS_QUERY_IGNTC 0x04
194 #define DNS_CNAME_CALLBACK 0x80
197 #define DNS_OPTION_SEARCH 1
199 #define DNS_OPTION_NAMESERVERS 2
215 #define DNS_OPTION_MISC 4
217 #define DNS_OPTION_HOSTSFILE 8
225 #define DNS_OPTIONS_ALL ( \
226 DNS_OPTION_SEARCH | \
227 DNS_OPTION_NAMESERVERS | \
229 DNS_OPTION_HOSTSFILE | \
234 #define DNS_OPTION_NAMESERVERS_NO_DEFAULT 16
237 #define DNS_NO_SEARCH DNS_QUERY_NO_SEARCH
249 typedef void (*
evdns_callback_type) (
int result,
char type,
int count,
int ttl,
void *addresses,
void *arg);
255 #define EVDNS_BASE_INITIALIZE_NAMESERVERS 1
258 #define EVDNS_BASE_NO_CACHE 0x10
261 #define EVDNS_BASE_DISABLE_WHEN_INACTIVE 0x8000
265 #define EVDNS_BASE_NAMESERVERS_NO_DEFAULT 0x10000
268 #define EVDNS_ERROR_NONE 0
270 #define EVDNS_ERROR_FAILED_TO_OPEN_FILE 1
272 #define EVDNS_ERROR_FAILED_TO_STAT_FILE 2
274 #define EVDNS_ERROR_FILE_TOO_LARGE 3
276 #define EVDNS_ERROR_OUT_OF_MEMORY 4
278 #define EVDNS_ERROR_SHORT_READ_FROM_FILE 5
280 #define EVDNS_ERROR_NO_NAMESERVERS_CONFIGURED 6
370 unsigned long int address);
432 const char *ip_as_string);
440 const struct sockaddr *sa, ev_socklen_t len,
unsigned flags);
442 struct evdns_request;
591 #if defined(EVENT_IN_DOXYGEN_) || defined(_WIN32)
604 #define EVDNS_BASE_CONFIG_WINDOWS_NAMESERVERS_IMPLEMENTED
658 struct evdns_server_request;
659 struct evdns_server_question;
673 #define EVDNS_ANSWER_SECTION 0
674 #define EVDNS_AUTHORITY_SECTION 1
675 #define EVDNS_ADDITIONAL_SECTION 2
677 #define EVDNS_TYPE_A 1
678 #define EVDNS_TYPE_NS 2
679 #define EVDNS_TYPE_CNAME 5
680 #define EVDNS_TYPE_SOA 6
681 #define EVDNS_TYPE_PTR 12
682 #define EVDNS_TYPE_MX 15
683 #define EVDNS_TYPE_TXT 16
684 #define EVDNS_TYPE_AAAA 28
686 #define EVDNS_QTYPE_AXFR 252
687 #define EVDNS_QTYPE_ALL 255
689 #define EVDNS_CLASS_INET 1
692 #define EVDNS_FLAGS_AA 0x400
693 #define EVDNS_FLAGS_RD 0x080
709 struct evconnlistener;
724 struct event_base *base,
struct evconnlistener *listener,
int flags,
771 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);
773 int evdns_server_request_add_a_reply(
struct evdns_server_request *req,
const char *name,
int n,
const void *addrs,
int ttl);
775 int evdns_server_request_add_aaaa_reply(
struct evdns_server_request *req,
const char *name,
int n,
const void *addrs,
int ttl);
777 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);
779 int evdns_server_request_add_cname_reply(
struct evdns_server_request *req,
const char *name,
const char *cname,
int ttl);
802 struct evdns_getaddrinfo_request;
830 struct evdns_base *dns_base,
831 const char *nodename,
const char *servname,
839 void evdns_getaddrinfo_cancel(
struct evdns_getaddrinfo_request *req);
855 struct sockaddr *sa, ev_socklen_t len);
EVENT2_EXPORT_SYMBOL int evdns_base_nameserver_sockaddr_add(struct evdns_base *base, const struct sockaddr *sa, ev_socklen_t len, unsigned flags)
Add a nameserver by sockaddr.
EVENT2_EXPORT_SYMBOL int evdns_server_request_get_requesting_addr(struct evdns_server_request *req, struct sockaddr *sa, int addr_len)
Get the address that made a DNS request.
void(* evdns_getaddrinfo_cb)(int result, struct evutil_addrinfo *res, void *arg)
Callback for evdns_getaddrinfo.
Definition: dns.h:799
EVENT2_EXPORT_SYMBOL int evdns_base_resume(struct evdns_base *base)
Resume normal operation and continue any suspended resolve requests.
EVENT2_EXPORT_SYMBOL void evdns_close_server_port(struct evdns_server_port *port)
Close down a DNS server port, and free associated structures.
void(* evdns_debug_log_fn_type)(int is_warning, const char *msg)
A callback that is invoked when a log message is generated.
Definition: dns.h:641
EVENT2_EXPORT_SYMBOL int evdns_base_get_nameserver_addr(struct evdns_base *base, int idx, struct sockaddr *sa, ev_socklen_t len)
Retrieve the address of the 'idx'th configured nameserver.
EVENT2_EXPORT_SYMBOL int evdns_server_request_respond(struct evdns_server_request *req, int err)
Send back a response to a DNS request, and free the request structure.
evdns_server_option
List of configurable evdns_server_port options.
Definition: dns.h:736
EVENT2_EXPORT_SYMBOL void evdns_base_clear_host_addresses(struct evdns_base *base)
Remove all hosts entries that have been loaded into the event_base via evdns_base_load_hosts or via e...
EVENT2_EXPORT_SYMBOL struct evdns_request * evdns_base_resolve_ipv4(struct evdns_base *base, const char *name, int flags, evdns_callback_type callback, void *ptr)
Lookup an A record for a given name.
EVENT2_EXPORT_SYMBOL int evdns_server_request_drop(struct evdns_server_request *req)
Free a DNS request without sending back a reply.
Structure to hold information and state for a Libevent dispatch loop.
Definition: event.h:219
EVENT2_EXPORT_SYMBOL void evdns_cache_write(struct evdns_base *dns_base, char *nodename, struct evutil_addrinfo *res, int ttl)
Write an entry to the evdns cache.
@ EVDNS_SOPT_TCP_MAX_CLIENTS
Maximum number of simultaneous tcp connections (clients) that server can hold.
Definition: dns.h:741
EVENT2_EXPORT_SYMBOL struct evdns_request * evdns_base_resolve_ipv6(struct evdns_base *base, const char *name, int flags, evdns_callback_type callback, void *ptr)
Lookup an AAAA record for a given name.
EVENT2_EXPORT_SYMBOL int evdns_base_load_hosts(struct evdns_base *base, const char *hosts_fname)
Load an /etc/hosts-style file from 'hosts_fname' into 'base'.
EVENT2_EXPORT_SYMBOL int evdns_base_get_nameserver_fd(struct evdns_base *base, int idx)
Retrieve the fd of the 'idx'th configured nameserver.
EVENT2_EXPORT_SYMBOL void evdns_base_search_ndots_set(struct evdns_base *base, const int ndots)
Set the 'ndots' parameter for searches.
EVENT2_EXPORT_SYMBOL void evdns_cancel_request(struct evdns_base *base, struct evdns_request *req)
Cancels a pending DNS resolution request.
EVENT2_EXPORT_SYMBOL int evdns_cache_lookup(struct evdns_base *base, const char *nodename, struct evutil_addrinfo *hints, ev_uint16_t port, struct evutil_addrinfo **res)
Lookup an entry from the evdns cache.
EVENT2_EXPORT_SYMBOL void evdns_base_search_clear(struct evdns_base *base)
Clear the list of search domains.
EVENT2_EXPORT_SYMBOL struct evdns_request * evdns_base_resolve_reverse(struct evdns_base *base, const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr)
Lookup a PTR record for a given IP address.
EVENT2_EXPORT_SYMBOL int evdns_base_resolv_conf_parse(struct evdns_base *base, int flags, const char *const filename)
Parse a resolv.conf file.
EVENT2_EXPORT_SYMBOL void evdns_base_free(struct evdns_base *base, int fail_requests)
Shut down the asynchronous DNS resolver and terminate all active requests.
@ EVDNS_SOPT_TCP_IDLE_TIMEOUT
Idle timeout (in seconds) of incoming TCP connections.
Definition: dns.h:748
EVENT2_EXPORT_SYMBOL struct evdns_server_port * evdns_add_server_port_with_base(struct event_base *base, evutil_socket_t socket, int flags, evdns_request_callback_fn_type callback, void *user_data)
Create a new UDP DNS server port.
void(* evdns_request_callback_fn_type)(struct evdns_server_request *, void *)
A callback to implement a DNS server.
Definition: dns.h:672
EVENT2_EXPORT_SYMBOL struct evdns_request * evdns_base_resolve_reverse_ipv6(struct evdns_base *base, const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr)
Lookup a PTR record for a given IPv6 address.
EVENT2_EXPORT_SYMBOL void evdns_set_log_fn(evdns_debug_log_fn_type fn)
Set the callback function to handle DNS log messages.
void(* evdns_callback_type)(int result, char type, int count, int ttl, void *addresses, void *arg)
The callback that contains the results from a lookup.
Definition: dns.h:249
EVENT2_EXPORT_SYMBOL struct evdns_server_port * evdns_add_server_port_with_listener(struct event_base *base, struct evconnlistener *listener, int flags, evdns_request_callback_fn_type callback, void *user_data)
Create a new TCP DNS server port.
EVENT2_EXPORT_SYMBOL int evdns_base_config_windows_nameservers(struct evdns_base *)
Obtain nameserver information using the Windows API.
EVENT2_EXPORT_SYMBOL int evdns_base_nameserver_ip_add(struct evdns_base *base, const char *ip_as_string)
Add a nameserver by string address.
EVENT2_EXPORT_SYMBOL struct evdns_getaddrinfo_request * evdns_getaddrinfo(struct evdns_base *dns_base, const char *nodename, const char *servname, const struct evutil_addrinfo *hints_in, evdns_getaddrinfo_cb cb, void *arg)
Make a non-blocking getaddrinfo request using the dns_base in 'dns_base'.
EVENT2_EXPORT_SYMBOL struct evdns_base * evdns_base_new(struct event_base *event_base, int flags)
Initialize the asynchronous DNS library.
EVENT2_EXPORT_SYMBOL void evdns_base_search_add(struct evdns_base *base, const char *domain)
Add a domain to the list of search domains.
EVENT2_EXPORT_SYMBOL int evdns_base_set_option(struct evdns_base *base, const char *option, const char *val)
Set the value of a configuration option.
Common convenience functions for cross-platform portability and related socket manipulations.
const EVENT2_EXPORT_SYMBOL char * evdns_err_to_string(int err)
Convert a DNS error code to a string.
EVENT2_EXPORT_SYMBOL int evdns_base_nameserver_add(struct evdns_base *base, unsigned long int address)
Add a nameserver.
A definition of struct addrinfo for systems that lack it.
Definition: util.h:731
EVENT2_EXPORT_SYMBOL int evdns_base_count_nameservers(struct evdns_base *base)
Get the number of configured nameservers.
EVENT2_EXPORT_SYMBOL void evdns_server_request_set_flags(struct evdns_server_request *req, int flags)
Sets some flags in a reply we're building.
EVENT2_EXPORT_SYMBOL int evdns_base_clear_nameservers_and_suspend(struct evdns_base *base)
Remove all configured nameservers, and suspend all pending resolves.
EVENT2_EXPORT_SYMBOL int evdns_server_port_set_option(struct evdns_server_port *port, enum evdns_server_option option, size_t value)
Configure DNS server.
#define evutil_socket_t
A type wide enough to hold the output of "socket()" or "accept()".
Definition: util.h:325