[asterisk-commits] file: trunk r433370 - in /trunk: ./ build_tools/ configs/samples/ include/ast...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 25 07:32:36 CDT 2015


Author: file
Date: Wed Mar 25 07:32:26 2015
New Revision: 433370

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433370
Log:
dns: Add core DNS API + unit tests and res_resolver_unbound module + unit tests.

This change adds an abstracted core DNS API which resembles the API described
here[1]. The API provides a pluggable mechanism for resolvers and also a
consistent view for records. Both synchronous and asynchronous queries are
supported.

This change also adds a res_resolver_unbound module which uses the libunbound
library to provide resolution.

Unit tests have also been written for all of the above to confirm the API and
functionality.

ASTERISK-24834 #close
Reported by: Matt Jordan

ASTERISK-24836 #close
Reported by: Matt Jordan

Review: https://reviewboard.asterisk.org/r/4474/
Review: https://reviewboard.asterisk.org/r/4512/

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+DNS+API

Added:
    trunk/configs/samples/resolver_unbound.conf.sample   (with props)
    trunk/include/asterisk/dns_core.h   (with props)
    trunk/include/asterisk/dns_internal.h   (with props)
    trunk/include/asterisk/dns_naptr.h   (with props)
    trunk/include/asterisk/dns_query_set.h   (with props)
    trunk/include/asterisk/dns_recurring.h   (with props)
    trunk/include/asterisk/dns_resolver.h   (with props)
    trunk/include/asterisk/dns_srv.h   (with props)
    trunk/include/asterisk/dns_tlsa.h   (with props)
    trunk/main/dns_core.c   (with props)
    trunk/main/dns_naptr.c   (with props)
    trunk/main/dns_query_set.c   (with props)
    trunk/main/dns_recurring.c   (with props)
    trunk/main/dns_srv.c   (with props)
    trunk/main/dns_tlsa.c   (with props)
    trunk/res/res_resolver_unbound.c   (with props)
    trunk/tests/test_dns.c   (with props)
    trunk/tests/test_dns_recurring.c   (with props)
Modified:
    trunk/build_tools/menuselect-deps.in
    trunk/configure
    trunk/configure.ac
    trunk/include/asterisk/autoconfig.h.in
    trunk/makeopts.in

Modified: trunk/build_tools/menuselect-deps.in
URL: http://svnview.digium.com/svn/asterisk/trunk/build_tools/menuselect-deps.in?view=diff&rev=433370&r1=433369&r2=433370
==============================================================================
--- trunk/build_tools/menuselect-deps.in (original)
+++ trunk/build_tools/menuselect-deps.in Wed Mar 25 07:32:26 2015
@@ -65,6 +65,7 @@
 SUPPSERV=@PBX_SUPPSERV@
 SYSLOG=@PBX_SYSLOG@
 TONEZONE=@PBX_TONEZONE@
+UNBOUND=@PBX_UNBOUND@
 UNIXODBC=@PBX_UNIXODBC@
 VORBIS=@PBX_VORBIS@
 VPB=@PBX_VPB@

Added: trunk/configs/samples/resolver_unbound.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/samples/resolver_unbound.conf.sample?view=auto&rev=433370
==============================================================================
--- trunk/configs/samples/resolver_unbound.conf.sample (added)
+++ trunk/configs/samples/resolver_unbound.conf.sample Wed Mar 25 07:32:26 2015
@@ -1,0 +1,24 @@
+; Unbound DNS Resolver Configuration
+;
+; This file serves as a reference for the configurable options within the
+; unbound DNS resolver.
+
+[general]
+;hosts = /etc/hosts        ; Full path to a hosts file which contains a mapping of
+;                          ; hostnames to addresses. If "system" is specified then
+;                          ; the system specific hosts file will be used. (default: system)
+;resolv = /etc/resolv.conf ; Full path to a resolv.conf which contains the nameservers
+;                          ; to use for resolution. If "system" is specified then the
+;                          ; system specific resolv.conf file will be used. (default: system)
+;nameserver = 127.0.0.1    ; An explicit nameserver to use for queries. If this option
+;                          ; is specified multiple times the first configured one will
+;                          ; be treated as the primary with each subsequent one being
+;                          ; a backup. If the resolv options is also specified the
+;                          ; nameservers from it will be tried after all nameserver
+;                          ; options.
+;debug = 99                ; The debug level to run the unbound resolver at. While
+;                          ; there is no explicit range the higher the number the more
+;                          ; debug is output.
+;ta_file = /etc/asterisk/dnssec_keys ; Full path to a trusted anchors key file. These keys are
+;                                    ; used to verify DNSSEC signed results.
+

