Asterisk - The Open Source Telephony Project  21.4.1
dns.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Written by Thorsten Lockert <tholo@trollphone.org>
5  *
6  * Funding provided by Troll Phone Networks AS
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*! \file
20  * \brief DNS support for Asterisk
21  * \author Thorsten Lockert <tholo@trollphone.org>
22  */
23 
24 #ifndef _ASTERISK_DNS_H
25 #define _ASTERISK_DNS_H
26 
27 /*! \brief DNS search return values */
29  AST_DNS_SEARCH_FAILURE = -1, /*!< DNS search resulted in failure */
30  AST_DNS_SEARCH_NO_RECORDS = 0, /*!< DNS search yielded no results */
31  AST_DNS_SEARCH_SUCCESS = 1 /*!< DNS search yielded at least one discovered record */
32 };
33 
34 /*!
35  * \brief Perform DNS lookup (used by DNS, enum and SRV lookups)
36  *
37  * \param context Void pointer containing data to use in the callback function.
38  * \param dname Domain name to lookup (host, SRV domain, TXT record name).
39  * \param class Record Class (see "man res_search").
40  * \param type Record type (see "man res_search").
41  * \param callback Callback function for handling the discovered resource records from
42  * the DNS search. len gets the length of the full DNS response.
43  *
44  * \retval -1 on search failure
45  * \retval 0 on no records found
46  * \retval 1 on success
47  *
48  * \note Asterisk DNS is synchronus at this time. This means that if your DNS
49  * service does not work, Asterisk may lock while waiting for a response.
50  */
51 int ast_search_dns(void *context, const char *dname, int class, int type,
52  int (*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer));
53 
54 /*!
55  * \brief Extended version of the DNS search function.
56  *
57  * \details Performs a DNS lookup, (used by DNS, enum and SRV lookups), parses the
58  * results and notifies the observer with the response and discovered records
59  * via invoking the provided callbacks (used by ast_dns_system_resolver).
60  *
61  * \param context Void pointer containing data to use in the handler functions.
62  * \param dname Domain name to lookup (host, SRV domain, TXT record name).
63  * \param rr_class Record Class (see "man res_search").
64  * \param rr_type Record type (see "man res_search").
65  * \param response_handler Callback function for handling the DNS response. Invoked upon
66  * completion of the DNS search.
67  * \param record_handler Callback function for handling the discovered resource
68  * records from the DNS search. Invoked n times, where n is the
69  * number of records discovered while parsing the DNS
70  * response.
71  *
72  * \retval AST_DNS_SEARCH_FAILURE on search failure
73  * \retval AST_DNS_SEARCH_NO_RECORDS on no records found
74  * \retval AST_DNS_SEARCH_SUCCESS on success
75  *
76  * \note Asterisk DNS is synchronus at this time. This means that if your DNS
77  * service does not work, Asterisk may lock while waiting for a response.
78  */
79 enum ast_dns_search_result ast_search_dns_ex(void *context, const char *dname, int rr_class, int rr_type,
80  int (*response_handler)(void *context, unsigned char *dns_response, int dns_response_len, int rcode),
81  int (*record_handler)(void *context, unsigned char *record, int record_len, int ttl));
82 
83 /*! \brief Retrieve the configured nameservers of the system */
85 
86 #endif /* _ASTERISK_DNS_H */
int ast_search_dns(void *context, const char *dname, int class, int type, int(*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer))
Perform DNS lookup (used by DNS, enum and SRV lookups)
Definition: dns.c:491
struct ao2_container * ast_dns_get_nameservers(void)
Retrieve the configured nameservers of the system.
Definition: dns.c:581
ast_dns_search_result
DNS search return values.
Definition: dns.h:28
enum ast_dns_search_result ast_search_dns_ex(void *context, const char *dname, int rr_class, int rr_type, int(*response_handler)(void *context, unsigned char *dns_response, int dns_response_len, int rcode), int(*record_handler)(void *context, unsigned char *record, int record_len, int ttl))
Extended version of the DNS search function.
Definition: dns.c:536
Generic container type.