[asterisk-commits] file: branch group/dns r432481 - in /team/group/dns: include/asterisk/ main/ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 5 06:43:14 CST 2015


Author: file
Date: Thu Mar  5 06:42:38 2015
New Revision: 432481

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=432481
Log:
Allow setting of the rcode on the result.

Modified:
    team/group/dns/include/asterisk/dns_core.h
    team/group/dns/include/asterisk/dns_internal.h
    team/group/dns/include/asterisk/dns_resolver.h
    team/group/dns/main/dns_core.c
    team/group/dns/tests/test_dns.c

Modified: team/group/dns/include/asterisk/dns_core.h
URL: http://svnview.digium.com/svn/asterisk/team/group/dns/include/asterisk/dns_core.h?view=diff&rev=432481&r1=432480&r2=432481
==============================================================================
--- team/group/dns/include/asterisk/dns_core.h (original)
+++ team/group/dns/include/asterisk/dns_core.h Thu Mar  5 06:42:38 2015
@@ -59,15 +59,6 @@
 int ast_dns_query_get_rr_class(const struct ast_dns_query *query);
 
 /*!
- * \brief Get the error rcode of a DNS query
- *
- * \param query The DNS query
- *
- * \return the DNS rcode
- */
-int ast_dns_query_get_rcode(const struct ast_dns_query *query);
-
-/*!
  * \brief Get the user specific data of a DNS query
  *
  * \param query The DNS query
@@ -114,6 +105,15 @@
  * \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

Modified: team/group/dns/include/asterisk/dns_internal.h
URL: http://svnview.digium.com/svn/asterisk/team/group/dns/include/asterisk/dns_internal.h?view=diff&rev=432481&r1=432480&r2=432481
==============================================================================
--- team/group/dns/include/asterisk/dns_internal.h (original)
+++ team/group/dns/include/asterisk/dns_internal.h Thu Mar  5 06:42:38 2015
@@ -79,6 +79,8 @@
 	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 */

Modified: team/group/dns/include/asterisk/dns_resolver.h
URL: http://svnview.digium.com/svn/asterisk/team/group/dns/include/asterisk/dns_resolver.h?view=diff&rev=432481&r1=432480&r2=432481
==============================================================================
--- team/group/dns/include/asterisk/dns_resolver.h (original)
+++ team/group/dns/include/asterisk/dns_resolver.h Thu Mar  5 06:42:38 2015
@@ -68,13 +68,14 @@
  * \param nxdomain Whether the domain was not found
  * \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
  *
  * \retval 0 success
  * \retval -1 failure
  */
 int ast_dns_resolver_set_result(struct ast_dns_query *query, unsigned int nxdomain, unsigned int secure, unsigned int bogus,
-	const char *canonical);
+	unsigned int rcode, const char *canonical);
 
 /*!
  * \brief Add a DNS record to the result of a DNS query

Modified: team/group/dns/main/dns_core.c
URL: http://svnview.digium.com/svn/asterisk/team/group/dns/main/dns_core.c?view=diff&rev=432481&r1=432480&r2=432481
==============================================================================
--- team/group/dns/main/dns_core.c (original)
+++ team/group/dns/main/dns_core.c Thu Mar  5 06:42:38 2015
@@ -61,11 +61,6 @@
 	return query->rr_class;
 }
 
-int ast_dns_query_get_rcode(const struct ast_dns_query *query)
-{
-	return 0;
-}
-
 void *ast_dns_query_get_data(const struct ast_dns_query *query)
 {
 	return query->user_data;
@@ -89,6 +84,11 @@
 unsigned int ast_dns_result_get_bogus(const struct ast_dns_result *result)
 {
 	return result->bogus;
+}
+
+unsigned int ast_dns_result_get_rcode(const struct ast_dns_result *result)
+{
+	return result->rcode;
 }
 
 const char *ast_dns_result_get_canonical(const struct ast_dns_result *result)
@@ -348,7 +348,7 @@
 }
 
 int ast_dns_resolver_set_result(struct ast_dns_query *query, unsigned int nxdomain, unsigned int secure, unsigned int bogus,
-	const char *canonical)
+	unsigned int rcode, const char *canonical)
 {
 	if (secure && bogus) {
 		ast_debug(2, "Query '%p': Could not set result information, it can not be both secure and bogus\n",
@@ -368,6 +368,7 @@
 	query->result->nxdomain = nxdomain;
 	query->result->secure = secure;
 	query->result->bogus = bogus;
+	query->result->rcode = rcode;
 	strcpy(query->result->canonical, canonical); /* SAFE */
 
 	return 0;

