<p>Matthew Fredrickson has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8953">View Change</a></p><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;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/53/8953/1</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 a91b7ec..73a7608 100644<br>--- a/res/res_hep.c<br>+++ b/res/res_hep.c<br>@@ -369,6 +369,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>@@ -381,10 +402,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/8953">change 8953</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/8953"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I33e1a37a8b86e20505dadeda760b861a9ef51f6f </div>
<div style="display:none"> Gerrit-Change-Number: 8953 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Matthew Fredrickson <creslin@digium.com> </div>