Index: funcs/func_enum.c
===================================================================
--- a/funcs/func_enum.c (revision 180682)
+++ b/funcs/func_enum.c (working copy)
@@ -78,7 +78,7 @@
The number of the result that you want to retrieve.
Results start at 1. If this argument is specified
as getnum, then it will return the total number of results
- that are available.
+ that are available or -1 on error.
@@ -360,7 +360,7 @@
erds = datastore->data;
if (!strcasecmp(args.resultnum, "getnum")) {
- snprintf(buf, len, "%u", erds->context->naptr_rrs_count);
+ snprintf(buf, len, "%d", erds->context->naptr_rrs_count);
res = 0;
goto finish;
}
Index: main/dns.c
===================================================================
--- a/main/dns.c (revision 180682)
+++ b/main/dns.c (working copy)
@@ -36,6 +36,7 @@
#include "asterisk/network.h"
#include /* res_* functions */
#include
+#include
#include "asterisk/channel.h"
#include "asterisk/dns.h"
@@ -280,6 +281,20 @@
ret = 0;
} else
ret = 1;
+ } else {
+#ifdef HAVE_RES_NINIT
+ res = dnsstate.res_h_errno;
+ ast_debug(1, "dnsstate.res_h_errno: %d\n", res);
+ ast_log(LOG_WARNING, "dnsstate.res_h_errno: %d\n", res);
+#else
+ res = h_errno;
+ ast_debug(1, "h_errno: %d\n", res);
+ ast_log(LOG_WARNING, "h_errno: %d\n", res);
+#endif
+ if (res == NO_DATA) {
+ ast_debug(1, "No matching DNS records for %s\n", dname);
+ ret = 0;
+ }
}
#ifdef HAVE_RES_NINIT
#ifdef HAVE_RES_NDESTROY
Index: main/enum.c
===================================================================
--- a/main/enum.c (revision 180682)
+++ b/main/enum.c (working copy)
@@ -851,11 +851,15 @@
ret = ast_search_dns(context, tmp, C_IN, T_NAPTR, enum_callback);
time_end = ast_tvnow();
- ast_verb(2, "ast_get_enum() profiling: %s, %s, %d ms\n",
- (ret == 0) ? "OK" : "FAIL", tmp, ast_tvdiff_ms(time_end, time_start));
+ ast_verb(2, "ast_get_enum() profiling: %d, %s, %d ms\n",
+ ret, tmp, ast_tvdiff_ms(time_end, time_start));
- if (ret < 0) {
+ if (ret == 0) {
+ ast_debug(1, "Need more digits for: %s\n", tmp);
+ strcpy(dst, "0");
+ } else if (ret < 0) {
ast_debug(1, "No such number found: %s (%s)\n", tmp, strerror(errno));
+ context->naptr_rrs_count = -1;
strcpy(dst, "0");
ret = 0;
}