<p>Friendly Automation <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11390">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_rtp_asterisk:  Add ability to propose local address in ICE<br><br>You can now add the "include_local_address" flag to an entry in<br>rtp.conf "[ice_host_candidates]" to include both the advertized<br>address and the local address in ICE negotiation:<br><br>[ice_host_candidates]<br>192.168.1.1 = 1.2.3.4,include_local_address<br><br>This causes both 192.168.1.1 and 1.2.3.4 to be advertized.<br><br>Change-Id: Ide492cd45ce84546175ca7d557de80d9770513db<br>---<br>M configs/samples/rtp.conf.sample<br>A doc/CHANGES-staging/rtp_ice_include_local_address.txt<br>M res/res_rtp_asterisk.c<br>3 files changed, 33 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configs/samples/rtp.conf.sample b/configs/samples/rtp.conf.sample</span><br><span>index 26a70d2..a2664e4 100644</span><br><span>--- a/configs/samples/rtp.conf.sample</span><br><span>+++ b/configs/samples/rtp.conf.sample</span><br><span>@@ -118,13 +118,19 @@</span><br><span> ;</span><br><span> ; The format for these overrides is:</span><br><span> ;</span><br><span style="color: hsl(0, 100%, 40%);">-;    <local address> => <advertised address></span><br><span style="color: hsl(120, 100%, 40%);">+;    <local address> => <advertised address>,[include_local_address]</span><br><span> ;</span><br><span> ; The following will replace 192.168.1.10 with 1.2.3.4 during ICE</span><br><span> ; negotiation:</span><br><span> ;</span><br><span> ;192.168.1.10 => 1.2.3.4</span><br><span> ;</span><br><span style="color: hsl(120, 100%, 40%);">+; The following will include BOTH 192.168.1.10 and 1.2.3.4 during ICE</span><br><span style="color: hsl(120, 100%, 40%);">+; negotiation instead of replacing 192.168.1.10.  This can make it easier</span><br><span style="color: hsl(120, 100%, 40%);">+; to serve both local and remote clients.</span><br><span style="color: hsl(120, 100%, 40%);">+;</span><br><span style="color: hsl(120, 100%, 40%);">+;192.168.1.10 => 1.2.3.4,include_local_address</span><br><span style="color: hsl(120, 100%, 40%);">+;</span><br><span> ; You can define an override for more than 1 interface if you have a multihomed</span><br><span> ; server. Any local interface that is not matched will be passed through</span><br><span> ; unaltered. Both IPv4 and IPv6 addresses are supported.</span><br><span>diff --git a/doc/CHANGES-staging/rtp_ice_include_local_address.txt b/doc/CHANGES-staging/rtp_ice_include_local_address.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..e5a65e5</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/rtp_ice_include_local_address.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: RTP/ICE</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+You can now indicate that you'd like an ice_host_candidate's local address</span><br><span style="color: hsl(120, 100%, 40%);">+to be published as well as the mapped address.  See the sample rtp.conf</span><br><span style="color: hsl(120, 100%, 40%);">+for more information.</span><br><span>diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c</span><br><span>index c4df6a4..c2e2a05 100644</span><br><span>--- a/res/res_rtp_asterisk.c</span><br><span>+++ b/res/res_rtp_asterisk.c</span><br><span>@@ -252,6 +252,7 @@</span><br><span> struct ast_ice_host_candidate {</span><br><span>     pj_sockaddr local;</span><br><span>   pj_sockaddr advertised;</span><br><span style="color: hsl(120, 100%, 40%);">+       unsigned int include_local;</span><br><span>  AST_RWLIST_ENTRY(ast_ice_host_candidate) next;</span><br><span> };</span><br><span> </span><br><span>@@ -615,21 +616,26 @@</span><br><span> }</span><br><span> </span><br><span> /*! \brief Applies the ICE host candidate mapping */</span><br><span style="color: hsl(0, 100%, 40%);">-static void host_candidate_overrides_apply(unsigned int count, pj_sockaddr addrs[])</span><br><span style="color: hsl(120, 100%, 40%);">+static unsigned int host_candidate_overrides_apply(unsigned int count, unsigned int max_count, pj_sockaddr addrs[])</span><br><span> {</span><br><span>       int pos;</span><br><span>     struct ast_ice_host_candidate *candidate;</span><br><span style="color: hsl(120, 100%, 40%);">+     unsigned int added = 0;</span><br><span> </span><br><span>  AST_RWLIST_RDLOCK(&host_candidates);</span><br><span>     for (pos = 0; pos < count; pos++) {</span><br><span>               AST_LIST_TRAVERSE(&host_candidates, candidate, next) {</span><br><span>                   if (!pj_sockaddr_cmp(&candidate->local, &addrs[pos])) {</span><br><span>                           pj_sockaddr_copy_addr(&addrs[pos], &candidate->advertised);</span><br><span style="color: hsl(120, 100%, 40%);">+                                if (candidate->include_local && (count + (++added)) <= max_count) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                     pj_sockaddr_cp(&addrs[count + (added - 1)], &candidate->local);</span><br><span style="color: hsl(120, 100%, 40%);">+                            }</span><br><span>                            break;</span><br><span>                       }</span><br><span>            }</span><br><span>    }</span><br><span>    AST_RWLIST_UNLOCK(&host_candidates);</span><br><span style="color: hsl(120, 100%, 40%);">+      return added;</span><br><span> }</span><br><span> </span><br><span> /*! \brief Helper function which updates an ast_sockaddr with the candidate used for the component */</span><br><span>@@ -3303,6 +3309,7 @@</span><br><span> {</span><br><span>         pj_sockaddr address[PJ_ICE_MAX_CAND];</span><br><span>        unsigned int count = PJ_ARRAY_SIZE(address), pos = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int max_count = PJ_ARRAY_SIZE(address);</span><br><span>     int basepos = -1;</span><br><span> </span><br><span>        /* Add all the local interface IP addresses */</span><br><span>@@ -3314,7 +3321,7 @@</span><br><span>               pj_enum_ip_interface(pj_AF_INET6(), &count, address);</span><br><span>    }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   host_candidate_overrides_apply(count, address);</span><br><span style="color: hsl(120, 100%, 40%);">+       count += host_candidate_overrides_apply(count, max_count, address);</span><br><span> </span><br><span>      for (pos = 0; pos < count; pos++) {</span><br><span>               if (!rtp_address_is_ice_blacklisted(&address[pos])) {</span><br><span>@@ -8640,6 +8647,8 @@</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>             pj_str_t address;</span><br><span style="color: hsl(120, 100%, 40%);">+             unsigned int include_local_address = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+               char *sep;</span><br><span> </span><br><span>               ast_sockaddr_setnull(&local_addr);</span><br><span>               ast_sockaddr_setnull(&advertised_addr);</span><br><span>@@ -8649,6 +8658,14 @@</span><br><span>                         continue;</span><br><span>            }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+         sep = strchr(var->value,',');</span><br><span style="color: hsl(120, 100%, 40%);">+              if (sep) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    *sep = '\0';</span><br><span style="color: hsl(120, 100%, 40%);">+                  sep++;</span><br><span style="color: hsl(120, 100%, 40%);">+                        sep = ast_skip_blanks(sep);</span><br><span style="color: hsl(120, 100%, 40%);">+                   include_local_address = strcmp(sep, "include_local_address") == 0;</span><br><span style="color: hsl(120, 100%, 40%);">+          }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>          if (ast_parse_arg(var->value, PARSE_ADDR | PARSE_PORT_IGNORE, &advertised_addr)) {</span><br><span>                    ast_log(LOG_WARNING, "Invalid advertised ICE host address: %s\n", var->value);</span><br><span>                  continue;</span><br><span>@@ -8659,6 +8676,8 @@</span><br><span>                    break;</span><br><span>               }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+         candidate->include_local = include_local_address;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>               pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&address, ast_sockaddr_stringify(&local_addr)), &candidate->local);</span><br><span>              pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&address, ast_sockaddr_stringify(&advertised_addr)), &candidate->advertised);</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11390">change 11390</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/+/11390"/><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: Ide492cd45ce84546175ca7d557de80d9770513db </div>
<div style="display:none"> Gerrit-Change-Number: 11390 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </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@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>