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 #ifndef SOFIA_RESOLV_SRES_H
00026
00027 #define SOFIA_RESOLV_SRES_H
00028
00045 #include <stdarg.h>
00046 #include "sofia-resolv/sres_config.h"
00047
00048 #ifdef __cplusplus
00049 extern "C" {
00050 #endif
00051
00052 enum {
00054 SRES_RETRANSMIT_INTERVAL = 500,
00055 #define SRES_RETRANSMIT_INTERVAL (SRES_RETRANSMIT_INTERVAL)
00056
00058 SRES_RETRY_INTERVAL = 1,
00059 #define SRES_RETRY_INTERVAL (SRES_RETRY_INTERVAL)
00060
00062 SRES_MAX_RETRY_COUNT = 6,
00063 #define SRES_MAX_RETRY_COUNT (SRES_MAX_RETRY_COUNT)
00064
00066 SRES_MAX_SEARCH = 6,
00067 #define SRES_MAX_SEARCH (SRES_MAX_SEARCH)
00068
00070 SRES_MAX_NAMESERVERS = 6,
00071 #define SRES_MAX_NAMESERVERS (SRES_MAX_NAMESERVERS)
00072
00074 SRES_MAXDNAME = 1025,
00075 #define SRES_MAXDNAME (SRES_MAXDNAME)
00076
00078 SRES_MAX_SORTLIST = 10
00079 #define SRES_MAX_SORTLIST (SRES_MAX_SORTLIST)
00080 };
00081
00082 #ifndef SRES_RECORD_T
00083 #define SRES_RECORD_T
00084
00085 typedef union sres_record sres_record_t;
00086 #endif
00087
00088 #ifndef SRES_CACHE_T
00089 #define SRES_CACHE_T
00090
00091 typedef struct sres_cache sres_cache_t;
00092 #endif
00093
00095 typedef struct sres_resolver_s sres_resolver_t;
00096
00097 #ifndef SRES_CONTEXT_T
00098 #define SRES_CONTEXT_T struct sres_context_s
00099 #endif
00100
00101 typedef SRES_CONTEXT_T sres_context_t;
00102
00104 typedef struct sres_query_s sres_query_t;
00105
00106 struct sockaddr;
00107
00109 SRESPUBFUN sres_resolver_t *sres_resolver_new(char const *resolv_conf_path);
00110
00112 SRESPUBFUN sres_resolver_t *sres_resolver_copy(sres_resolver_t *);
00113
00115 SRESPUBFUN
00116 sres_resolver_t *
00117 sres_resolver_new_with_cache(char const *conf_file_path,
00118 sres_cache_t *cache,
00119 char const *options, ...);
00120
00122 SRESPUBFUN
00123 sres_resolver_t *
00124 sres_resolver_new_with_cache_va(char const *conf_file_path,
00125 sres_cache_t *cache,
00126 char const *options, va_list va);
00127
00129 SRESPUBFUN sres_resolver_t *sres_resolver_ref(sres_resolver_t *res);
00130
00132 SRESPUBFUN void sres_resolver_unref(sres_resolver_t *res);
00133
00135 SRESPUBFUN int sres_resolver_update(sres_resolver_t *res, int always);
00136
00138 SRESPUBFUN
00139 void *sres_resolver_set_userdata(sres_resolver_t *res, void *userdata);
00140
00142 SRESPUBFUN
00143 void *sres_resolver_get_userdata(sres_resolver_t const *res);
00144
00151 typedef void sres_answer_f(sres_context_t *context,
00152 sres_query_t *query,
00153 sres_record_t **answers);
00154
00156 SRESPUBFUN
00157 sres_query_t *sres_query(sres_resolver_t *res,
00158 sres_answer_f *callback,
00159 sres_context_t *context,
00160 uint16_t type,
00161 char const *domain);
00162
00164 SRESPUBFUN
00165 sres_query_t *sres_search(sres_resolver_t *res,
00166 sres_answer_f *callback,
00167 sres_context_t *context,
00168 uint16_t type,
00169 char const *name);
00170
00172 SRESPUBFUN
00173 sres_query_t *sres_query_sockaddr(sres_resolver_t *res,
00174 sres_answer_f *callback,
00175 sres_context_t *context,
00176 uint16_t type,
00177 struct sockaddr const *addr);
00178
00180 SRESPUBFUN
00181 sres_query_t *sres_query_make(sres_resolver_t *res,
00182 sres_answer_f *callback,
00183 sres_context_t *context,
00184 int dummy,
00185 uint16_t type,
00186 char const *domain);
00187
00189 SRESPUBFUN
00190 sres_query_t *sres_query_make_sockaddr(sres_resolver_t *res,
00191 sres_answer_f *callback,
00192 sres_context_t *context,
00193 int dummy,
00194 uint16_t type,
00195 struct sockaddr const *addr);
00196
00198 SRESPUBFUN
00199 void sres_query_bind(sres_query_t *q,
00200 sres_answer_f *callback,
00201 sres_context_t *context);
00202
00204 SRESPUBFUN
00205 sres_record_t **sres_cached_answers(sres_resolver_t *res,
00206 uint16_t type,
00207 char const *domain);
00208
00210 SRESPUBFUN
00211 sres_record_t **sres_search_cached_answers(sres_resolver_t *res,
00212 uint16_t type,
00213 char const *name);
00214
00216 SRESPUBFUN
00217 sres_record_t **sres_cached_answers_sockaddr(sres_resolver_t *res,
00218 uint16_t type,
00219 struct sockaddr const *addr);
00220
00222 SRESPUBFUN
00223 int sres_set_cached_srv_priority(sres_resolver_t *res,
00224 char const *domain,
00225 char const *target,
00226 uint16_t port,
00227 uint32_t newttl,
00228 uint16_t newprio);
00229
00230
00232 SRESPUBFUN
00233 int sres_blocking_query(sres_resolver_t *res,
00234 uint16_t type,
00235 char const *domain,
00236 int ignore_cache,
00237 sres_record_t ***return_records);
00238
00240 SRESPUBFUN
00241 int sres_blocking_search(sres_resolver_t *res,
00242 uint16_t type,
00243 char const *name,
00244 int ignore_cache,
00245 sres_record_t ***return_records);
00246
00248 SRESPUBFUN
00249 int sres_blocking_query_sockaddr(sres_resolver_t *res,
00250 uint16_t type,
00251 struct sockaddr const *addr,
00252 int ignore_cache,
00253 sres_record_t ***return_records);
00254
00256 SRESPUBFUN int sres_is_blocking(sres_resolver_t *res);
00257
00259 SRESPUBFUN int sres_sort_answers(sres_resolver_t *, sres_record_t **answers);
00260
00262 SRESPUBFUN
00263 int sres_filter_answers(sres_resolver_t *res,
00264 sres_record_t **answers,
00265 uint16_t type);
00266
00268 SRESPUBFUN void sres_free_answers(sres_resolver_t *, sres_record_t **answers);
00269
00271 SRESPUBFUN void sres_free_answer(sres_resolver_t *res, sres_record_t *answer);
00272
00273 #ifdef __cplusplus
00274 }
00275 #endif
00276
00277 #endif