00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00135 #ifndef _EVENT2_DNS_H_
00136 #define _EVENT2_DNS_H_
00137
00138 #ifdef __cplusplus
00139 extern "C" {
00140 #endif
00141
00142
00143 #include <event2/util.h>
00144
00146 #define DNS_ERR_NONE 0
00147
00148 #define DNS_ERR_FORMAT 1
00149
00151 #define DNS_ERR_SERVERFAILED 2
00152
00153 #define DNS_ERR_NOTEXIST 3
00154
00155 #define DNS_ERR_NOTIMPL 4
00156
00158 #define DNS_ERR_REFUSED 5
00159
00160 #define DNS_ERR_TRUNCATED 65
00161
00162 #define DNS_ERR_UNKNOWN 66
00163
00164 #define DNS_ERR_TIMEOUT 67
00165
00166 #define DNS_ERR_SHUTDOWN 68
00167
00168 #define DNS_ERR_CANCEL 69
00169
00170 #define DNS_IPv4_A 1
00171 #define DNS_PTR 2
00172 #define DNS_IPv6_AAAA 3
00173
00174 #define DNS_QUERY_NO_SEARCH 1
00175
00176 #define DNS_OPTION_SEARCH 1
00177 #define DNS_OPTION_NAMESERVERS 2
00178 #define DNS_OPTION_MISC 4
00179 #define DNS_OPTION_HOSTSFILE 8
00180 #define DNS_OPTIONS_ALL 15
00181
00182
00183 #define DNS_NO_SEARCH DNS_QUERY_NO_SEARCH
00184
00195 typedef void (*evdns_callback_type) (int result, char type, int count, int ttl, void *addresses, void *arg);
00196
00197 struct evdns_base;
00198 struct event_base;
00199
00212 struct evdns_base * evdns_base_new(struct event_base *event_base, int initialize_nameservers);
00213
00214
00227 void evdns_base_free(struct evdns_base *base, int fail_requests);
00228
00235 const char *evdns_err_to_string(int err);
00236
00237
00249 int evdns_base_nameserver_add(struct evdns_base *base,
00250 unsigned long int address);
00251
00264 int evdns_base_count_nameservers(struct evdns_base *base);
00265
00275 int evdns_base_clear_nameservers_and_suspend(struct evdns_base *base);
00276
00277
00288 int evdns_base_resume(struct evdns_base *base);
00289
00307 int evdns_base_nameserver_ip_add(struct evdns_base *base,
00308 const char *ip_as_string);
00309
00313 int
00314 evdns_base_nameserver_sockaddr_add(struct evdns_base *base,
00315 const struct sockaddr *sa, ev_socklen_t len, unsigned flags);
00316
00317 struct evdns_request;
00318
00330 struct evdns_request *evdns_base_resolve_ipv4(struct evdns_base *base, const char *name, int flags, evdns_callback_type callback, void *ptr);
00331
00343 struct evdns_request *evdns_base_resolve_ipv6(struct evdns_base *base, const char *name, int flags, evdns_callback_type callback, void *ptr);
00344
00345 struct in_addr;
00346 struct in6_addr;
00347
00359 struct evdns_request *evdns_base_resolve_reverse(struct evdns_base *base, const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr);
00360
00361
00373 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);
00374
00382 void evdns_cancel_request(struct evdns_base *base, struct evdns_request *req);
00383
00400 int evdns_base_set_option(struct evdns_base *base, const char *option, const char *val);
00401
00402
00425 int evdns_base_resolv_conf_parse(struct evdns_base *base, int flags, const char *const filename);
00426
00437 int evdns_base_load_hosts(struct evdns_base *base, const char *hosts_fname);
00438
00449 #ifdef WIN32
00450 int evdns_base_config_windows_nameservers(struct evdns_base *);
00451 #define EVDNS_BASE_CONFIG_WINDOWS_NAMESERVERS_IMPLEMENTED
00452 #endif
00453
00454
00458 void evdns_base_search_clear(struct evdns_base *base);
00459
00460
00466 void evdns_base_search_add(struct evdns_base *base, const char *domain);
00467
00468
00477 void evdns_base_search_ndots_set(struct evdns_base *base, const int ndots);
00478
00485 typedef void (*evdns_debug_log_fn_type)(int is_warning, const char *msg);
00486
00487
00495 void evdns_set_log_fn(evdns_debug_log_fn_type fn);
00496
00507 void evdns_set_transaction_id_fn(ev_uint16_t (*fn)(void));
00508
00518 void evdns_set_random_bytes_fn(void (*fn)(char *, size_t));
00519
00520
00521
00522
00523
00524 struct evdns_server_request;
00525 struct evdns_server_question;
00526
00538 typedef void (*evdns_request_callback_fn_type)(struct evdns_server_request *, void *);
00539 #define EVDNS_ANSWER_SECTION 0
00540 #define EVDNS_AUTHORITY_SECTION 1
00541 #define EVDNS_ADDITIONAL_SECTION 2
00542
00543 #define EVDNS_TYPE_A 1
00544 #define EVDNS_TYPE_NS 2
00545 #define EVDNS_TYPE_CNAME 5
00546 #define EVDNS_TYPE_SOA 6
00547 #define EVDNS_TYPE_PTR 12
00548 #define EVDNS_TYPE_MX 15
00549 #define EVDNS_TYPE_TXT 16
00550 #define EVDNS_TYPE_AAAA 28
00551
00552 #define EVDNS_QTYPE_AXFR 252
00553 #define EVDNS_QTYPE_ALL 255
00554
00555 #define EVDNS_CLASS_INET 1
00556
00557
00558 #define EVDNS_FLAGS_AA 0x400
00559 #define EVDNS_FLAGS_RD 0x080
00560
00571 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);
00573 void evdns_close_server_port(struct evdns_server_port *port);
00574
00578 void evdns_server_request_set_flags(struct evdns_server_request *req, int flags);
00579
00580
00581
00582 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);
00583 int evdns_server_request_add_a_reply(struct evdns_server_request *req, const char *name, int n, const void *addrs, int ttl);
00584 int evdns_server_request_add_aaaa_reply(struct evdns_server_request *req, const char *name, int n, const void *addrs, int ttl);
00585 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);
00586 int evdns_server_request_add_cname_reply(struct evdns_server_request *req, const char *name, const char *cname, int ttl);
00587
00591 int evdns_server_request_respond(struct evdns_server_request *req, int err);
00595 int evdns_server_request_drop(struct evdns_server_request *req);
00596 struct sockaddr;
00600 int evdns_server_request_get_requesting_addr(struct evdns_server_request *_req, struct sockaddr *sa, int addr_len);
00601
00603 typedef void (*evdns_getaddrinfo_cb)(int result, struct evutil_addrinfo *res, void *arg);
00604
00605 struct evdns_base;
00606 struct evdns_getaddrinfo_request;
00624 struct evdns_getaddrinfo_request *evdns_getaddrinfo(
00625 struct evdns_base *dns_base,
00626 const char *nodename, const char *servname,
00627 const struct evutil_addrinfo *hints_in,
00628 evdns_getaddrinfo_cb cb, void *arg);
00629
00630
00631
00632
00633 void evdns_getaddrinfo_cancel(struct evdns_getaddrinfo_request *req);
00634
00635 #ifdef __cplusplus
00636 }
00637 #endif
00638
00639 #endif