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
00160 #ifndef _EVENT2_DNS_H_
00161 #define _EVENT2_DNS_H_
00162
00163 #ifdef __cplusplus
00164 extern "C" {
00165 #endif
00166
00167
00168 #include <event2/util.h>
00169
00171 #define DNS_ERR_NONE 0
00172
00173 #define DNS_ERR_FORMAT 1
00174
00176 #define DNS_ERR_SERVERFAILED 2
00177
00178 #define DNS_ERR_NOTEXIST 3
00179
00180 #define DNS_ERR_NOTIMPL 4
00181
00183 #define DNS_ERR_REFUSED 5
00184
00185 #define DNS_ERR_TRUNCATED 65
00186
00187 #define DNS_ERR_UNKNOWN 66
00188
00189 #define DNS_ERR_TIMEOUT 67
00190
00191 #define DNS_ERR_SHUTDOWN 68
00192
00193 #define DNS_ERR_CANCEL 69
00194
00195 #define DNS_IPv4_A 1
00196 #define DNS_PTR 2
00197 #define DNS_IPv6_AAAA 3
00198
00199 #define DNS_QUERY_NO_SEARCH 1
00200
00201 #define DNS_OPTION_SEARCH 1
00202 #define DNS_OPTION_NAMESERVERS 2
00203 #define DNS_OPTION_MISC 4
00204 #define DNS_OPTIONS_ALL 7
00205
00213 typedef void (*evdns_callback_type) (int result, char type, int count, int ttl, void *addresses, void *arg);
00214
00215 struct evdns_base;
00216 struct event_base;
00217
00230 struct evdns_base * evdns_base_new(struct event_base *event_base, int initialize_nameservers);
00231
00232
00245 void evdns_base_free(struct evdns_base *base, int fail_requests);
00246
00253 const char *evdns_err_to_string(int err);
00254
00255
00267 int evdns_base_nameserver_add(struct evdns_base *base,
00268 unsigned long int address);
00269
00282 int evdns_base_count_nameservers(struct evdns_base *base);
00283
00293 int evdns_base_clear_nameservers_and_suspend(struct evdns_base *base);
00294
00295
00306 int evdns_base_resume(struct evdns_base *base);
00307
00325 int evdns_base_nameserver_ip_add(struct evdns_base *base,
00326 const char *ip_as_string);
00327
00328 struct evdns_request;
00329
00341 struct evdns_request *evdns_base_resolve_ipv4(struct evdns_base *base, const char *name, int flags, evdns_callback_type callback, void *ptr);
00342
00354 struct evdns_request *evdns_base_resolve_ipv6(struct evdns_base *base, const char *name, int flags, evdns_callback_type callback, void *ptr);
00355
00356 struct in_addr;
00357 struct in6_addr;
00358
00370 struct evdns_request *evdns_base_resolve_reverse(struct evdns_base *base, const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr);
00371
00372
00384 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);
00385
00393 void evdns_cancel_request(struct evdns_base *base, struct evdns_request *req);
00394
00411 int evdns_base_set_option(struct evdns_base *base, const char *option, const char *val, int flags);
00412
00413
00436 int evdns_base_resolv_conf_parse(struct evdns_base *base, int flags, const char *const filename);
00437
00438
00449 #ifdef MS_WINDOWS
00450 int evdns_config_windows_nameservers(void);
00451 #endif
00452
00453
00457 void evdns_base_search_clear(struct evdns_base *base);
00458
00459
00465 void evdns_base_search_add(struct evdns_base *base, const char *domain);
00466
00467
00476 void evdns_base_search_ndots_set(struct evdns_base *base, const int ndots);
00477
00484 typedef void (*evdns_debug_log_fn_type)(int is_warning, const char *msg);
00485
00486
00492 void evdns_set_log_fn(evdns_debug_log_fn_type fn);
00493
00501 void evdns_set_transaction_id_fn(ev_uint16_t (*fn)(void));
00502
00509 void evdns_set_random_bytes_fn(void (*fn)(char *, size_t));
00510
00511 #define DNS_NO_SEARCH 1
00512
00513
00514
00515
00516
00517 struct evdns_server_request;
00518 struct evdns_server_question;
00519
00531 typedef void (*evdns_request_callback_fn_type)(struct evdns_server_request *, void *);
00532 #define EVDNS_ANSWER_SECTION 0
00533 #define EVDNS_AUTHORITY_SECTION 1
00534 #define EVDNS_ADDITIONAL_SECTION 2
00535
00536 #define EVDNS_TYPE_A 1
00537 #define EVDNS_TYPE_NS 2
00538 #define EVDNS_TYPE_CNAME 5
00539 #define EVDNS_TYPE_SOA 6
00540 #define EVDNS_TYPE_PTR 12
00541 #define EVDNS_TYPE_MX 15
00542 #define EVDNS_TYPE_TXT 16
00543 #define EVDNS_TYPE_AAAA 28
00544
00545 #define EVDNS_QTYPE_AXFR 252
00546 #define EVDNS_QTYPE_ALL 255
00547
00548 #define EVDNS_CLASS_INET 1
00549
00550
00551 #define EVDNS_FLAGS_AA 0x400
00552 #define EVDNS_FLAGS_RD 0x080
00553
00564 struct evdns_server_port *evdns_add_server_port_with_base(struct event_base *base, evutil_socket_t socket, int is_tcp, evdns_request_callback_fn_type callback, void *user_data);
00566 void evdns_close_server_port(struct evdns_server_port *port);
00567
00571 void evdns_server_request_set_flags(struct evdns_server_request *req, int flags);
00572
00573
00574
00575 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);
00576 int evdns_server_request_add_a_reply(struct evdns_server_request *req, const char *name, int n, void *addrs, int ttl);
00577 int evdns_server_request_add_aaaa_reply(struct evdns_server_request *req, const char *name, int n, void *addrs, int ttl);
00578 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);
00579 int evdns_server_request_add_cname_reply(struct evdns_server_request *req, const char *name, const char *cname, int ttl);
00580
00584 int evdns_server_request_respond(struct evdns_server_request *req, int err);
00588 int evdns_server_request_drop(struct evdns_server_request *req);
00589 struct sockaddr;
00593 int evdns_server_request_get_requesting_addr(struct evdns_server_request *_req, struct sockaddr *sa, int addr_len);
00594
00595 #ifdef __cplusplus
00596 }
00597 #endif
00598
00599 #endif