<p>Kevin Harwell <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16414">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved; Approved for Submit
</div><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, 54 insertions(+), 9 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configure b/configure</span><br><span>index 3a2a6a4..174659d 100755</span><br><span>--- a/configure</span><br><span>+++ b/configure</span><br><span>@@ -1296,7 +1296,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>@@ -1309,6 +1308,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>@@ -1349,6 +1349,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>@@ -1538,6 +1539,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>@@ -1790,6 +1792,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>@@ -1927,7 +1938,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>@@ -2080,6 +2091,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>@@ -10848,6 +10860,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>@@ -14688,7 +14701,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>@@ -14734,7 +14747,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>@@ -14758,7 +14771,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>@@ -14803,7 +14816,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>@@ -14827,7 +14840,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>@@ -16127,6 +16140,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>@@ -18957,6 +18972,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 4fb75f2..e5d1595 100644</span><br><span>--- a/configure.ac</span><br><span>+++ b/configure.ac</span><br><span>@@ -1466,7 +1466,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 2c770d1..968e97d 100644</span><br><span>--- a/include/asterisk/autoconfig.h.in</span><br><span>+++ b/include/asterisk/autoconfig.h.in</span><br><span>@@ -1073,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><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16414">change 16414</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/+/16414"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: I67067077d8a406ee996664518d9c8fbf11f6977d </div>
<div style="display:none"> Gerrit-Change-Number: 16414 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>