diff options
author | Mark Michelson <mmichelson@digium.com> | 2015-07-08 09:00:41 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2015-07-08 09:00:41 -0500 |
commit | af3f4b342b1633c51e747d002335aed4ee78b26e (patch) | |
tree | c400f060b08edeb86115c55f9dfec25db89c52a2 /include | |
parent | 9276415f650af4ba8f11880f1e6235cf14204e1e (diff) | |
parent | 3cdfd39af7c632403bff34fdbf2c4945cd02bb79 (diff) |
Merge "DNS: Create a system-level DNS resolver"
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/_private.h | 1 | ||||
-rw-r--r-- | include/asterisk/dns.h | 66 |
2 files changed, 57 insertions, 10 deletions
diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h index d49de1789..2966f8787 100644 --- a/include/asterisk/_private.h +++ b/include/asterisk/_private.h @@ -29,6 +29,7 @@ int ast_cli_perms_init(int reload); /*!< Provided by cli.c */ int dnsmgr_init(void); /*!< Provided by dnsmgr.c */ void dnsmgr_start_refresh(void); /*!< Provided by dnsmgr.c */ int dnsmgr_reload(void); /*!< Provided by dnsmgr.c */ +int ast_dns_system_resolver_init(void); /*!< Provided by dns_system_resolver.c */ void threadstorage_init(void); /*!< Provided by threadstorage.c */ int ast_device_state_engine_init(void); /*!< Provided by devicestate.c */ int astobj2_init(void); /*!< Provided by astobj2.c */ diff --git a/include/asterisk/dns.h b/include/asterisk/dns.h index 4899fa8b4..c193a22aa 100644 --- a/include/asterisk/dns.h +++ b/include/asterisk/dns.h @@ -24,17 +24,63 @@ #ifndef _ASTERISK_DNS_H #define _ASTERISK_DNS_H -/*! \brief Perform DNS lookup (used by DNS, enum and SRV lookups) - \param context - \param dname Domain name to lookup (host, SRV domain, TXT record name) - \param class Record Class (see "man res_search") - \param type Record type (see "man res_search") - \param callback Callback function for handling DNS result - \note Asterisk DNS is synchronus at this time. This means that if your DNS - services does not work, Asterisk may lock while waiting for response. -*/ +/*! \brief DNS search return values */ +enum ast_dns_search_result { + AST_DNS_SEARCH_FAILURE = -1, /*!< DNS search resulted in failure */ + AST_DNS_SEARCH_NO_RECORDS = 0, /*!< DNS search yielded no results */ + AST_DNS_SEARCH_SUCCESS = 1 /*!< DNS search yielded at least one discovered record */ +}; + +/*! + * \brief Perform DNS lookup (used by DNS, enum and SRV lookups) + * + * \param context Void pointer containing data to use in the callback function. + * \param dname Domain name to lookup (host, SRV domain, TXT record name). + * \param class Record Class (see "man res_search"). + * \param type Record type (see "man res_search"). + * \param answer The full DNS response. + * \param len The length of the full DNS response. + * \param callback Callback function for handling the discovered resource records from + * the DNS search. + * + * \retval -1 on search failure + * \retval 0 on no records found + * \retval 1 on success + * + * \note Asterisk DNS is synchronus at this time. This means that if your DNS + * service does not work, Asterisk may lock while waiting for a response. + */ 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)); + int (*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer)); + +/*! + * \brief Extended version of the DNS search function. + * + * \details Performs a DNS lookup, (used by DNS, enum and SRV lookups), parses the + * results and notifies the observer with the response and discovered records + * via invoking the provided callbacks (used by ast_dns_system_resolver). + * + * \param context Void pointer containing data to use in the handler functions. + * \param dname Domain name to lookup (host, SRV domain, TXT record name). + * \param rr_class Record Class (see "man res_search"). + * \param rr_type Record type (see "man res_search"). + * \param response_handler Callback function for handling the DNS response. Invoked upon + * completion of the DNS search. + * \param record_handler Callback function for handling the discovered resource + * records from the DNS search. Invoked n times, where n is the + * number of records discovered while parsing the DNS + * response. + * + * \retval AST_DNS_SEARCH_FAILURE on search failure + * \retval AST_DNS_SEARCH_NO_RECORDS on no records found + * \retval AST_DNS_SEARCH_SUCCESS on success + * + * \note Asterisk DNS is synchronus at this time. This means that if your DNS + * service does not work, Asterisk may lock while waiting for a response. + */ +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)); /*! \brief Retrieve the configured nameservers of the system */ struct ao2_container *ast_dns_get_nameservers(void); |