<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8954">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Corey Farrell: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Joshua Colp: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_hep: Adds hostname resolution support for capture_address<br><br>Previously, only an IP address would be accepted for the capture_address config<br>setting in hep.conf. This change allows capture_address to be a resolvable<br>hostname or an IP address.<br><br>ASTERISK-27796 #close<br>Reported-By: Sebastian Gutierrez<br><br>Change-Id: I33e1a37a8b86e20505dadeda760b861a9ef51f6f<br>---<br>M res/res_hep.c<br>1 file changed, 23 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_hep.c b/res/res_hep.c<br>index 4e548e2..cc7028b 100644<br>--- a/res/res_hep.c<br>+++ b/res/res_hep.c<br>@@ -367,6 +367,27 @@<br> }<br> }<br> <br>+/*! \brief Pulls first resolved address and returns it */<br>+static int ast_sockaddr_resolve_first_af(struct ast_sockaddr *addr,<br>+ const char* name, int flag, int family)<br>+{<br>+ struct ast_sockaddr *addrs;<br>+ int addrs_cnt;<br>+<br>+ addrs_cnt = ast_sockaddr_resolve(&addrs, name, flag, family);<br>+ if (addrs_cnt <= 0) {<br>+ return 1;<br>+ }<br>+ if (addrs_cnt > 1) {<br>+ ast_debug(1, "Multiple addresses resolving %s, using the first one only\n", name);<br>+ }<br>+<br>+ ast_sockaddr_copy(addr, &addrs[0]);<br>+<br>+ ast_free(addrs);<br>+ return 0;<br>+}<br>+<br> /*! \brief Allocate the HEPv3 run-time data */<br> static struct hepv3_runtime_data *hepv3_data_alloc(struct hepv3_global_config *config)<br> {<br>@@ -379,10 +400,11 @@<br> <br> data->sockfd = -1;<br> <br>- if (!ast_sockaddr_parse(&data->remote_addr, config->capture_address, PARSE_PORT_REQUIRE)) {<br>+ if (ast_sockaddr_resolve_first_af(&data->remote_addr, config->capture_address, PARSE_PORT_REQUIRE, AST_AF_UNSPEC)) {<br> ast_log(AST_LOG_WARNING, "Failed to create address from %s\n", config->capture_address);<br> ao2_ref(data, -1);<br> return NULL;<br>+<br> }<br> <br> data->sockfd = socket(ast_sockaddr_is_ipv6(&data->remote_addr) ? AF_INET6 : AF_INET, SOCK_DGRAM, 0);<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8954">change 8954</a>. To unsubscribe, 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/8954"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I33e1a37a8b86e20505dadeda760b861a9ef51f6f </div>
<div style="display:none"> Gerrit-Change-Number: 8954 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Matthew Fredrickson <creslin@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>