<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14181">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
George Joseph: Looks good to me, but someone else must approve; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_rtp_asterisk: iterate all local addresses looking to populate ICE.<br><br>By using pjproject to give us a list of candidates, and then filtering,<br>if the host has >32 addresses configured, then it is possible that we<br>end up filtering out all 32 of those, and ending up with no candidates<br>at all. Instead, get getifaddrs (which pjsip is using underlying<br>anyway) to retrieve all local addresses, and iterate those, adding the<br>first 32 addresses not excluded by the ICE ACL.<br><br>In our setup at any point in time We've got between 6 and 328 addresses<br>on any given system. The lower limit is the lower limit but the upper<br>limit is growing on a near daily basis currently.<br><br>Change-Id: I109eaffc3e2b432f00bf958e3caa0f38cacb4edb<br>Signed-off-by: Jaco Kroon <jaco@uls.co.za><br>---<br>M res/res_rtp_asterisk.c<br>1 file changed, 142 insertions(+), 90 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c</span><br><span>index 7af7fe0..739b17b 100644</span><br><span>--- a/res/res_rtp_asterisk.c</span><br><span>+++ b/res/res_rtp_asterisk.c</span><br><span>@@ -214,6 +214,7 @@</span><br><span> static pj_str_t turnusername;</span><br><span> static pj_str_t turnpassword;</span><br><span> static struct stasis_subscription *acl_change_sub = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+static struct ast_sockaddr lo6 = { .len = 0 };</span><br><span> </span><br><span> /*! ACL for ICE addresses */</span><br><span> static struct ast_acl_list *ice_acl = NULL;</span><br><span>@@ -261,8 +262,8 @@</span><br><span> </span><br><span> /*! \brief Structure which contains ICE host candidate mapping information */</span><br><span> struct ast_ice_host_candidate {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr local;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr advertised;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_sockaddr local;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_sockaddr advertised;</span><br><span> unsigned int include_local;</span><br><span> AST_RWLIST_ENTRY(ast_ice_host_candidate) next;</span><br><span> };</span><br><span>@@ -721,29 +722,6 @@</span><br><span> AST_RWLIST_UNLOCK(&host_candidates);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/*! \brief Applies the ICE host candidate mapping */</span><br><span style="color: hsl(0, 100%, 40%);">-static unsigned int host_candidate_overrides_apply(unsigned int count, unsigned int max_count, pj_sockaddr addrs[])</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- int pos;</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_ice_host_candidate *candidate;</span><br><span style="color: hsl(0, 100%, 40%);">- unsigned int added = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- AST_RWLIST_RDLOCK(&host_candidates);</span><br><span style="color: hsl(0, 100%, 40%);">- for (pos = 0; pos < count; pos++) {</span><br><span style="color: hsl(0, 100%, 40%);">- AST_LIST_TRAVERSE(&host_candidates, candidate, next) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (!pj_sockaddr_cmp(&candidate->local, &addrs[pos])) {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr_copy_addr(&addrs[pos], &candidate->advertised);</span><br><span style="color: hsl(0, 100%, 40%);">- if (candidate->include_local && (count + (++added)) <= max_count) {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr_cp(&addrs[count + (added - 1)], &candidate->local);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- AST_RWLIST_UNLOCK(&host_candidates);</span><br><span style="color: hsl(0, 100%, 40%);">- return added;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /*! \brief Helper function which updates an ast_sockaddr with the candidate used for the component */</span><br><span> static void update_address_with_ice_candidate(pj_ice_sess *ice, enum ast_rtp_ice_component_type component,</span><br><span> struct ast_sockaddr *cand_address)</span><br><span>@@ -3451,18 +3429,12 @@</span><br><span> * \retval 0 if address is not ICE blacklisted</span><br><span> * \retval 1 if address is ICE blacklisted</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-static int rtp_address_is_ice_blacklisted(const pj_sockaddr_t *address)</span><br><span style="color: hsl(120, 100%, 40%);">+static int rtp_address_is_ice_blacklisted(const struct ast_sockaddr *address)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_sockaddr saddr;</span><br><span> int result = 0;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_sockaddr_from_pj_sockaddr(&saddr, address) < 0) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_ERROR, "Failed to convert pj_sockddr_t to ast_sockaddr - ICE blacklisting (default)\n");</span><br><span style="color: hsl(0, 100%, 40%);">- return 1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> ast_rwlock_rdlock(&ice_acl_lock);</span><br><span style="color: hsl(0, 100%, 40%);">- result |= ast_apply_acl_nolog(ice_acl, &saddr) == AST_SENSE_DENY;</span><br><span style="color: hsl(120, 100%, 40%);">+ result |= ast_apply_acl_nolog(ice_acl, address) == AST_SENSE_DENY;</span><br><span> ast_rwlock_unlock(&ice_acl_lock);</span><br><span> </span><br><span> return result;</span><br><span>@@ -3495,41 +3467,123 @@</span><br><span> static void rtp_add_candidates_to_ice(struct ast_rtp_instance *instance, struct ast_rtp *rtp, struct ast_sockaddr *addr, int port, int component,</span><br><span> int transport)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr address[PJ_ICE_MAX_CAND];</span><br><span style="color: hsl(0, 100%, 40%);">- unsigned int count = PJ_ARRAY_SIZE(address), pos = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- unsigned int max_count = PJ_ARRAY_SIZE(address);</span><br><span style="color: hsl(0, 100%, 40%);">- int basepos = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int count = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ifaddrs *ifa, *ia;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_sockaddr tmp;</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_sockaddr pjtmp;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_ice_host_candidate *candidate;</span><br><span style="color: hsl(120, 100%, 40%);">+ int af_inet_ok = 0, af_inet6_ok = 0;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* Add all the local interface IP addresses */</span><br><span> if (ast_sockaddr_is_ipv4(addr)) {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_enum_ip_interface(pj_AF_INET(), &count, address);</span><br><span style="color: hsl(120, 100%, 40%);">+ af_inet_ok = 1;</span><br><span> } else if (ast_sockaddr_is_any(addr)) {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_enum_ip_interface(pj_AF_UNSPEC(), &count, address);</span><br><span style="color: hsl(120, 100%, 40%);">+ af_inet_ok = af_inet6_ok = 1;</span><br><span> } else {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_enum_ip_interface(pj_AF_INET6(), &count, address);</span><br><span style="color: hsl(120, 100%, 40%);">+ af_inet6_ok = 1;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- count += host_candidate_overrides_apply(count, max_count, address);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- for (pos = 0; pos < count; pos++) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (!rtp_address_is_ice_blacklisted(&address[pos])) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (basepos == -1) {</span><br><span style="color: hsl(0, 100%, 40%);">- basepos = pos;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (getifaddrs(&ifa) < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* If we can't get addresses, we can't load ICE candidates */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_ERROR, "Error obtaining list of local addresses: %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ strerror(errno));</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Iterate through the list of addresses obtained from the system,</span><br><span style="color: hsl(120, 100%, 40%);">+ * until we've iterated through all of them, or accepted</span><br><span style="color: hsl(120, 100%, 40%);">+ * PJ_ICE_MAX_CAND candidates */</span><br><span style="color: hsl(120, 100%, 40%);">+ for (ia = ifa; ia && count < PJ_ICE_MAX_CAND; ia = ia->ifa_next) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Interface is either not UP or doesn't have an address assigned,</span><br><span style="color: hsl(120, 100%, 40%);">+ * eg, a ppp that just completed LCP but no IPCP yet */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ia->ifa_addr || (ia->ifa_flags & IFF_UP) == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr_set_port(&address[pos], port);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Filter out non-IPvX addresses, eg, link-layer */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ia->ifa_addr->sa_family != AF_INET && ia->ifa_addr->sa_family != AF_INET6) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</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%);">+ ast_sockaddr_from_sockaddr(&tmp, ia->ifa_addr);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ia->ifa_addr->sa_family == AF_INET) {</span><br><span style="color: hsl(120, 100%, 40%);">+ const struct sockaddr_in *sa_in = (struct sockaddr_in*)ia->ifa_addr;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!af_inet_ok) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</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%);">+ /* Skip 127.0.0.0/8 (loopback) */</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Don't use IFF_LOOPBACK check since one could assign usable</span><br><span style="color: hsl(120, 100%, 40%);">+ * publics to the loopback */</span><br><span style="color: hsl(120, 100%, 40%);">+ if ((sa_in->sin_addr.s_addr & htonl(0xFF000000)) == htonl(0x7F000000)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</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%);">+ /* Skip 0.0.0.0/8 based on RFC1122, and from pjproject */</span><br><span style="color: hsl(120, 100%, 40%);">+ if ((sa_in->sin_addr.s_addr & htonl(0xFF000000)) == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ } else { /* ia->ifa_addr->sa_family == AF_INET6 */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!af_inet6_ok) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</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%);">+ /* Filter ::1 */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_sockaddr_cmp_addr(&lo6, &tmp)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</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%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Pull in the host candidates from [ice_host_candidates] */</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_RWLIST_RDLOCK(&host_candidates);</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_LIST_TRAVERSE(&host_candidates, candidate, next) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_sockaddr_cmp(&candidate->local, &tmp)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* candidate->local matches actual assigned, so check if</span><br><span style="color: hsl(120, 100%, 40%);">+ * advertised is blacklisted, if not, add it to the</span><br><span style="color: hsl(120, 100%, 40%);">+ * advertised list. Not that it would make sense to remap</span><br><span style="color: hsl(120, 100%, 40%);">+ * a local address to a blacklisted address, but honour it</span><br><span style="color: hsl(120, 100%, 40%);">+ * anyway. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!rtp_address_is_ice_blacklisted(&candidate->advertised)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sockaddr_to_pj_sockaddr(&candidate->advertised, &pjtmp);</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_sockaddr_set_port(&pjtmp, port);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_rtp_ice_add_cand(instance, rtp, component, transport,</span><br><span style="color: hsl(120, 100%, 40%);">+ PJ_ICE_CAND_TYPE_HOST, 65535, &pjtmp, &pjtmp, NULL,</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_sockaddr_get_len(&pjtmp));</span><br><span style="color: hsl(120, 100%, 40%);">+ ++count;</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 (!candidate->include_local) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* We don't want to advertise the actual address */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sockaddr_setnull(&tmp);</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%);">+ break;</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%);">+ AST_RWLIST_UNLOCK(&host_candidates);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* we had an entry in [ice_host_candidates] that matched, and</span><br><span style="color: hsl(120, 100%, 40%);">+ * didn't have include_local_address set. Alternatively, adding</span><br><span style="color: hsl(120, 100%, 40%);">+ * that match resulted in us going to PJ_ICE_MAX_CAND */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_sockaddr_isnull(&tmp) || count == PJ_ICE_MAX_CAND) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</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 (rtp_address_is_ice_blacklisted(&tmp)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</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%);">+ ast_sockaddr_to_pj_sockaddr(&tmp, &pjtmp);</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_sockaddr_set_port(&pjtmp, port);</span><br><span> ast_rtp_ice_add_cand(instance, rtp, component, transport,</span><br><span style="color: hsl(0, 100%, 40%);">- PJ_ICE_CAND_TYPE_HOST, 65535, &address[pos], &address[pos], NULL,</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr_get_len(&address[pos]));</span><br><span style="color: hsl(120, 100%, 40%);">+ PJ_ICE_CAND_TYPE_HOST, 65535, &pjtmp, &pjtmp, NULL,</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_sockaddr_get_len(&pjtmp));</span><br><span style="color: hsl(120, 100%, 40%);">+ ++count;</span><br><span> }</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (basepos == -1) {</span><br><span style="color: hsl(0, 100%, 40%);">- /* start with first address unless excluded above */</span><br><span style="color: hsl(0, 100%, 40%);">- basepos = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span> </span><br><span> /* If configured to use a STUN server to get our external mapped address do so */</span><br><span style="color: hsl(0, 100%, 40%);">- if (count && stunaddr.sin_addr.s_addr && !stun_address_is_blacklisted(addr) &&</span><br><span style="color: hsl(0, 100%, 40%);">- (ast_sockaddr_is_ipv4(addr) || ast_sockaddr_is_any(addr))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (stunaddr.sin_addr.s_addr && !stun_address_is_blacklisted(addr) &&</span><br><span style="color: hsl(120, 100%, 40%);">+ (ast_sockaddr_is_ipv4(addr) || ast_sockaddr_is_any(addr)) &&</span><br><span style="color: hsl(120, 100%, 40%);">+ count < PJ_ICE_MAX_CAND) {</span><br><span> struct sockaddr_in answer;</span><br><span> int rsp;</span><br><span> </span><br><span>@@ -3542,41 +3596,38 @@</span><br><span> ? rtp->rtcp->s : rtp->s, &stunaddr, NULL, &answer);</span><br><span> ao2_lock(instance);</span><br><span> if (!rsp) {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr base;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_rtp_engine_ice_candidate *candidate;</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_sockaddr ext, base;</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_str_t mapped = pj_str(ast_strdupa(ast_inet_ntoa(answer.sin_addr)));</span><br><span style="color: hsl(120, 100%, 40%);">+ int srflx = 1, baseset = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ao2_iterator i;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* Use the first local IPv4 host candidate as the base */</span><br><span style="color: hsl(0, 100%, 40%);">- for (pos = basepos; pos < count; pos++) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (address[pos].addr.sa_family == PJ_AF_INET &&</span><br><span style="color: hsl(0, 100%, 40%);">- !rtp_address_is_ice_blacklisted(&address[pos])) {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr_cp(&base, &address[pos]);</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_sockaddr_init(pj_AF_INET(), &ext, &mapped, ntohs(answer.sin_port));</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 the returned address is the same as one of our host</span><br><span style="color: hsl(120, 100%, 40%);">+ * candidates, don't send the srflx. At the same time,</span><br><span style="color: hsl(120, 100%, 40%);">+ * we need to set the base address (raddr).</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ i = ao2_iterator_init(rtp->ice_local_candidates, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ while (srflx && (candidate = ao2_iterator_next(&i))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!baseset && ast_sockaddr_is_ipv4(&candidate->address)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ baseset = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sockaddr_to_pj_sockaddr(&candidate->address, &base);</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!pj_sockaddr_cmp(&candidate->address, &ext)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ srflx = 0;</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%);">+ ao2_ref(candidate, -1);</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_iterator_destroy(&i);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (pos < count) {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr ext;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_str_t mapped = pj_str(ast_strdupa(ast_inet_ntoa(answer.sin_addr)));</span><br><span style="color: hsl(0, 100%, 40%);">- int srflx = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr_init(pj_AF_INET(), &ext, &mapped, ntohs(answer.sin_port));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /*</span><br><span style="color: hsl(0, 100%, 40%);">- * If the returned address is the same as one of our host</span><br><span style="color: hsl(0, 100%, 40%);">- * candidates, don't send the srflx</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- for (pos = 0; pos < count; pos++) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (pj_sockaddr_cmp(&address[pos], &ext) == 0 &&</span><br><span style="color: hsl(0, 100%, 40%);">- !rtp_address_is_ice_blacklisted(&address[pos])) {</span><br><span style="color: hsl(0, 100%, 40%);">- srflx = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (srflx) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_rtp_ice_add_cand(instance, rtp, component, transport,</span><br><span style="color: hsl(0, 100%, 40%);">- PJ_ICE_CAND_TYPE_SRFLX, 65535, &ext, &base, &base,</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr_get_len(&ext));</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (srflx && baseset) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_rtp_ice_add_cand(instance, rtp, component, transport,</span><br><span style="color: hsl(120, 100%, 40%);">+ PJ_ICE_CAND_TYPE_SRFLX, 65535, &ext, &base, &base,</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_sockaddr_get_len(&ext));</span><br><span> }</span><br><span> }</span><br><span> }</span><br><span>@@ -9025,7 +9076,6 @@</span><br><span> AST_RWLIST_WRLOCK(&host_candidates);</span><br><span> for (var = ast_variable_browse(cfg, "ice_host_candidates"); var; var = var->next) {</span><br><span> struct ast_sockaddr local_addr, advertised_addr;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_str_t address;</span><br><span> unsigned int include_local_address = 0;</span><br><span> char *sep;</span><br><span> </span><br><span>@@ -9057,8 +9107,8 @@</span><br><span> </span><br><span> candidate->include_local = include_local_address;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&address, ast_sockaddr_stringify(&local_addr)), &candidate->local);</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&address, ast_sockaddr_stringify(&advertised_addr)), &candidate->advertised);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sockaddr_copy(&candidate->local, &local_addr);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sockaddr_copy(&candidate->advertised, &advertised_addr);</span><br><span> </span><br><span> AST_RWLIST_INSERT_TAIL(&host_candidates, candidate, next);</span><br><span> }</span><br><span>@@ -9162,6 +9212,8 @@</span><br><span> #ifdef HAVE_PJPROJECT</span><br><span> pj_lock_t *lock;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sockaddr_parse(&lo6, "::1", PARSE_PORT_IGNORE);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> AST_PJPROJECT_INIT_LOG_LEVEL();</span><br><span> if (pj_init() != PJ_SUCCESS) {</span><br><span> return AST_MODULE_LOAD_DECLINE;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14181">change 14181</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/+/14181"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I109eaffc3e2b432f00bf958e3caa0f38cacb4edb </div>
<div style="display:none"> Gerrit-Change-Number: 14181 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Jaco Kroon <jaco@uls.co.za> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </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>