Propchange: trunk/configs/samples/resolver_unbound.conf.sample
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/configs/samples/resolver_unbound.conf.sample
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: trunk/configs/samples/resolver_unbound.conf.sample
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: trunk/configure.ac
URL: http://svnview.digium.com/svn/asterisk/trunk/configure.ac?view=diff&rev=433370&r1=433369&r2=433370
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Wed Mar 25 07:32:26 2015
@@ -507,6 +507,7 @@
 AST_EXT_LIB_SETUP([TIMERFD], [timerfd], [timerfd])
 AST_EXT_LIB_SETUP([TINFO], [Term Info], [tinfo])
 AST_EXT_LIB_SETUP([TONEZONE], [tonezone], [tonezone])
+AST_EXT_LIB_SETUP([UNBOUND], [unbound], [unbound])
 AST_EXT_LIB_SETUP([UNIXODBC], [unixODBC], [unixodbc])
 AST_EXT_LIB_SETUP([VORBIS], [Vorbis], [vorbis])
 AST_EXT_LIB_SETUP([VPB], [Voicetronix API], [vpb])
@@ -2032,6 +2033,8 @@
 
 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
 
+AST_EXT_LIB_CHECK([UNBOUND], [unbound], [ub_ctx_create], [unbound.h], [])
+
 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h], [])
 
 AST_EXT_LIB_CHECK([OGG], [ogg], [ogg_sync_init], [])

Modified: trunk/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/autoconfig.h.in?view=diff&rev=433370&r1=433369&r2=433370
==============================================================================
--- trunk/include/asterisk/autoconfig.h.in (original)
+++ trunk/include/asterisk/autoconfig.h.in Wed Mar 25 07:32:26 2015
@@ -1064,6 +1064,9 @@
 
 /* Define to 1 if you have the `truncl' function. */
 #undef HAVE_TRUNCL
+
+/* Define to 1 if you have the unbound library. */
+#undef HAVE_UNBOUND
 
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H

