Loading...
Searching...
No Matches
sres.h
Go to the documentation of this file.
/*
* This file is part of the Sofia-SIP package
*
* Copyright (C) 2005 Nokia Corporation.
*
* Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef SOFIA_RESOLV_SRES_H
#define SOFIA_RESOLV_SRES_H
#include <stdarg.h>
#include "sofia-resolv/sres_config.h"
#ifdef __cplusplus
extern "C" {
#endif
enum {
SRES_RETRANSMIT_INTERVAL = 500,
#define SRES_RETRANSMIT_INTERVAL (SRES_RETRANSMIT_INTERVAL)
SRES_RETRY_INTERVAL = 1,
#define SRES_RETRY_INTERVAL (SRES_RETRY_INTERVAL)
SRES_MAX_RETRY_COUNT = 6,
#define SRES_MAX_RETRY_COUNT (SRES_MAX_RETRY_COUNT)
SRES_MAX_SEARCH = 6,
#define SRES_MAX_SEARCH (SRES_MAX_SEARCH)
SRES_MAX_NAMESERVERS = 6,
#define SRES_MAX_NAMESERVERS (SRES_MAX_NAMESERVERS)
SRES_MAXDNAME = 1025,
#define SRES_MAXDNAME (SRES_MAXDNAME)
SRES_MAX_SORTLIST = 10
#define SRES_MAX_SORTLIST (SRES_MAX_SORTLIST)
};
#ifndef SRES_RECORD_T
#define SRES_RECORD_T
typedef union sres_record sres_record_t;
#endif
#ifndef SRES_CACHE_T
#define SRES_CACHE_T
typedef struct sres_cache sres_cache_t;
#endif
typedef struct sres_resolver_s sres_resolver_t;
#ifndef SRES_CONTEXT_T
#define SRES_CONTEXT_T struct sres_context_s
#endif
typedef SRES_CONTEXT_T sres_context_t;
typedef struct sres_query_s sres_query_t;
struct sockaddr;
SRESPUBFUN sres_resolver_t *sres_resolver_new(char const *resolv_conf_path);
SRESPUBFUN sres_resolver_t *sres_resolver_copy(sres_resolver_t *);
SRESPUBFUN
sres_resolver_t *
sres_resolver_new_with_cache(char const *conf_file_path,
sres_cache_t *cache,
char const *options, ...);
SRESPUBFUN
sres_resolver_t *
sres_resolver_new_with_cache_va(char const *conf_file_path,
sres_cache_t *cache,
char const *options, va_list va);
SRESPUBFUN sres_resolver_t *sres_resolver_ref(sres_resolver_t *res);
SRESPUBFUN void sres_resolver_unref(sres_resolver_t *res);
SRESPUBFUN int sres_resolver_update(sres_resolver_t *res, int always);
SRESPUBFUN
void *sres_resolver_set_userdata(sres_resolver_t *res, void *userdata);
SRESPUBFUN
void *sres_resolver_get_userdata(sres_resolver_t const *res);
typedef void sres_answer_f(sres_context_t *context,
sres_query_t *query,
sres_record_t **answers);
SRESPUBFUN
sres_query_t *sres_query(sres_resolver_t *res,
sres_answer_f *callback,
sres_context_t *context,
uint16_t type,
char const *domain);
SRESPUBFUN
sres_query_t *sres_search(sres_resolver_t *res,
sres_answer_f *callback,
sres_context_t *context,
uint16_t type,
char const *name);
SRESPUBFUN
sres_query_t *sres_query_sockaddr(sres_resolver_t *res,
sres_answer_f *callback,
sres_context_t *context,
uint16_t type,
struct sockaddr const *addr);
SRESPUBFUN
sres_query_t *sres_query_make(sres_resolver_t *res,
sres_answer_f *callback,
sres_context_t *context,
int dummy,
uint16_t type,
char const *domain);
SRESPUBFUN
sres_query_t *sres_query_make_sockaddr(sres_resolver_t *res,
sres_answer_f *callback,
sres_context_t *context,
int dummy,
uint16_t type,
struct sockaddr const *addr);
SRESPUBFUN
void sres_query_bind(sres_query_t *q,
sres_answer_f *callback,
sres_context_t *context);
SRESPUBFUN
sres_record_t **sres_cached_answers(sres_resolver_t *res,
uint16_t type,
char const *domain);
SRESPUBFUN
sres_record_t **sres_search_cached_answers(sres_resolver_t *res,
uint16_t type,
char const *name);
SRESPUBFUN
sres_record_t **sres_cached_answers_sockaddr(sres_resolver_t *res,
uint16_t type,
struct sockaddr const *addr);
SRESPUBFUN
int sres_set_cached_srv_priority(sres_resolver_t *res,
char const *domain,
char const *target,
uint16_t port,
uint32_t newttl,
uint16_t newprio);
SRESPUBFUN
int sres_blocking_query(sres_resolver_t *res,
uint16_t type,
char const *domain,
int ignore_cache,
sres_record_t ***return_records);
SRESPUBFUN
int sres_blocking_search(sres_resolver_t *res,
uint16_t type,
char const *name,
int ignore_cache,
sres_record_t ***return_records);
SRESPUBFUN
int sres_blocking_query_sockaddr(sres_resolver_t *res,
uint16_t type,
struct sockaddr const *addr,
int ignore_cache,
sres_record_t ***return_records);
SRESPUBFUN int sres_is_blocking(sres_resolver_t *res);
SRESPUBFUN int sres_sort_answers(sres_resolver_t *, sres_record_t **answers);
SRESPUBFUN
int sres_filter_answers(sres_resolver_t *res,
sres_record_t **answers,
uint16_t type);
SRESPUBFUN void sres_free_answers(sres_resolver_t *, sres_record_t **answers);
SRESPUBFUN void sres_free_answer(sres_resolver_t *res, sres_record_t *answer);
#ifdef __cplusplus
}
#endif
#endif /* SOFIA_RESOLV_SRES_H */
sres_resolver_get_userdata
SRESPUBFUN void * sres_resolver_get_userdata(sres_resolver_t const *res)
Get userdata pointer.
Definition sres.c:848
sres_query_t
struct sres_query_s sres_query_t
Opaque type of DNS query object.
Definition sres.h:104
sres_cached_answers
SRESPUBFUN sres_record_t ** sres_cached_answers(sres_resolver_t *res, uint16_t type, char const *domain)
Get a list of matching (type/domain) records from cache.
Definition sres.c:1238
sres_search
SRESPUBFUN sres_query_t * sres_search(sres_resolver_t *res, sres_answer_f *callback, sres_context_t *context, uint16_t type, char const *name)
Search DNS.
Definition sres.c:1022
sres_resolver_copy
SRESPUBFUN sres_resolver_t * sres_resolver_copy(sres_resolver_t *)
Copy a resolver.
Definition sres.c:633
sres_blocking_query
SRESPUBFUN int sres_blocking_query(sres_resolver_t *res, uint16_t type, char const *domain, int ignore_cache, sres_record_t ***return_records)
Send a query, wait for answer, return results.
Definition sres_blocking.c:292
sres_query_bind
SRESPUBFUN void sres_query_bind(sres_query_t *q, sres_answer_f *callback, sres_context_t *context)
Rebind a DNS query.
Definition sres.c:1215
sres_cache_t
struct sres_cache sres_cache_t
Opaque type of DNS cache object.
Definition sres.h:91
sres_resolver_set_userdata
SRESPUBFUN void * sres_resolver_set_userdata(sres_resolver_t *res, void *userdata)
Set userdata pointer.
Definition sres.c:827
sres_cached_answers_sockaddr
SRESPUBFUN sres_record_t ** sres_cached_answers_sockaddr(sres_resolver_t *res, uint16_t type, struct sockaddr const *addr)
Get a list of matching (type/domain) records from cache.
Definition sres.c:1361
sres_query_make_sockaddr
SRESPUBFUN sres_query_t * sres_query_make_sockaddr(sres_resolver_t *res, sres_answer_f *callback, sres_context_t *context, int dummy, uint16_t type, struct sockaddr const *addr)
Make a reverse DNS query with socket.
Definition sres.c:1190
sres_filter_answers
SRESPUBFUN int sres_filter_answers(sres_resolver_t *res, sres_record_t **answers, uint16_t type)
Filter and sort the list of records.
Definition sres.c:1457
sres_resolver_ref
SRESPUBFUN sres_resolver_t * sres_resolver_ref(sres_resolver_t *res)
Increase reference count on a resolver object.
Definition sres.c:807
sres_query
SRESPUBFUN sres_query_t * sres_query(sres_resolver_t *res, sres_answer_f *callback, sres_context_t *context, uint16_t type, char const *domain)
Make a DNS query.
Definition sres.c:957
sres_resolver_update
SRESPUBFUN int sres_resolver_update(sres_resolver_t *res, int always)
Re-read resolv.conf if needed.
Definition sres.c:1940
sres_answer_f
void sres_answer_f(sres_context_t *context, sres_query_t *query, sres_record_t **answers)
Prototype for callback function.
Definition sres.h:151
sres_sort_answers
SRESPUBFUN int sres_sort_answers(sres_resolver_t *, sres_record_t **answers)
Sort the list of records.
Definition sres.c:1423
sres_resolver_new
SRESPUBFUN sres_resolver_t * sres_resolver_new(char const *resolv_conf_path)
New resolver object.
Definition sres.c:623
sres_resolver_unref
SRESPUBFUN void sres_resolver_unref(sres_resolver_t *res)
Decrease the reference count on a resolver object.
Definition sres.c:814
sres_resolver_t
struct sres_resolver_s sres_resolver_t
Opaque type of DNS resolver object.
Definition sres.h:95
sres_is_blocking
SRESPUBFUN int sres_is_blocking(sres_resolver_t *res)
Return true (and set resolver in blocking mode) if resolver can block.
Definition sres_blocking.c:254
sres_free_answers
SRESPUBFUN void sres_free_answers(sres_resolver_t *, sres_record_t **answers)
Free the list records.
Definition sres.c:1496
sres_context_t
struct sres_context_s sres_context_t
Application-defined type for sres_query_t context.
Definition sres.h:101
sres_blocking_query_sockaddr
SRESPUBFUN int sres_blocking_query_sockaddr(sres_resolver_t *res, uint16_t type, struct sockaddr const *addr, int ignore_cache, sres_record_t ***return_records)
Send a a reverse DNS query, wait for answer, return results.
Definition sres_blocking.c:414
sres_resolver_new_with_cache
SRESPUBFUN sres_resolver_t * sres_resolver_new_with_cache(char const *conf_file_path, sres_cache_t *cache, char const *options,...)
New resolver object.
Definition sres.c:677
sres_query_sockaddr
SRESPUBFUN sres_query_t * sres_query_sockaddr(sres_resolver_t *res, sres_answer_f *callback, sres_context_t *context, uint16_t type, struct sockaddr const *addr)
Make a reverse DNS query.
Definition sres.c:1152
sres_resolver_new_with_cache_va
SRESPUBFUN sres_resolver_t * sres_resolver_new_with_cache_va(char const *conf_file_path, sres_cache_t *cache, char const *options, va_list va)
New resolver object.
Definition sres.c:696
sres_blocking_search
SRESPUBFUN int sres_blocking_search(sres_resolver_t *res, uint16_t type, char const *name, int ignore_cache, sres_record_t ***return_records)
Search DNS, return results.
Definition sres_blocking.c:356
sres_record_t
union sres_record sres_record_t
Type representing any DNS record.
Definition sres.h:85
sres_query_make
SRESPUBFUN sres_query_t * sres_query_make(sres_resolver_t *res, sres_answer_f *callback, sres_context_t *context, int dummy, uint16_t type, char const *domain)
Make a DNS query with socket.
Definition sres.c:1175
sres_free_answer
SRESPUBFUN void sres_free_answer(sres_resolver_t *res, sres_record_t *answer)
Free and zero one record.
Definition sres.c:1484
sres_search_cached_answers
SRESPUBFUN sres_record_t ** sres_search_cached_answers(sres_resolver_t *res, uint16_t type, char const *name)
Search for a list of matching (type/name) records from cache.
Definition sres.c:1274
sres_set_cached_srv_priority
SRESPUBFUN int sres_set_cached_srv_priority(sres_resolver_t *res, char const *domain, char const *target, uint16_t port, uint32_t newttl, uint16_t newprio)
Modify the priority of the specified SRV records.
Definition sres.c:1398
sres_config.h
Configuration for Sofia DNS Resolver.
SRESPUBFUN
#define SRESPUBFUN
SRESPUBFUN declares an exported function.
Definition sres_config.h:41
uint32_t
SU_U32_T uint32_t
uint16_t
SU_U16_T uint16_t
sres_record
Union of different DNS records.
Definition sres_record.h:180

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.