Modified: team/group/dns/tests/test_dns.c
URL: http://svnview.digium.com/svn/asterisk/team/group/dns/tests/test_dns.c?view=diff&rev=432481&r1=432480&r2=432481
==============================================================================
--- team/group/dns/tests/test_dns.c (original)
+++ team/group/dns/tests/test_dns.c Thu Mar  5 06:42:38 2015
@@ -320,7 +320,7 @@
 
 	memset(&some_query, 0, sizeof(some_query));
 
-	if (ast_dns_resolver_set_result(&some_query, 0, 0, 0, "asterisk.org")) {
+	if (ast_dns_resolver_set_result(&some_query, 0, 0, 0, 0, "asterisk.org")) {
 		ast_test_status_update(test, "Unable to add legitimate DNS result to query\n");
 		return AST_TEST_FAIL;
 	}
@@ -329,7 +329,7 @@
 		return AST_TEST_FAIL;
 	}
 
-	if (ast_dns_resolver_set_result(&some_query, 0, 0, 1, "asterisk.org")) {
+	if (ast_dns_resolver_set_result(&some_query, 0, 0, 1, 0, "asterisk.org")) {
 		ast_test_status_update(test, "Unable to add bogus DNS result to query\n");
 		return AST_TEST_FAIL;
 	}
@@ -338,7 +338,7 @@
 		return AST_TEST_FAIL;
 	}
 
-	if (ast_dns_resolver_set_result(&some_query, 0, 1, 0, "asterisk.org")) {
+	if (ast_dns_resolver_set_result(&some_query, 0, 1, 0, 0, "asterisk.org")) {
 		ast_test_status_update(test, "Unable to add secure DNS result to query\n");
 		return AST_TEST_FAIL;
 	}
@@ -347,7 +347,7 @@
 		return AST_TEST_FAIL;
 	}
 
-	if (ast_dns_resolver_set_result(&some_query, 1, 0, 0, "asterisk.org")) {
+	if (ast_dns_resolver_set_result(&some_query, 1, 0, 0, 0, "asterisk.org")) {
 		ast_test_status_update(test, "Unable to add nxdomain DNS result to query\n");
 		return AST_TEST_FAIL;
 	}
@@ -379,12 +379,12 @@
 
 	memset(&some_query, 0, sizeof(some_query));
 
-	if (!ast_dns_resolver_set_result(&some_query, 0, 1, 1, "asterisk.org")) {
+	if (!ast_dns_resolver_set_result(&some_query, 0, 1, 1, 0, "asterisk.org")) {
 		ast_test_status_update(test, "Successfully added a result that was both secure and bogus\n");
 		return AST_TEST_FAIL;
 	}
 
-	if (!ast_dns_resolver_set_result(&some_query, 0, 0, 0, NULL)) {
+	if (!ast_dns_resolver_set_result(&some_query, 0, 0, 0, 0, NULL)) {
 		ast_test_status_update(test, "Successfully added result with no canonical name\n");
 		return AST_TEST_FAIL;
 	}
@@ -450,7 +450,7 @@
 
 	memset(&some_query, 0, sizeof(some_query));
 
-	if (ast_dns_resolver_set_result(&some_query, 0, 0, 0, "asterisk.org")) {
+	if (ast_dns_resolver_set_result(&some_query, 0, 0, 0, 0, "asterisk.org")) {
 		ast_test_status_update(test, "Unable to set result for DNS query\n");
 		return AST_TEST_FAIL;
 	}
@@ -548,7 +548,7 @@
 		return AST_TEST_FAIL;
 	}
 
-	if (ast_dns_resolver_set_result(&some_query, 0, 0, 0, "asterisk.org")) {
+	if (ast_dns_resolver_set_result(&some_query, 0, 0, 0, 0, "asterisk.org")) {
 		ast_test_status_update(test, "Unable to set result for DNS query\n");
 		return AST_TEST_FAIL;
 	}




More information about the asterisk-commits mailing list