Added: trunk/include/asterisk/dns_core.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/dns_core.h?view=auto&rev=433370
==============================================================================
--- trunk/include/asterisk/dns_core.h (added)
+++ trunk/include/asterisk/dns_core.h Wed Mar 25 07:32:26 2015
@@ -1,0 +1,267 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2015, Digium, Inc.
+ *
+ * Joshua Colp <jcolp at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief Core DNS API
+ * \author Joshua Colp <jcolp at digium.com>
+ */
+
+#ifndef _ASTERISK_DNS_CORE_H
+#define _ASTERISK_DNS_CORE_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+/*! \brief Opaque structure for an active DNS query */
+struct ast_dns_query_active;
+
+/*! \brief Opaque structure for a DNS query */
+struct ast_dns_query;
+
+/*!
+ * \brief Get the name queried in a DNS query
+ *
+ * \param query The DNS query
+ *
+ * \return the name queried
+ */
+const char *ast_dns_query_get_name(const struct ast_dns_query *query);
+
+/*!
+ * \brief Get the record resource type of a DNS query
+ *
+ * \param query The DNS query
+ *
+ * \return the record resource type
+ */
+int ast_dns_query_get_rr_type(const struct ast_dns_query *query);
+
+/*!
+ * \brief Get the record resource class of a DNS query
+ *
+ * \param query The DNS query
+ *
+ * \return the record resource class
+ */
+int ast_dns_query_get_rr_class(const struct ast_dns_query *query);
+
+/*!
+ * \brief Get the user specific data of a DNS query
+ *
+ * \param query The DNS query
+ *
+ * \return the user specific data
+ *
+ * \note The reference count of the data is NOT incremented on return
+ */
+void *ast_dns_query_get_data(const struct ast_dns_query *query);
+
+/*! \brief Opaque structure for a DNS query result, guaranteed to be immutable */
+struct ast_dns_result;
+
+/*!
+ * \brief Get the result information for a DNS query
+ *
+ * \param query The DNS query
+ *
+ * \return the DNS result information
+ *
+ * \note The result is NOT ao2 allocated
+ */
+struct ast_dns_result *ast_dns_query_get_result(const struct ast_dns_query *query);
+
+/*!
+ * \brief Get whether the result is secure or not
+ *
+ * \param result The DNS result
+ *
+ * \return whether the result is secure or not
+ */
+unsigned int ast_dns_result_get_secure(const struct ast_dns_result *result);
+
+/*!
+ * \brief Get whether the result is bogus or not
+ *
+ * \param result The DNS result
+ *
+ * \return whether the result is bogus or not
+ */
+unsigned int ast_dns_result_get_bogus(const struct ast_dns_result *result);
+
+/*!
+ * \brief Get the error rcode of a DN result
+ *
+ * \param query The DNS result
+ *
+ * \return the DNS rcode
+ */
+unsigned int ast_dns_result_get_rcode(const struct ast_dns_result *result);
+
+/*!
+ * \brief Get the canonical name of the result
+ *
+ * \param result The DNS result
+ *
+ * \return the canonical name
+ */
+const char *ast_dns_result_get_canonical(const struct ast_dns_result *result);
+
+/*!
+ * \brief Get the first record of a DNS Result
+ *
+ * \param result The DNS result
+ *
+ * \return first DNS record
+ */
+const struct ast_dns_record *ast_dns_result_get_records(const struct ast_dns_result *result);
+
+/*!
+ * \brief Get the raw DNS answer from a DNS result
+ *
+ * \param result The DNS result
+ *
+ * \return The DNS result
+ */
+const char *ast_dns_result_get_answer(const struct ast_dns_result *result);
+
+/*!
+ * \brief Retrieve the lowest TTL from a result
+ *
+ * \param result The DNS result
+ *
+ * \return the lowest TTL
+ *
+ * \note If no records exist this function will return a TTL of 0
+ */
+int ast_dns_result_get_lowest_ttl(const struct ast_dns_result *result);
+
+/*!
+ * \brief Free the DNS result information
+ *
+ * \param result The DNS result
+ */
+void ast_dns_result_free(struct ast_dns_result *result);
+
+/*! \brief Opaque structure for a DNS record */
+struct ast_dns_record;
+
+/*!
+ * \brief Callback invoked when a query completes
+ *
+ * \param query The DNS query that was invoked
+ */
+typedef void (*ast_dns_resolve_callback)(const struct ast_dns_query *query);
+
+/*!
+ * \brief Get the resource record type of a DNS record
+ *
+ * \param record The DNS record
+ *
+ * \return the resource record type
+ */
+int ast_dns_record_get_rr_type(const struct ast_dns_record *record);
+
+/*!
+ * \brief Get the resource record class of a DNS record
+ *
+ * \param record The DNS record
+ *
+ * \return the resource record class
+ */
+int ast_dns_record_get_rr_class(const struct ast_dns_record *record);
+
+/*!
+ * \brief Get the TTL of a DNS record
+ *
+ * \param record The DNS record
+ *
+ * \return the TTL
+ */
+int ast_dns_record_get_ttl(const struct ast_dns_record *record);
+
+/*!
+ * \brief Retrieve the raw DNS record
+ *
+ * \param record The DNS record
+ *
+ * \return the raw DNS record
+ */
+const char *ast_dns_record_get_data(const struct ast_dns_record *record);
+
+/*!
+ * \brief Get the next DNS record
+ *
+ * \param record The current DNS record
+ *
+ * \return the next DNS record
+ */
+const struct ast_dns_record *ast_dns_record_get_next(const struct ast_dns_record *record);
+
+/*!
+ * \brief Asynchronously resolve a DNS query
+ *
+ * \param name The name of what to resolve
+ * \param rr_type Resource record type
+ * \param rr_class Resource record class
+ * \param callback The callback to invoke upon completion
+ * \param data User data to make available on the query
+ *
+ * \retval non-NULL success - query has been sent for resolution
+ * \retval NULL failure
+ *
+ * \note The result passed to the callback does not need to be freed
+ *
+ * \note The user data MUST be an ao2 object
+ *
+ * \note This function increments the reference count of the user data, it does NOT steal
+ *
+ * \note The active query must be released upon completion or cancellation using ao2_ref
+ */
+struct ast_dns_query_active *ast_dns_resolve_async(const char *name, int rr_type, int rr_class, ast_dns_resolve_callback callback, void *data);
+
+/*!
+ * \brief Cancel an asynchronous DNS resolution
+ *
+ * \param active The active DNS query returned from ast_dns_resolve_async
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ *
+ * \note If successfully cancelled the callback will not be invoked
+ */
+int ast_dns_resolve_cancel(struct ast_dns_query_active *active);
+
+/*!
+ * \brief Synchronously resolve a DNS query
+ *
+ * \param name The name of what to resolve
+ * \param rr_type Resource record type
+ * \param rr_class Resource record class
+ * \param result A pointer to hold the DNS result
+ *
+ * \retval 0 success - query was completed and result is available
+ * \retval -1 failure
+ */
+int ast_dns_resolve(const char *name, int rr_type, int rr_class, struct ast_dns_result **result);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _ASTERISK_DNS_CORE_H */

