<p>Jaco Kroon has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13362">View Change</a></p><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 my setup at any point in time I've got between 6 and 328 addresses on<br>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, 120 insertions(+), 87 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/62/13362/1</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 7ebe5cc..87c137f 100644</span><br><span>--- a/res/res_rtp_asterisk.c</span><br><span>+++ b/res/res_rtp_asterisk.c</span><br><span>@@ -248,8 +248,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>@@ -643,29 +643,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>@@ -3021,18 +2998,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(ice_acl, &saddr, "RTP ICE ACL: ") == AST_SENSE_DENY;</span><br><span style="color: hsl(120, 100%, 40%);">+    result |= ast_apply_acl(ice_acl, address, "RTP ICE ACL: ") == AST_SENSE_DENY;</span><br><span>      ast_rwlock_unlock(&ice_acl_lock);</span><br><span> </span><br><span>    return result;</span><br><span>@@ -3065,40 +3036,100 @@</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%);">+     static struct ast_sockaddr lo6 = { .len = 0 };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-      /* Add all the local interface IP addresses */</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 style="color: hsl(120, 100%, 40%);">+</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(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%);">+              for (ia = ifa; ia && count < PJ_ICE_MAX_CAND; ia = ia->ifa_next) {</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%);">-   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%);">+                        ast_sockaddr_setnull(&tmp);</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%);">+                        if (ast_sockaddr_isnull(&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%);">+                 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%);">+                           /* 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 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%);">+                           /* 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%);">+                     } else if (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%);">+                           if (ast_sockaddr_isnull(&lo6)) {</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 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) == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                                   continue;</span><br><span style="color: hsl(120, 100%, 40%);">+                     } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                              /* Only AF_INET (IPv4) and AF_INET6 (IPv6) supported. */</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%);">+                      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) == 0) {</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%);">+                                             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%);">+                     }</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%);">+                    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%);">+                   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(120, 100%, 40%);">+        if (stunaddr.sin_addr.s_addr && !stun_address_is_blacklisted(addr) &&</span><br><span>                (ast_sockaddr_is_ipv4(addr) || ast_sockaddr_is_any(addr))) {</span><br><span>                 struct sockaddr_in answer;</span><br><span>           int rsp;</span><br><span>@@ -3112,41 +3143,44 @@</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;</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(0, 100%, 40%);">-                          }</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%);">+                      if (ast_sockaddr_is_any(addr)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                              baseset = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+                  } else {</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(addr, &base);</span><br><span>                        }</span><br><span style="color: hsl(0, 100%, 40%);">-</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(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</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) && !ast_sockaddr_is_any(&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> </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(120, 100%, 40%);">+                               if (pj_sockaddr_cmp(&candidate->address, &ext) == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                     srflx = 0;</span><br><span>                           }</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 style="color: hsl(120, 100%, 40%);">+                       }</span><br><span style="color: hsl(120, 100%, 40%);">+                     ao2_iterator_destroy(&i);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                       if (srflx) {</span><br><span style="color: hsl(120, 100%, 40%);">+                          ast_sockaddr_to_pj_sockaddr(addr, &base);</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>@@ -6799,7 +6833,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>@@ -6831,8 +6864,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></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13362">change 13362</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/+/13362"/><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-Change-Id: I109eaffc3e2b432f00bf958e3caa0f38cacb4edb </div>
<div style="display:none"> Gerrit-Change-Number: 13362 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Jaco Kroon <jaco@uls.co.za> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>