summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2015-04-01 16:27:48 +0000
committerJoshua Colp <jcolp@digium.com>2015-04-01 16:27:48 +0000
commit39824e3d013287d8860d620454d230278b0fba69 (patch)
treeff7380c85bde86fe7138f0b79cf4071594bedb18 /include/asterisk
parentda13d15425e2dfefaf1b656d8aa6462d967b77ad (diff)
dns: Add support for SRV record parsing and sorting.
This change adds support for parsing SRV records and consuming their values in an easy fashion. It also adds automatic sorting of SRV records according to RFC 2782. Tests have also been included which cover parsing, sorting, and off-nominal cases where the record is corrupted. ASTERISK-24931 #close Reported by: Joshua Colp Review: https://reviewboard.asterisk.org/r/4528/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433889 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/dns_internal.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/include/asterisk/dns_internal.h b/include/asterisk/dns_internal.h
index 48fa26471..eb149245a 100644
--- a/include/asterisk/dns_internal.h
+++ b/include/asterisk/dns_internal.h
@@ -35,6 +35,7 @@ struct ast_dns_record {
size_t data_len;
/*! \brief Linked list information */
AST_LIST_ENTRY(ast_dns_record) list;
+ char *data_ptr;
/*! \brief The raw DNS record */
char data[0];
};
@@ -51,6 +52,10 @@ struct ast_dns_srv_record {
unsigned short weight;
/*! \brief The port in the SRV record */
unsigned short port;
+ /*! \brief The running weight sum */
+ unsigned int weight_sum;
+ /*! \brief Additional data */
+ char data[0];
};
/*! \brief A NAPTR record */
@@ -80,11 +85,13 @@ struct ast_dns_result {
/*! \brief Optional rcode, set if an error occurred */
unsigned int rcode;
/*! \brief Records returned */
- AST_LIST_HEAD_NOLOCK(, ast_dns_record) records;
+ AST_LIST_HEAD_NOLOCK(dns_records, ast_dns_record) records;
/*! \brief The canonical name */
const char *canonical;
/*! \brief The raw DNS answer */
const char *answer;
+ /*! \brief The size of the raw DNS answer */
+ size_t answer_size;
/*! \brief Buffer for dynamic data */
char buf[0];
};
@@ -143,3 +150,24 @@ struct ast_sched_context;
* \return scheduler context
*/
struct ast_sched_context *ast_dns_get_sched(void);
+
+/*!
+ * \brief Allocate and parse a DNS SRV record
+ *
+ * \param query The DNS query
+ * \param data This specific SRV record
+ * \param size The size of the SRV record
+ *
+ * \retval non-NULL success
+ * \retval NULL failure
+ */
+struct ast_dns_record *ast_dns_srv_alloc(struct ast_dns_query *query, const char *data, const size_t size);
+
+/*!
+ * \brief Sort the SRV records on a result
+ *
+ * \param result The DNS result
+ */
+void ast_dns_srv_sort(struct ast_dns_result *result);
+
+