Propchange: trunk/include/asterisk/dns_core.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/include/asterisk/dns_core.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: trunk/include/asterisk/dns_core.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/include/asterisk/dns_internal.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/dns_internal.h?view=auto&rev=433370
==============================================================================
--- trunk/include/asterisk/dns_internal.h (added)
+++ trunk/include/asterisk/dns_internal.h Wed Mar 25 07:32:26 2015
@@ -1,0 +1,145 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2015, Digium, Inc.
+ *
+ * Joshua Colp <jcolp at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Internal DNS structure definitions
+ *
+ * \author Joshua Colp <jcolp at digium.com>
+ */
+
+/*! \brief Generic DNS record information */
+struct ast_dns_record {
+	/*! \brief Resource record type */
+	int rr_type;
+	/*! \brief Resource record class */
+	int rr_class;
+	/*! \brief Time-to-live of the record */
+	int ttl;
+	/*! \brief The size of the raw DNS record */
+	size_t data_len;
+	/*! \brief Linked list information */
+	AST_LIST_ENTRY(ast_dns_record) list;
+	/*! \brief The raw DNS record */
+	char data[0];
+};
+
+/*! \brief An SRV record */
+struct ast_dns_srv_record {
+	/*! \brief Generic DNS record information */
+	struct ast_dns_record generic;
+	/*! \brief The hostname in the SRV record */
+	const char *host;
+	/*! \brief The priority of the SRV record */
+	unsigned short priority;
+	/*! \brief The weight of the SRV record */
+	unsigned short weight;
+	/*! \brief The port in the SRV record */
+	unsigned short port;
+};
+
+/*! \brief A NAPTR record */
+struct ast_dns_naptr_record {
+	/*! \brief Generic DNS record information */
+	struct ast_dns_record generic;
+	/*! \brief The flags from the NAPTR record */
+	const char *flags;
+	/*! \brief The service from the NAPTR record */
+	const char *service;
+	/*! \brief The regular expression from the NAPTR record */
+	const char *regexp;
+	/*! \brief The replacement from the NAPTR record */
+	const char *replacement;
+	/*! \brief The order for the NAPTR record */
+	unsigned short order;
+	/*! \brief The preference of the NAPTR record */
+	unsigned short preference;
+};
+
+/*! \brief The result of a DNS query */
+struct ast_dns_result {
+	/*! \brief Whether the result is secure */
+	unsigned int secure;
+	/*! \brief Whether the result is bogus */
+	unsigned int bogus;
+	/*! \brief Optional rcode, set if an error occurred */
+	unsigned int rcode;
+	/*! \brief Records returned */
+	AST_LIST_HEAD_NOLOCK(, ast_dns_record) records;
+	/*! \brief The canonical name */
+	const char *canonical;
+	/*! \brief The raw DNS answer */
+	const char *answer;
+	/*! \brief Buffer for dynamic data */
+	char buf[0];
+};
+
+/*! \brief A DNS query */
+struct ast_dns_query {
+	/*! \brief Callback to invoke upon completion */
+	ast_dns_resolve_callback callback;
+	/*! \brief User-specific data */
+	void *user_data;
+	/*! \brief The resolver in use for this query */
+	struct ast_dns_resolver *resolver;
+	/*! \brief Resolver-specific data */
+	void *resolver_data;
+	/*! \brief Result of the DNS query */
+	struct ast_dns_result *result;
+	/*! \brief Resource record type */
+	int rr_type;
+	/*! \brief Resource record class */
+	int rr_class;
+	/*! \brief The name of what is being resolved */
+	char name[0];
+};
+
+/*! \brief A recurring DNS query */
+struct ast_dns_query_recurring {
+	/*! \brief Callback to invoke upon completion */
+	ast_dns_resolve_callback callback;
+	/*! \brief User-specific data */
+	void *user_data;
+	/*! \brief Current active query */
+	struct ast_dns_query_active *active;
+	/*! \brief The recurring query has been cancelled */
+	unsigned int cancelled;
+	/*! \brief Scheduled timer for next resolution */
+	int timer;
+	/*! \brief Resource record type */
+	int rr_type;
+	/*! \brief Resource record class */
+	int rr_class;
+	/*! \brief The name of what is being resolved */
+	char name[0];
+};
+
+/*! \brief An active DNS query */
+struct ast_dns_query_active {
+	/*! \brief The underlying DNS query */
+	struct ast_dns_query *query;
+};
+
+struct ast_sched_context;
+
+/*!
+ * \brief Retrieve the DNS scheduler context
+ *
+ * \return scheduler context
+ */
+struct ast_sched_context *ast_dns_get_sched(void);

