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 EVENTDNS_H
00161 #define EVENTDNS_H
00162
00163 #ifdef __cplusplus
00164 extern "C" {
00165 #endif
00166
00167
00168 #include <evutil.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_IPv4_A 1
00194 #define DNS_PTR 2
00195 #define DNS_IPv6_AAAA 3
00196
00197 #define DNS_QUERY_NO_SEARCH 1
00198
00199 #define DNS_OPTION_SEARCH 1
00200 #define DNS_OPTION_NAMESERVERS 2
00201 #define DNS_OPTION_MISC 4
00202 #define DNS_OPTIONS_ALL 7
00203
00211 typedef void (*evdns_callback_type) (int result, char type, int count, int ttl, void *addresses, void *arg);
00212
00223 int evdns_init(void);
00224
00225
00237 void evdns_shutdown(int fail_requests);
00238
00239
00246 const char *evdns_err_to_string(int err);
00247
00248
00259 int evdns_nameserver_add(unsigned long int address);
00260
00261
00273 int evdns_count_nameservers(void);
00274
00275
00284 int evdns_clear_nameservers_and_suspend(void);
00285
00286
00296 int evdns_resume(void);
00297
00298
00308 int evdns_nameserver_ip_add(const char *ip_as_string);
00309
00310
00321 int evdns_resolve_ipv4(const char *name, int flags, evdns_callback_type callback, void *ptr);
00322
00323
00334 int evdns_resolve_ipv6(const char *name, int flags, evdns_callback_type callback, void *ptr);
00335
00336 struct in_addr;
00337 struct in6_addr;
00338
00349 int evdns_resolve_reverse(const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr);
00350
00351
00362 int evdns_resolve_reverse_ipv6(const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr);
00363
00364
00377 int evdns_set_option(const char *option, const char *val, int flags);
00378
00379
00401 int evdns_resolv_conf_parse(int flags, const char *const filename);
00402
00403
00414 #ifdef MS_WINDOWS
00415 int evdns_config_windows_nameservers(void);
00416 #endif
00417
00418
00422 void evdns_search_clear(void);
00423
00424
00430 void evdns_search_add(const char *domain);
00431
00432
00441 void evdns_search_ndots_set(const int ndots);
00442
00449 typedef void (*evdns_debug_log_fn_type)(int is_warning, const char *msg);
00450
00451
00457 void evdns_set_log_fn(evdns_debug_log_fn_type fn);
00458
00465 void evdns_set_transaction_id_fn(ev_uint16_t (*fn)(void));
00466
00467 #define DNS_NO_SEARCH 1
00468
00469
00470
00471
00472
00473 struct evdns_server_request {
00474 int flags;
00475 int nquestions;
00476 struct evdns_server_question **questions;
00477 };
00478 struct evdns_server_question {
00479 int type;
00480 #ifdef __cplusplus
00481 int dns_question_class;
00482 #else
00483
00484
00485
00486 int class;
00487 #define dns_question_class class
00488 #endif
00489 char name[1];
00490 };
00491 typedef void (*evdns_request_callback_fn_type)(struct evdns_server_request *, void *);
00492 #define EVDNS_ANSWER_SECTION 0
00493 #define EVDNS_AUTHORITY_SECTION 1
00494 #define EVDNS_ADDITIONAL_SECTION 2
00495
00496 #define EVDNS_TYPE_A 1
00497 #define EVDNS_TYPE_NS 2
00498 #define EVDNS_TYPE_CNAME 5
00499 #define EVDNS_TYPE_SOA 6
00500 #define EVDNS_TYPE_PTR 12
00501 #define EVDNS_TYPE_MX 15
00502 #define EVDNS_TYPE_TXT 16
00503 #define EVDNS_TYPE_AAAA 28
00504
00505 #define EVDNS_QTYPE_AXFR 252
00506 #define EVDNS_QTYPE_ALL 255
00507
00508 #define EVDNS_CLASS_INET 1
00509
00510 struct evdns_server_port *evdns_add_server_port(int socket, int is_tcp, evdns_request_callback_fn_type callback, void *user_data);
00511 void evdns_close_server_port(struct evdns_server_port *port);
00512
00513 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);
00514 int evdns_server_request_add_a_reply(struct evdns_server_request *req, const char *name, int n, void *addrs, int ttl);
00515 int evdns_server_request_add_aaaa_reply(struct evdns_server_request *req, const char *name, int n, void *addrs, int ttl);
00516 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);
00517 int evdns_server_request_add_cname_reply(struct evdns_server_request *req, const char *name, const char *cname, int ttl);
00518
00519 int evdns_server_request_respond(struct evdns_server_request *req, int err);
00520 int evdns_server_request_drop(struct evdns_server_request *req);
00521 struct sockaddr;
00522 int evdns_server_request_get_requesting_addr(struct evdns_server_request *_req, struct sockaddr *sa, int addr_len);
00523
00524 #ifdef __cplusplus
00525 }
00526 #endif
00527
00528 #endif