]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
dns.c: Load IPv6 DNS resolvers if configured.
authorSean Bright <sean.bright@gmail.com>
Mon, 6 Sep 2021 16:37:08 +0000 (12:37 -0400)
committerKevin Harwell <kharwell@digium.com>
Wed, 8 Sep 2021 23:17:53 +0000 (18:17 -0500)
IPv6 nameserver addresses are stored in different part of the
__res_state structure, so look there if we appear to have support for
it.

ASTERISK-28004 #close

Change-Id: I67067077d8a406ee996664518d9c8fbf11f6977d

configure
configure.ac
include/asterisk/autoconfig.h.in
main/dns.c

index 586f612ac9d796412a27c19653964bfd9e23567d..3ddc925db73171e1fb5fb91059fa63ae866130aa 100755 (executable)
--- a/configure
+++ b/configure
@@ -1288,7 +1288,6 @@ BUILD_OS
 BUILD_VENDOR
 BUILD_CPU
 BUILD_PLATFORM
-astcachedir
 astvarrundir
 astlogdir
 astspooldir
@@ -1301,6 +1300,7 @@ astmoddir
 astlibdir
 astheaderdir
 astetcdir
+astcachedir
 astsbindir
 EGREP
 GREP
@@ -1341,6 +1341,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -1530,6 +1531,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1782,6 +1784,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1919,7 +1930,7 @@ fi
 for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
                datadir sysconfdir sharedstatedir localstatedir includedir \
                oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-               libdir localedir mandir
+               libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -2072,6 +2083,7 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -9332,6 +9344,12 @@ $as_echo "#define HAVE_PJSIP_INV_ACCEPT_MULTIPLE_SDP_ANSWERS 1" >>confdefs.h
 $as_echo "#define HAVE_PJSIP_ENDPOINT_COMPACT_FORM 1" >>confdefs.h
 
 
+$as_echo "#define HAVE_PJSIP_TRANSPORT_DISABLE_CONNECTION_REUSE 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_PJSIP_OAUTH_AUTHENTICATION 1" >>confdefs.h
+
+
 $as_echo "#define HAVE_PJPROJECT_ON_VALID_ICE_PAIR_CALLBACK 1" >>confdefs.h
 
 
@@ -10834,6 +10852,7 @@ fi
 
 
 
+
     MISDN_DESCRIP="mISDN user"
     MISDN_OPTION="misdn"
     PBX_MISDN=0
@@ -14650,7 +14669,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
                       && LARGE_OFF_T % 2147483647 == 1)
                      ? 1 : -1];
@@ -14696,7 +14715,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
                       && LARGE_OFF_T % 2147483647 == 1)
                      ? 1 : -1];
@@ -14720,7 +14739,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
                       && LARGE_OFF_T % 2147483647 == 1)
                      ? 1 : -1];
@@ -14765,7 +14784,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
                       && LARGE_OFF_T % 2147483647 == 1)
                      ? 1 : -1];
@@ -14789,7 +14808,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
                       && LARGE_OFF_T % 2147483647 == 1)
                      ? 1 : -1];
@@ -16089,6 +16108,8 @@ main ()
     if (*(data + i) != *(data3 + i))
       return 14;
   close (fd);
+  free (data);
+  free (data3);
   return 0;
 }
 _ACEOF
@@ -18919,6 +18940,17 @@ $as_echo "no" >&6; }
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+       ac_fn_c_check_member "$LINENO" "struct __res_state" "_u._ext.nsaddrs" "ac_cv_member_struct___res_state__u__ext_nsaddrs" "#include <resolv.h>
+"
+if test "x$ac_cv_member_struct___res_state__u__ext_nsaddrs" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT___RES_STATE__U__EXT_NSADDRS 1
+_ACEOF
+
+
+fi
+
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
index 44c23c7f58cfd7901f5992a06702c8b6084c54c5..0bd1c505f19228e6819b49541392ce27ea5e91a8 100644 (file)
@@ -1464,7 +1464,8 @@ AC_LINK_IFELSE(
                AC_MSG_RESULT(yes)
                AC_DEFINE([HAVE_RES_CLOSE], 1, [Define to 1 if your system has the close resolver function.]),
                AC_MSG_RESULT(no)
-       ),
+       )
+       AC_CHECK_MEMBERS([struct __res_state._u._ext.nsaddrs], [], [], [[#include <resolv.h>]]),
        AC_MSG_RESULT(no)
 )
 
index ae10643ab6149b98fcd10bb751dce3a68a512483..bdb3e5099b1fc9a67af98d74ba313b403c903be3 100644 (file)
    support feature. */
 #undef HAVE_PJSIP_INV_SESSION_REF
 
+/* Define if your system has HAVE_PJSIP_OAUTH_AUTHENTICATION declared */
+#undef HAVE_PJSIP_OAUTH_AUTHENTICATION
+
 /* Define if your system has the PJSIP_REPLACE_MEDIA_STREAM headers. */
 #undef HAVE_PJSIP_REPLACE_MEDIA_STREAM
 
 /* Define if your system has the PJSIP_TLS_TRANSPORT_PROTO headers. */
 #undef HAVE_PJSIP_TLS_TRANSPORT_PROTO
 
+/* Define if your system has HAVE_PJSIP_TRANSPORT_DISABLE_CONNECTION_REUSE
+   declared */
+#undef HAVE_PJSIP_TRANSPORT_DISABLE_CONNECTION_REUSE
+
 /* Define to 1 if PJPROJECT has the pjsip_tsx_layer_find_tsx2 support feature.
    */
 #undef HAVE_PJSIP_TSX_LAYER_FIND_TSX2
 /* Define to 1 if `uid' is a member of `struct ucred'. */
 #undef HAVE_STRUCT_UCRED_UID
 
+/* Define to 1 if `_u._ext.nsaddrs' is a member of `struct __res_state'. */
+#undef HAVE_STRUCT___RES_STATE__U__EXT_NSADDRS
+
 /* Define to 1 if you have the mISDN Supplemental Services library. */
 #undef HAVE_SUPPSERV
 
index 782d4a8f8de2ed4d7d472daf18b2f857f864123e..9cf0cf41ded573c3b0e48c6981ee4af4cc70d5d7 100644 (file)
@@ -605,7 +605,22 @@ struct ao2_container *ast_dns_get_nameservers(void)
 #endif
 
        for (i = 0; i < state->nscount; i++) {
-               ast_str_container_add(nameservers, ast_inet_ntoa(state->nsaddr_list[i].sin_addr));
+               char addr[INET6_ADDRSTRLEN];
+               const char *addrp = NULL;
+
+               /* glibc sets sin_family to 0 when the nameserver is an IPv6 address */
+               if (state->nsaddr_list[i].sin_family) {
+                       addrp = inet_ntop(AF_INET, &state->nsaddr_list[i].sin_addr, addr, sizeof(addr));
+#if defined(HAVE_RES_NINIT) && defined(HAVE_STRUCT___RES_STATE__U__EXT_NSADDRS)
+               } else if (state->_u._ext.nsaddrs[i]) {
+                       addrp = inet_ntop(AF_INET6, &state->_u._ext.nsaddrs[i]->sin6_addr, addr, sizeof(addr));
+#endif
+               }
+
+               if (addrp) {
+                       ast_debug(1, "Discovered nameserver: %s\n", addrp);
+                       ast_str_container_add(nameservers, addrp);
+               }
        }
 
 #ifdef HAVE_RES_NINIT