Propchange: trunk/include/asterisk/dns_internal.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/include/asterisk/dns_internal.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: trunk/include/asterisk/dns_internal.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/include/asterisk/dns_naptr.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/dns_naptr.h?view=auto&rev=433370
==============================================================================
--- trunk/include/asterisk/dns_naptr.h (added)
+++ trunk/include/asterisk/dns_naptr.h Wed Mar 25 07:32:26 2015
@@ -1,0 +1,89 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2015, Digium, Inc.
+ *
+ * Joshua Colp <jcolp at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief DNS NAPTR Record Parsing API
+ * \author Joshua Colp <jcolp at digium.com>
+ */
+
+#ifndef _ASTERISK_DNS_NAPTR_H
+#define _ASTERISK_DNS_NAPTR_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+/*!
+ * \brief Get the flags from a NAPTR record
+ *
+ * \param record The DNS record
+ *
+ * \return the flags
+ */
+const char *ast_dns_naptr_get_flags(const struct ast_dns_record *record);
+
+/*!
+ * \brief Get the service from a NAPTR record
+ *
+ * \param record The DNS record
+ *
+ * \return the service
+ */
+const char *ast_dns_naptr_get_service(const struct ast_dns_record *record);
+
+/*!
+ * \brief Get the regular expression from a NAPTR record
+ *
+ * \param record The DNS record
+ *
+ * \return the regular expression
+ */
+const char *ast_dns_naptr_get_regexp(const struct ast_dns_record *record);
+
+/*!
+ * \brief Get the replacement value from a NAPTR record
+ *
+ * \param record The DNS record
+ *
+ * \return the replacement value
+ */
+const char *ast_dns_naptr_get_replacement(const struct ast_dns_record *record);
+
+/*!
+ * \brief Get the order from a NAPTR record
+ *
+ * \param record The DNS record
+ *
+ * \return the order
+ */
+unsigned short ast_dns_naptr_get_order(const struct ast_dns_record *record);
+
+/*!
+ * \brief Get the preference from a NAPTR record
+ *
+ * \param record The DNS record
+ *
+ * \return the preference
+ */
+unsigned short ast_dns_naptr_get_preference(const struct ast_dns_record *record);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _ASTERISK_DNS_NAPTR_H */

