Merged revisions 127663 via svnmerge from
[asterisk/asterisk.git] / main / dns.c
index b8530d0..4884406 100644 (file)
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/nameser.h>
+#include "asterisk/network.h"
+#include <arpa/nameser.h>      /* res_* functions */
 #include <resolv.h>
-#include <unistd.h>
 
-#include "asterisk/logger.h"
 #include "asterisk/channel.h"
 #include "asterisk/dns.h"
 #include "asterisk/endian.h"
-#include "asterisk/options.h"
 
 #define MAX_SIZE 4096
 
@@ -268,6 +263,7 @@ int ast_search_dns(void *context,
        int res, ret = -1;
 
 #ifdef HAVE_RES_NINIT
+       memset(&dnsstate, 0, sizeof(dnsstate));
        res_ninit(&dnsstate);
        res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer));
 #else
@@ -279,12 +275,10 @@ int ast_search_dns(void *context,
                if ((res = dns_parse_answer(context, class, type, answer, res, callback)) < 0) {
                        ast_log(LOG_WARNING, "DNS Parse error for %s\n", dname);
                        ret = -1;
-               }
-               else if (ret == 0) {
+               } else if (res == 0) {
                        ast_debug(1, "No matches found in DNS for %s\n", dname);
                        ret = 0;
-               }
-               else
+               } else
                        ret = 1;
        }
 #ifdef HAVE_RES_NINIT