<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16413">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">dns.c: Load IPv6 DNS resolvers if configured.<br><br>IPv6 nameserver addresses are stored in different part of the<br>__res_state structure, so look there if we appear to have support for<br>it.<br><br>ASTERISK-28004 #close<br><br>Change-Id: I67067077d8a406ee996664518d9c8fbf11f6977d<br>---<br>M configure<br>M configure.ac<br>M include/asterisk/autoconfig.h.in<br>M main/dns.c<br>4 files changed, 67 insertions(+), 9 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/13/16413/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configure b/configure</span><br><span>index 586f612..3ddc925 100755</span><br><span>--- a/configure</span><br><span>+++ b/configure</span><br><span>@@ -1288,7 +1288,6 @@</span><br><span> BUILD_VENDOR</span><br><span> BUILD_CPU</span><br><span> BUILD_PLATFORM</span><br><span style="color: hsl(0, 100%, 40%);">-astcachedir</span><br><span> astvarrundir</span><br><span> astlogdir</span><br><span> astspooldir</span><br><span>@@ -1301,6 +1300,7 @@</span><br><span> astlibdir</span><br><span> astheaderdir</span><br><span> astetcdir</span><br><span style="color: hsl(120, 100%, 40%);">+astcachedir</span><br><span> astsbindir</span><br><span> EGREP</span><br><span> GREP</span><br><span>@@ -1341,6 +1341,7 @@</span><br><span> docdir</span><br><span> oldincludedir</span><br><span> includedir</span><br><span style="color: hsl(120, 100%, 40%);">+runstatedir</span><br><span> localstatedir</span><br><span> sharedstatedir</span><br><span> sysconfdir</span><br><span>@@ -1530,6 +1531,7 @@</span><br><span> sysconfdir='${prefix}/etc'</span><br><span> sharedstatedir='${prefix}/com'</span><br><span> localstatedir='${prefix}/var'</span><br><span style="color: hsl(120, 100%, 40%);">+runstatedir='${localstatedir}/run'</span><br><span> includedir='${prefix}/include'</span><br><span> oldincludedir='/usr/include'</span><br><span> docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'</span><br><span>@@ -1782,6 +1784,15 @@</span><br><span> | -silent | --silent | --silen | --sile | --sil)</span><br><span> silent=yes ;;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ -runstatedir | --runstatedir | --runstatedi | --runstated \</span><br><span style="color: hsl(120, 100%, 40%);">+ | --runstate | --runstat | --runsta | --runst | --runs \</span><br><span style="color: hsl(120, 100%, 40%);">+ | --run | --ru | --r)</span><br><span style="color: hsl(120, 100%, 40%);">+ ac_prev=runstatedir ;;</span><br><span style="color: hsl(120, 100%, 40%);">+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \</span><br><span style="color: hsl(120, 100%, 40%);">+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \</span><br><span style="color: hsl(120, 100%, 40%);">+ | --run=* | --ru=* | --r=*)</span><br><span style="color: hsl(120, 100%, 40%);">+ runstatedir=$ac_optarg ;;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)</span><br><span> ac_prev=sbindir ;;</span><br><span> -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \</span><br><span>@@ -1919,7 +1930,7 @@</span><br><span> for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \</span><br><span> datadir sysconfdir sharedstatedir localstatedir includedir \</span><br><span> oldincludedir docdir infodir htmldir dvidir pdfdir psdir \</span><br><span style="color: hsl(0, 100%, 40%);">- libdir localedir mandir</span><br><span style="color: hsl(120, 100%, 40%);">+ libdir localedir mandir runstatedir</span><br><span> do</span><br><span> eval ac_val=\$$ac_var</span><br><span> # Remove trailing slashes.</span><br><span>@@ -2072,6 +2083,7 @@</span><br><span> --sysconfdir=DIR read-only single-machine data [PREFIX/etc]</span><br><span> --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]</span><br><span> --localstatedir=DIR modifiable single-machine data [PREFIX/var]</span><br><span style="color: hsl(120, 100%, 40%);">+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]</span><br><span> --libdir=DIR object code libraries [EPREFIX/lib]</span><br><span> --includedir=DIR C header files [PREFIX/include]</span><br><span> --oldincludedir=DIR C header files for non-gcc [/usr/include]</span><br><span>@@ -9332,6 +9344,12 @@</span><br><span> $as_echo "#define HAVE_PJSIP_ENDPOINT_COMPACT_FORM 1" >>confdefs.h</span><br><span> </span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo "#define HAVE_PJSIP_TRANSPORT_DISABLE_CONNECTION_REUSE 1" >>confdefs.h</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo "#define HAVE_PJSIP_OAUTH_AUTHENTICATION 1" >>confdefs.h</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> $as_echo "#define HAVE_PJPROJECT_ON_VALID_ICE_PAIR_CALLBACK 1" >>confdefs.h</span><br><span> </span><br><span> </span><br><span>@@ -10834,6 +10852,7 @@</span><br><span> </span><br><span> </span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> MISDN_DESCRIP="mISDN user"</span><br><span> MISDN_OPTION="misdn"</span><br><span> PBX_MISDN=0</span><br><span>@@ -14650,7 +14669,7 @@</span><br><span> We can't simply define LARGE_OFF_T to be 9223372036854775807,</span><br><span> since some C++ compilers masquerading as C compilers</span><br><span> incorrectly reject 9223372036854775807. */</span><br><span style="color: hsl(0, 100%, 40%);">-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))</span><br><span style="color: hsl(120, 100%, 40%);">+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))</span><br><span> int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721</span><br><span> && LARGE_OFF_T % 2147483647 == 1)</span><br><span> ? 1 : -1];</span><br><span>@@ -14696,7 +14715,7 @@</span><br><span> We can't simply define LARGE_OFF_T to be 9223372036854775807,</span><br><span> since some C++ compilers masquerading as C compilers</span><br><span> incorrectly reject 9223372036854775807. */</span><br><span style="color: hsl(0, 100%, 40%);">-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))</span><br><span style="color: hsl(120, 100%, 40%);">+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))</span><br><span> int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721</span><br><span> && LARGE_OFF_T % 2147483647 == 1)</span><br><span> ? 1 : -1];</span><br><span>@@ -14720,7 +14739,7 @@</span><br><span> We can't simply define LARGE_OFF_T to be 9223372036854775807,</span><br><span> since some C++ compilers masquerading as C compilers</span><br><span> incorrectly reject 9223372036854775807. */</span><br><span style="color: hsl(0, 100%, 40%);">-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))</span><br><span style="color: hsl(120, 100%, 40%);">+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))</span><br><span> int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721</span><br><span> && LARGE_OFF_T % 2147483647 == 1)</span><br><span> ? 1 : -1];</span><br><span>@@ -14765,7 +14784,7 @@</span><br><span> We can't simply define LARGE_OFF_T to be 9223372036854775807,</span><br><span> since some C++ compilers masquerading as C compilers</span><br><span> incorrectly reject 9223372036854775807. */</span><br><span style="color: hsl(0, 100%, 40%);">-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))</span><br><span style="color: hsl(120, 100%, 40%);">+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))</span><br><span> int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721</span><br><span> && LARGE_OFF_T % 2147483647 == 1)</span><br><span> ? 1 : -1];</span><br><span>@@ -14789,7 +14808,7 @@</span><br><span> We can't simply define LARGE_OFF_T to be 9223372036854775807,</span><br><span> since some C++ compilers masquerading as C compilers</span><br><span> incorrectly reject 9223372036854775807. */</span><br><span style="color: hsl(0, 100%, 40%);">-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))</span><br><span style="color: hsl(120, 100%, 40%);">+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))</span><br><span> int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721</span><br><span> && LARGE_OFF_T % 2147483647 == 1)</span><br><span> ? 1 : -1];</span><br><span>@@ -16089,6 +16108,8 @@</span><br><span> if (*(data + i) != *(data3 + i))</span><br><span> return 14;</span><br><span> close (fd);</span><br><span style="color: hsl(120, 100%, 40%);">+ free (data);</span><br><span style="color: hsl(120, 100%, 40%);">+ free (data3);</span><br><span> return 0;</span><br><span> }</span><br><span> _ACEOF</span><br><span>@@ -18919,6 +18940,17 @@</span><br><span> fi</span><br><span> rm -f core conftest.err conftest.$ac_objext \</span><br><span> conftest$ac_exeext conftest.$ac_ext</span><br><span style="color: hsl(120, 100%, 40%);">+ ac_fn_c_check_member "$LINENO" "struct __res_state" "_u._ext.nsaddrs" "ac_cv_member_struct___res_state__u__ext_nsaddrs" "#include <resolv.h></span><br><span style="color: hsl(120, 100%, 40%);">+"</span><br><span style="color: hsl(120, 100%, 40%);">+if test "x$ac_cv_member_struct___res_state__u__ext_nsaddrs" = xyes; then :</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+cat >>confdefs.h <<_ACEOF</span><br><span style="color: hsl(120, 100%, 40%);">+#define HAVE_STRUCT___RES_STATE__U__EXT_NSADDRS 1</span><br><span style="color: hsl(120, 100%, 40%);">+_ACEOF</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> else</span><br><span> { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5</span><br><span> $as_echo "no" >&6; }</span><br><span>diff --git a/configure.ac b/configure.ac</span><br><span>index 44c23c7..0bd1c50 100644</span><br><span>--- a/configure.ac</span><br><span>+++ b/configure.ac</span><br><span>@@ -1464,7 +1464,8 @@</span><br><span> AC_MSG_RESULT(yes)</span><br><span> AC_DEFINE([HAVE_RES_CLOSE], 1, [Define to 1 if your system has the close resolver function.]),</span><br><span> AC_MSG_RESULT(no)</span><br><span style="color: hsl(0, 100%, 40%);">- ),</span><br><span style="color: hsl(120, 100%, 40%);">+ )</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_CHECK_MEMBERS([struct __res_state._u._ext.nsaddrs], [], [], [[#include <resolv.h>]]),</span><br><span> AC_MSG_RESULT(no)</span><br><span> )</span><br><span> </span><br><span>diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in</span><br><span>index ae10643..bdb3e50 100644</span><br><span>--- a/include/asterisk/autoconfig.h.in</span><br><span>+++ b/include/asterisk/autoconfig.h.in</span><br><span>@@ -661,12 +661,19 @@</span><br><span> support feature. */</span><br><span> #undef HAVE_PJSIP_INV_SESSION_REF</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Define if your system has HAVE_PJSIP_OAUTH_AUTHENTICATION declared */</span><br><span style="color: hsl(120, 100%, 40%);">+#undef HAVE_PJSIP_OAUTH_AUTHENTICATION</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Define if your system has the PJSIP_REPLACE_MEDIA_STREAM headers. */</span><br><span> #undef HAVE_PJSIP_REPLACE_MEDIA_STREAM</span><br><span> </span><br><span> /* Define if your system has the PJSIP_TLS_TRANSPORT_PROTO headers. */</span><br><span> #undef HAVE_PJSIP_TLS_TRANSPORT_PROTO</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Define if your system has HAVE_PJSIP_TRANSPORT_DISABLE_CONNECTION_REUSE</span><br><span style="color: hsl(120, 100%, 40%);">+ declared */</span><br><span style="color: hsl(120, 100%, 40%);">+#undef HAVE_PJSIP_TRANSPORT_DISABLE_CONNECTION_REUSE</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Define to 1 if PJPROJECT has the pjsip_tsx_layer_find_tsx2 support feature.</span><br><span> */</span><br><span> #undef HAVE_PJSIP_TSX_LAYER_FIND_TSX2</span><br><span>@@ -1066,6 +1073,9 @@</span><br><span> /* Define to 1 if `uid' is a member of `struct ucred'. */</span><br><span> #undef HAVE_STRUCT_UCRED_UID</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Define to 1 if `_u._ext.nsaddrs' is a member of `struct __res_state'. */</span><br><span style="color: hsl(120, 100%, 40%);">+#undef HAVE_STRUCT___RES_STATE__U__EXT_NSADDRS</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Define to 1 if you have the mISDN Supplemental Services library. */</span><br><span> #undef HAVE_SUPPSERV</span><br><span> </span><br><span>diff --git a/main/dns.c b/main/dns.c</span><br><span>index 782d4a8..9cf0cf4 100644</span><br><span>--- a/main/dns.c</span><br><span>+++ b/main/dns.c</span><br><span>@@ -605,7 +605,22 @@</span><br><span> #endif</span><br><span> </span><br><span> for (i = 0; i < state->nscount; i++) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_container_add(nameservers, ast_inet_ntoa(state->nsaddr_list[i].sin_addr));</span><br><span style="color: hsl(120, 100%, 40%);">+ char addr[INET6_ADDRSTRLEN];</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *addrp = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* glibc sets sin_family to 0 when the nameserver is an IPv6 address */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (state->nsaddr_list[i].sin_family) {</span><br><span style="color: hsl(120, 100%, 40%);">+ addrp = inet_ntop(AF_INET, &state->nsaddr_list[i].sin_addr, addr, sizeof(addr));</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(HAVE_RES_NINIT) && defined(HAVE_STRUCT___RES_STATE__U__EXT_NSADDRS)</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (state->_u._ext.nsaddrs[i]) {</span><br><span style="color: hsl(120, 100%, 40%);">+ addrp = inet_ntop(AF_INET6, &state->_u._ext.nsaddrs[i]->sin6_addr, addr, sizeof(addr));</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (addrp) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "Discovered nameserver: %s\n", addrp);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_container_add(nameservers, addrp);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span> #ifdef HAVE_RES_NINIT</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16413">change 16413</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/16413"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I67067077d8a406ee996664518d9c8fbf11f6977d </div>
<div style="display:none"> Gerrit-Change-Number: 16413 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>