Propchange: trunk/include/asterisk/dns_naptr.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/include/asterisk/dns_naptr.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: trunk/include/asterisk/dns_naptr.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/include/asterisk/dns_query_set.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/dns_query_set.h?view=auto&rev=433370
==============================================================================
--- trunk/include/asterisk/dns_query_set.h (added)
+++ trunk/include/asterisk/dns_query_set.h Wed Mar 25 07:32:26 2015
@@ -1,0 +1,136 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2015, Digium, Inc.
+ *
+ * Joshua Colp <jcolp at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief DNS Query Set API
+ * \author Joshua Colp <jcolp at digium.com>
+ */
+
+#ifndef _ASTERISK_DNS_QUERY_SET_H
+#define _ASTERISK_DNS_QUERY_SET_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+/*! \brief Opaque structure for a set of DNS queries */
+struct ast_dns_query_set;
+
+/*!
+ * \brief Callback invoked when a query set completes
+ *
+ * \param query_set The DNS query set that was invoked
+ */
+typedef void (*ast_dns_query_set_callback)(const struct ast_dns_query_set *query_set);
+
+/*!
+ * \brief Create a query set to hold queries
+ *
+ * \retval non-NULL success
+ * \retval NULL failure
+ */
+struct ast_dns_query_set *ast_dns_query_set_create(void);
+
+/*!
+ * \brief Add a query to a query set
+ *
+ * \param query_set A DNS query set
+ * \param name The name of what to resolve
+ * \param rr_type Resource record type
+ * \param rr_class Resource record class
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_dns_query_set_add(struct ast_dns_query_set *query_set, const char *name, int rr_type, int rr_class);
+
+/*!
+ * \brief Retrieve the number of queries in a query set
+ *
+ * \param query_set A DNS query set
+ *
+ * \return the number of queries
+ */
+size_t ast_dns_query_set_num_queries(const struct ast_dns_query_set *query_set);
+
+/*!
+ * \brief Retrieve a query from a query set
+ *
+ * \param query_set A DNS query set
+ * \param index The index of the query to retrieve
+ *
+ * \retval non-NULL success
+ * \retval NULL failure
+ */
+struct ast_dns_query *ast_dns_query_set_get(const struct ast_dns_query_set *query_set, unsigned int index);
+
+/*!
+ * \brief Retrieve user specific data from a query set
+ *
+ * \param query_set A DNS query set
+ *
+ * \return user specific data
+ */
+void *ast_dns_query_set_get_data(const struct ast_dns_query_set *query_set);
+
+/*!
+ * \brief Asynchronously resolve queries in a query set
+ *
+ * \param query_set The query set
+ * \param callback The callback to invoke upon completion
+ * \param data User data to make available on the query set
+ *
+ * \note The callback will be invoked when all queries have completed
+ *
+ * \note The user data passed in to this function must be ao2 allocated
+ */
+void ast_dns_query_set_resolve_async(struct ast_dns_query_set *query_set, ast_dns_query_set_callback callback, void *data);
+
+/*!
+ * \brief Synchronously resolve queries in a query set
+ *
+ * \param query_set The query set
+ *
+ * \note This function will return when all queries have been completed
+ */
+void ast_query_set_resolve(struct ast_dns_query_set *query_set);
+
+/*!
+ * \brief Cancel an asynchronous DNS query set resolution
+ *
+ * \param query_set The DNS query set
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ *
+ * \note If successfully cancelled the callback will not be invoked
+ */
+int ast_dns_query_set_resolve_cancel(struct ast_dns_query_set *query_set);
+
+/*!
+ * \brief Free a query set
+ *
+ * \param query_set A DNS query set
+ */
+void ast_dns_query_set_free(struct ast_dns_query_set *query_set);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _ASTERISK_DNS_QUERY_SET_H */

