<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://reviewboard.asterisk.org/r/3601/">https://reviewboard.asterisk.org/r/3601/</a>
     </td>
    </tr>
   </table>
   <br />










<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On June 10th, 2014, 5:13 p.m. CDT, <b>Scott Griepentrog</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  



<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/3601/diff/1/?file=59438#file59438line602" style="color: black; font-weight: bold; text-decoration: underline;">/branches/12/main/bridge_channel.c</a>
    <span style="font-weight: normal;">

     (Diff revision 1)

    </span>
   </th>
  </tr>
 </thead>



 
 

 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">573</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="kt">void</span> <span class="nf">ast_bridge_channel_update_accountcodes</span><span class="p">(</span><span class="k">struct</span> <span class="n">ast_bridge_channel</span> <span class="o">*</span><span class="n">joining</span><span class="p">,</span> <span class="k">struct</span> <span class="n">ast_bridge_channel</span> <span class="o">*</span><span class="n">leaving</span><span class="p">)</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">574</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="p">{</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">575</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="k">if</span> <span class="p">(</span><span class="n">joining</span><span class="p">)</span> <span class="p">{</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">576</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="tb">  </span><span class="n">bridge_channel_update_accountcodes_joining</span><span class="p">(</span><span class="n">joining</span><span class="p">,</span> <span class="n">leaving</span><span class="p">);</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">577</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">578</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="tb">  </span><span class="n">bridge_channel_update_accountcodes_leaving</span><span class="p">(</span><span class="n">leaving</span><span class="p">);</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">579</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="p">}</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">580</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="p">}</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">581</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
  </tr>

 </tbody>

</table>

  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I'm not understanding the need for this to be split out with separate join/leave handling.  It seems like an un-necessary complication.  Would it not work to use a method similar to the linkedid propagation and copy account codes from earliest channel, just never overwriting an existing code?</pre>
 </blockquote>





</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The processing is different because of the different conditions.  Joining channels have not been added to the bridge channel list yet and the optional leaving channel is being swapped with the joining channel.  The leaving case is needed when a bridge goes from a 3-party bridge to a 2-party bridge and the bridge may be marked as destroyed.  The leaving case was not handled before this patch so the peeraccount codes could be mismatched with the peer channel.

Accountcodes to not propagate like linkedids where the oldest linkedid gets set on all channels in the bridge.  The accountcode/peeraccount are more like caller-id/connected-line respectively.  When a channel is replaced with another channel, the peeraccount codes need to be updated so they match what's accross the bridge.

I could have replaced the ast_bridge_channel_update_accountcodes with a joining and leaving version.  However, that would change the API unnecessarily.</pre>
<br />




<p>- rmudgett</p>


<br />
<p>On June 6th, 2014, 11 p.m. CDT, rmudgett wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Asterisk Developers.</div>
<div>By rmudgett.</div>


<p style="color: grey;"><i>Updated June 6, 2014, 11 p.m.</i></p>







<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="https://issues.asterisk.org/jira/browse/AFS-65">AFS-65</a>, 

 <a href="https://issues.asterisk.org/jira/browse/ASTERISK-17954">ASTERISK-17954</a>


</div>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Accountcode propagation:

The current behavior is to simply set the accountcode of an outgoing
channel to the accountcode of the channel initiating the call.  It was
done this way a long time ago to allow the accountcode set on the SIP/100
channel to be propagated to a local channel so the dialplan execution on
the Local;2 channel would have the SIP/100 accountcode available.

SIP/100 -> Local;1/Local;2 -> SIP/200

Propagating the SIP/100 accountcode to the local channels is very useful.
However, a side effect of this is it will overwrite any accountcode set by
the SIP channel driver configuration for the SIP/200 channel with the
accountcode from the Local;2 channel.  Without any dialplan manipulation,
all channels in this call would have the same accountcode.  I believe this
is the basis for the ASTERISK-17954 issue.

Using dialplan, you can set a different accountcode on the SIP/200 channel
either by setting the accountcode on the Local;2 channel or by the Dial
application's b(pre-dial), M(macro) or U(gosub) options, or by the
FollowMe application's b(pre-dial) option, or by the Queue application's
macro or gosub options.

This patch changes the behavior slightly.  The outgoing channel gets the
accountcode of the initiating channel _only_ if the outgoing channel
doesn't already have an accountcode set.

The most visible effect the change would have is if the channel driver
automatically set the accountcode on channel creation.  In the example
above if SIP/100 and SIP/200 are created with their own accountcode from
the SIP channel driver configuration, the SIP/200 accountcode would not
get overwritten by the SIP/100 accountcode and you would not need to use
dialplan to set it back.  Of course the converse is that dialplan would
need to be used to propagate the SIP/100 accountcode to SIP/200.

* Changed the accountcode propagation from simply setting the accountcode
of the channel initiating the call onto the outgoing channel to setting
the accountcode only if the outgoing channel doesn't already have one.
In other words, if a channel already has an accountcode it will not be
changed unless explicitly set by CHANNEL(accountcode) or an originate
method that can specify an accountcode.  The most visible effect the
change has is if the channel driver is configured with an accountcode
for new channels.

* Moved most accountcode propagation behavior into ast_request() which
eliminates several inconsistencies throughout the code.  (app_dial,
app_followme, app_queue, and the dialing API)

* Fixed the basic bridge sub-class updating peeraccount codes when the
number of channels in the bridge drops back down to two parties.

* Refactored ast_bridge_channel_update_accountcodes() to handle channels
joining/leaving the bridge.

* Fixed the basic bridge to not call the base pull method twice.

* Fixed CEL extracting the wrong ie value for the peeraccount.

* Fixed some incorrect CEL event ie types.  These seem to only be used
by the unit tests.
</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Set the accountcode on the initial channel and let the channel driver supply or not the accountcode for the other channel.
Without the channel driver supplying the accountcode, the outgoing channel got the same accountcode as the initial channel.
With the channel driver supplying the accountcode, the outgoing channel kept its accountcode.

Let the channel driver supply the accountcode for all endpoint channel.
Performed a DTMF attended transfer with consultation and creation of a three party bridge.
When the transferrer channel left the three party bridge, the remaining two channels got the peeraccount updated to the other party.

Throughout each of these tests, the CEL log had the expected peeraccount value.  Note the peeraccount value is meaningless if the bridge contains more than two parties.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>/branches/12/main/pbx.c <span style="color: grey">(415428)</span></li>

 <li>/branches/12/main/event.c <span style="color: grey">(415428)</span></li>

 <li>/branches/12/main/dial.c <span style="color: grey">(415428)</span></li>

 <li>/branches/12/main/channel.c <span style="color: grey">(415428)</span></li>

 <li>/branches/12/main/cel.c <span style="color: grey">(415428)</span></li>

 <li>/branches/12/main/bridge_channel.c <span style="color: grey">(415428)</span></li>

 <li>/branches/12/main/bridge_basic.c <span style="color: grey">(415428)</span></li>

 <li>/branches/12/include/asterisk/bridge_channel.h <span style="color: grey">(415428)</span></li>

 <li>/branches/12/apps/app_queue.c <span style="color: grey">(415428)</span></li>

 <li>/branches/12/apps/app_followme.c <span style="color: grey">(415428)</span></li>

 <li>/branches/12/apps/app_dial.c <span style="color: grey">(415428)</span></li>

 <li>/branches/12/UPGRADE.txt <span style="color: grey">(415428)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/3601/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>








  </div>
 </body>
</html>