Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PJLIB_UTIL_RESOLVER_H__
00021 #define __PJLIB_UTIL_RESOLVER_H__
00022
00027 #include <pjlib-util/dns.h>
00028
00029
00030 PJ_BEGIN_DECL
00031
00032
00165 typedef struct pj_dns_resolver pj_dns_resolver;
00166
00170 typedef struct pj_dns_async_query pj_dns_async_query;
00171
00182 typedef void pj_dns_callback(void *user_data,
00183 pj_status_t status,
00184 pj_dns_parsed_packet *response);
00185
00186
00190 typedef struct pj_dns_settings
00191 {
00192 unsigned options;
00193 unsigned qretr_delay;
00194 unsigned qretr_count;
00195 unsigned cache_max_ttl;
00197 unsigned good_ns_ttl;
00198 unsigned bad_ns_ttl;
00199 } pj_dns_settings;
00200
00201
00206 typedef struct pj_dns_a_record
00207 {
00209 pj_str_t name;
00210
00214 pj_str_t alias;
00215
00217 unsigned addr_count;
00218
00220 pj_in_addr addr[PJ_DNS_MAX_IP_IN_A_REC];
00221
00223 char buf_[128];
00224
00225 } pj_dns_a_record;
00226
00227
00233 PJ_DECL(void) pj_dns_settings_default(pj_dns_settings *s);
00234
00235
00260 PJ_DECL(pj_status_t) pj_dns_resolver_create(pj_pool_factory *pf,
00261 const char *name,
00262 unsigned options,
00263 pj_timer_heap_t *timer,
00264 pj_ioqueue_t *ioqueue,
00265 pj_dns_resolver **p_resolver);
00266
00267
00284 PJ_DECL(pj_status_t) pj_dns_resolver_set_ns(pj_dns_resolver *resolver,
00285 unsigned count,
00286 const pj_str_t servers[],
00287 const pj_uint16_t ports[]);
00288
00289
00298 PJ_DECL(pj_status_t) pj_dns_resolver_get_settings(pj_dns_resolver *resolver,
00299 pj_dns_settings *st);
00300
00301
00312 PJ_DECL(pj_status_t) pj_dns_resolver_set_settings(pj_dns_resolver *resolver,
00313 const pj_dns_settings *st);
00314
00315
00327 PJ_DECL(void) pj_dns_resolver_handle_events(pj_dns_resolver *resolver,
00328 const pj_time_val *timeout);
00329
00330
00341 PJ_DECL(pj_status_t) pj_dns_resolver_destroy(pj_dns_resolver *resolver,
00342 pj_bool_t notify);
00343
00344
00376 PJ_DECL(pj_status_t) pj_dns_resolver_start_query(pj_dns_resolver *resolver,
00377 const pj_str_t *name,
00378 int type,
00379 unsigned options,
00380 pj_dns_callback *cb,
00381 void *user_data,
00382 pj_dns_async_query **p_query);
00383
00393 PJ_DECL(pj_status_t) pj_dns_resolver_cancel_query(pj_dns_async_query *query,
00394 pj_bool_t notify);
00395
00406 PJ_DECL(pj_status_t) pj_dns_parse_a_response(const pj_dns_parsed_packet *pkt,
00407 pj_dns_a_record *rec);
00408
00409
00427 PJ_DECL(pj_status_t) pj_dns_resolver_add_entry(pj_dns_resolver *resolver,
00428 const pj_dns_parsed_packet *pkt,
00429 pj_bool_t set_ttl);
00430
00439 PJ_DECL(unsigned) pj_dns_resolver_get_cached_count(pj_dns_resolver *resolver);
00440
00441
00448 PJ_DECL(void) pj_dns_resolver_dump(pj_dns_resolver *resolver,
00449 pj_bool_t detail);
00450
00451
00456 PJ_END_DECL
00457
00458
00459 #endif
00460