Propchange: trunk/include/asterisk/dns_query_set.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/include/asterisk/dns_query_set.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: trunk/include/asterisk/dns_query_set.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/include/asterisk/dns_recurring.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/dns_recurring.h?view=auto&rev=433370
==============================================================================
--- trunk/include/asterisk/dns_recurring.h (added)
+++ trunk/include/asterisk/dns_recurring.h Wed Mar 25 07:32:26 2015
@@ -1,0 +1,78 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2015, Digium, Inc.
+ *
+ * Joshua Colp <jcolp at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief DNS Recurring Resolution API
+ * \author Joshua Colp <jcolp at digium.com>
+ */
+
+#ifndef _ASTERISK_DNS_RECURRING_H
+#define _ASTERISK_DNS_RECURRING_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+/*! \brief Opaque structure for a recurring DNS query */
+struct ast_dns_query_recurring;
+
+/*!
+ * \brief Asynchronously resolve a DNS query, and continue resolving it according to the lowest TTL available
+ *
+ * \param name The name of what to resolve
+ * \param rr_type Resource record type
+ * \param rr_class Resource record class
+ * \param callback The callback to invoke upon completion
+ * \param data User data to make available on the query
+ *
+ * \retval non-NULL success - query has been sent for resolution
+ * \retval NULL failure
+ *
+ * \note The user data passed in to this function must be ao2 allocated
+ *
+ * \note This query will continue to happen according to the lowest TTL unless cancelled using ast_dns_resolve_recurring_cancel
+ *
+ * \note It is NOT possible for the callback to be invoked concurrently for the query multiple times
+ *
+ * \note The query will occur when the TTL expires, not before. This means that there is a period of time where the previous
+ *       information can be considered stale.
+ *
+ * \note If the TTL is determined to be 0 (the record specifies 0, or no records exist) this will cease doing a recurring query.
+ *       It is the responsibility of the caller to resume querying at an interval they determine.
+ */
+struct ast_dns_query_recurring *ast_dns_resolve_recurring(const char *name, int rr_type, int rr_class, ast_dns_resolve_callback callback, void *data);
+
+/*!
+ * \brief Cancel an asynchronous recurring DNS resolution
+ *
+ * \param query The DNS query returned from ast_dns_resolve_recurring
+ *
+ * \retval 0 success - any active query has been cancelled and the query will no longer occur
+ * \retval -1 failure - an active query was in progress and could not be cancelled
+ *
+ * \note If successfully cancelled the callback will not be invoked
+ *
+ * \note This function does NOT drop your reference to the recurring query, this should be dropped using ao2_ref
+ */
+int ast_dns_resolve_recurring_cancel(struct ast_dns_query_recurring *recurring);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _ASTERISK_DNS_RECURRING_H */

Propchange: trunk/include/asterisk/dns_recurring.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/include/asterisk/dns_recurring.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: trunk/include/asterisk/dns_recurring.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/include/asterisk/dns_resolver.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/dns_resolver.h?view=auto&rev=433370
==============================================================================
--- trunk/include/asterisk/dns_resolver.h (added)
+++ trunk/include/asterisk/dns_resolver.h Wed Mar 25 07:32:26 2015
@@ -1,0 +1,142 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2015, Digium, Inc.
+ *
+ * Joshua Colp <jcolp at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief DNS Resolver API
+ * \author Joshua Colp <jcolp at digium.com>
+ */
+
+#ifndef _ASTERISK_DNS_RESOLVER_H
+#define _ASTERISK_DNS_RESOLVER_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+/*! \brief DNS resolver implementation */
+struct ast_dns_resolver {
+    /*! \brief The name of the resolver implementation */
+    const char *name;
+
+    /*! \brief Priority for this resolver if multiple exist, lower being higher priority */
+    unsigned int priority;
+
+    /*!
+     * \brief Perform resolution of a DNS query
+     *
+     * \note The reference count of the query should be increased and released
+     *       upon the query completing or being successfully cancelled
+     */
+    int (*resolve)(struct ast_dns_query *query);
+
+    /*! \brief Cancel resolution of a DNS query */
+    int (*cancel)(struct ast_dns_query *query);
+
+    /*! \brief Linked list information */
+    AST_RWLIST_ENTRY(ast_dns_resolver) next;
+};
+
+/*!
+ * \brief Set resolver specific data on a query
+ *
+ * \param query The DNS query
+ * \param data The resolver specific data
+ *
+ * \note The resolver data MUST be an ao2 object
+ *
+ * \note This function increments the reference count of the resolver data, it does NOT steal
+ *
+ * \note Once resolver specific data has been set it can not be changed
+ *
+ * \retval 0 success
+ * \retval -1 failure, resolver data is already set
+ */
+int ast_dns_resolver_set_data(struct ast_dns_query *query, void *data);
+
+/*!
+ * \brief Retrieve resolver specific data
+ *
+ * \param query The DNS query
+ *
+ * \return the resolver specific data
+ *
+ * \note The reference count of the resolver data is NOT incremented on return
+ */
+void *ast_dns_resolver_get_data(const struct ast_dns_query *query);
+
+/*!
+ * \brief Set result information for a DNS query
+ *
+ * \param query The DNS query
+ * \param result Whether the result is secured or not
+ * \param bogus Whether the result is bogus or not
+ * \param rcode Optional response code
+ * \param canonical The canonical name
+ * \param answer The raw DNS answer
+ * \param answer_size The size of the raw DNS answer
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_dns_resolver_set_result(struct ast_dns_query *query, unsigned int secure, unsigned int bogus,
+	unsigned int rcode, const char *canonical, const char *answer, size_t answer_size);
+
+/*!
+ * \brief Add a DNS record to the result of a DNS query
+ *
+ * \param query The DNS query
+ * \param rr_type Resource record type
+ * \param rr_class Resource record class
+ * \param ttl TTL of the record
+ * \param data The raw DNS record
+ * \param size The size of the raw DNS record
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_dns_resolver_add_record(struct ast_dns_query *query, int rr_type, int rr_class, int ttl, const char *data, const size_t size);
+
+/*!
+ * \brief Mark a DNS query as having been completed
+ *
+ * \param query The DNS query
+ */
+void ast_dns_resolver_completed(struct ast_dns_query *query);
+
+/*!
+ * \brief Register a DNS resolver
+ *
+ * \param resolver A DNS resolver implementation
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_dns_resolver_register(struct ast_dns_resolver *resolver);
+
+/*!
+ * \brief Unregister a DNS resolver
+ *
+ * \param resolver A DNS resolver implementation
+ */
+void ast_dns_resolver_unregister(struct ast_dns_resolver *resolver);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _ASTERISK_DNS_RESOLVER_H */

