Asterisk - The Open Source Telephony Project  18.5.0
dns.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Written by Thorsten Lockert <[email protected]>
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 <[email protected]>
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 answer The full DNS response.
42  * \param len The length of the full DNS response.
43  * \param callback Callback function for handling the discovered resource records from
44  * the DNS search.
45  *
46  * \retval -1 on search failure
47  * \retval 0 on no records found
48  * \retval 1 on success
49  *
50  * \note Asterisk DNS is synchronus at this time. This means that if your DNS
51  * service does not work, Asterisk may lock while waiting for a response.
52  */
53 int ast_search_dns(void *context, const char *dname, int class, int type,
54  int (*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer));
55 
56 /*!
57  * \brief Extended version of the DNS search function.
58  *
59  * \details Performs a DNS lookup, (used by DNS, enum and SRV lookups), parses the
60  * results and notifies the observer with the response and discovered records
61  * via invoking the provided callbacks (used by ast_dns_system_resolver).
62  *
63  * \param context Void pointer containing data to use in the handler functions.
64  * \param dname Domain name to lookup (host, SRV domain, TXT record name).
65  * \param rr_class Record Class (see "man res_search").
66  * \param rr_type Record type (see "man res_search").
67  * \param response_handler Callback function for handling the DNS response. Invoked upon
68  * completion of the DNS search.
69  * \param record_handler Callback function for handling the discovered resource
70  * records from the DNS search. Invoked n times, where n is the
71  * number of records discovered while parsing the DNS
72  * response.
73  *
74  * \retval AST_DNS_SEARCH_FAILURE on search failure
75  * \retval AST_DNS_SEARCH_NO_RECORDS on no records found
76  * \retval AST_DNS_SEARCH_SUCCESS on success
77  *
78  * \note Asterisk DNS is synchronus at this time. This means that if your DNS
79  * service does not work, Asterisk may lock while waiting for a response.
80  */
81 enum ast_dns_search_result ast_search_dns_ex(void *context, const char *dname, int rr_class, int rr_type,
82  int (*response_handler)(void *context, unsigned char *dns_response, int dns_response_len, int rcode),
83  int (*record_handler)(void *context, unsigned char *record, int record_len, int ttl));
84 
85 /*! \brief Retrieve the configured nameservers of the system */
87 
88 #endif /* _ASTERISK_DNS_H */
static const char type[]
Definition: chan_ooh323.c:109
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:493
struct ao2_container * ast_dns_get_nameservers(void)
Retrieve the configured nameservers of the system.
Definition: dns.c:583
ast_dns_search_result
DNS search return values.
Definition: dns.h:28
static int answer(void *data)
Definition: chan_pjsip.c:682
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:538
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Generic container type.
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116