Propchange: trunk/include/asterisk/dns_resolver.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/include/asterisk/dns_resolver.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: trunk/include/asterisk/dns_resolver.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/include/asterisk/dns_srv.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/dns_srv.h?view=auto&rev=433370
==============================================================================
--- trunk/include/asterisk/dns_srv.h (added)
+++ trunk/include/asterisk/dns_srv.h Wed Mar 25 07:32:26 2015
@@ -1,0 +1,71 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2015, Digium, Inc.
+ *
+ * Joshua Colp <jcolp at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief DNS SRV Record Parsing API
+ * \author Joshua Colp <jcolp at digium.com>
+ */
+
+#ifndef _ASTERISK_DNS_SRV_H
+#define _ASTERISK_DNS_SRV_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+/*!
+ * \brief Get the hostname from an SRV record
+ *
+ * \param record The DNS record
+ *
+ * \return the hostname
+ */
+const char *ast_dns_srv_get_host(const struct ast_dns_record *record);
+
+/*!
+ * \brief Get the priority from an SRV record
+ *
+ * \param record The DNS record
+ *
+ * \return the priority
+ */
+unsigned short ast_dns_srv_get_priority(const struct ast_dns_record *record);
+
+/*!
+ * \brief Get the weight from an SRV record
+ *
+ * \param record The DNS record
+ *
+ * \return the weight
+ */
+unsigned short ast_dns_srv_get_weight(const struct ast_dns_record *record);
+
+/*!
+ * \brief Get the port from an SRV record
+ *
+ * \param record The DNS record
+ *
+ * \return the port
+ */
+unsigned short ast_dns_srv_get_port(const struct ast_dns_record *record);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _ASTERISK_DNS_SRV_H */

Propchange: trunk/include/asterisk/dns_srv.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/include/asterisk/dns_srv.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: trunk/include/asterisk/dns_srv.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: trunk/include/asterisk/dns_tlsa.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/dns_tlsa.h?view=auto&rev=433370
==============================================================================
--- trunk/include/asterisk/dns_tlsa.h (added)
+++ trunk/include/asterisk/dns_tlsa.h Wed Mar 25 07:32:26 2015
@@ -1,0 +1,72 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2015, Digium, Inc.
+ *
+ * Joshua Colp <jcolp at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief DNS TLSA Record Parsing API
+ * \author Joshua Colp <jcolp at digium.com>
+ */
+
+#ifndef _ASTERISK_DNS_TLSA_H
+#define _ASTERISK_DNS_TLSA_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+/*!
+ * \brief Get the certificate usage field from a TLSA record
+ *
+ * \param record The DNS record
+ *
+ * \return the certificate usage field
+ */
+
+unsigned int ast_dns_tlsa_get_usage(const struct ast_dns_record *record);
+
+/*!
+ * \brief Get the selector field from a TLSA record
+ *
+ * \param record The DNS record
+ *
+ * \return the selector field
+ */

[... 4482 lines stripped ...]



More information about the asterisk-commits mailing list