<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    <tt>Hi Samuel,<br>
      <br>
      You should do like:<br>
      <br>
    </tt>    $var(i) = 0;<br>
        while ($var(i) &lt; $(avp(callee_fork){param.count})) {<br>
                $avp(callee_uri) =
    $(avp(callee_fork){param.valueat,$var(i)});<br>
                if ($var(i)!=0)<br>
                          append_branch();<br>
                $ru = $avp(callee_uri);<br>
                $avp(callee_username) = $rU;<br>
                $avp(callee_realm) = $rd;<br>
                setbflag(27);<br>
                lookup("location","mb");<br>
                setflag(9);<br>
                $var(i) = $var(i) + 1;<br>
        }<br>
    <tt><br>
      the idea is, before overwritting the RURI, push the existing
      content as a new branch - at the first step you do not have to do
      it as originally (before the loop) the RURI content is not to be
      kept.<br>
      <br>
      Regards,<br>
    </tt>
    <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
    <br>
    On 12/07/2012 01:53 PM, Samuel Muller wrote:
    <blockquote
cite="mid:CAEhWu_YqMN6OzY1PBt=wjvWGEdJL_7ngfRWk-=a-0FHCnhMQ2w@mail.gmail.com"
      type="cite">Thanks Bogdan for your answer.<br>
      <br>
      I tried several things since, I understood that :<br>
          $branch = $ru;<br>
          append_branch();<br>
      makes 2 branches, so everything is duplicated.<br clear="all">
      <div><br>
        I removed $branch = $ru; it's better now, but I had again 1
        duplicated branch : the 0 and the last one in the loop.<br>
        <br>
        This worked for me :<br>
        $var(j) = $(avp(callee_fork){param.count}) - 1;<br>
        if ($var(i) &lt; $var(j)) {<br>
            append_branch();<br>
        }<br>
        <br>
        then, what I did mistake, is that I've to do manipulations into
        my loop and set up branch flags accordingly.<br>
        so, I've now a huge loop process :(<br>
        <br>
        There are 2 little things I don't understand yet :<br>
        <br>
        1/ in the branch route where I send the result of the loop :<br>
        branch_route[1] {<br>
            xlog("L_NOTICE","br1: engage branch $T_branch_idx to $ru");<br>
            ...<br>
        }<br>
        <br>
        I got this ERROR line for each branch :<br>
        opensips[15295]: ERROR:tm:pv_get_tm_ruri: BUG: _tm_branch_index
        greater than nr_of_outgoings<br>
        <br>
        2/ accounting<br>
        <br>
        I've really something clean for the INVITE using Sip-Leg-Dst /
        Sip-Leg-Src, each R-URI branch is correctly added.<br>
        but ... nothing in the BYE or CANCEL (independently of the
        direction of the request).<br>
        I can not know which branch answered, and nothing in the
        accounting logs that indicates which one I've to account - I've
        only the first request URI of the INVITE, and no information
        about the callee behind the hunting group that I've to use.<br>
        <br>
        How can I get that ?<br>
        <br>
        Thank you,<br>
        <br>
        <br>
        <b>.Sam.</b><br>
      </div>
      <br>
      <br>
      <br>
      <div class="gmail_quote">On Thu, Dec 6, 2012 at 6:40 PM,
        Bogdan-Andrei Iancu <span dir="ltr">&lt;<a
            moz-do-not-send="true" href="mailto:bogdan@opensips.org"
            target="_blank">bogdan@opensips.org</a>&gt;</span> wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          <div bgcolor="#ffffff" text="#000000"> <tt>Hi Samuel,<br>
              <br>
              It is not clear from your script snapshots where you are
              supposed to set the bflags 11 and 28.<br>
              <br>
              The idea is that you create all the additional branches
              (as normally you have the RURI - mandatory - plus some
              optional additional branches) in that "while" loop. In the
              request route you are doing changes only over the RURI
              (and not over the additional branches). Accessing the
              already created branches can be done via the $branch[]
              variables only.<br>
              <br>
              Regards,<br>
            </tt>
            <pre cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a moz-do-not-send="true" href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre>
            <div>
              <div class="h5"> <br>
                On 12/05/2012 06:08 PM, Samuel Muller wrote: </div>
            </div>
            <blockquote type="cite">
              <div>
                <div class="h5">Hello,<br>
                  <br>
                  I'm looking for explanations about parallel forking
                  and branch flags.<br>
                  I'm deeply annoyed by this feature ...<br>
                  <br>
                  I need to set up different parameters (like rtpproxy,
                  from display, accounting, ...) per contact.<br>
                  <br>
                  actually, I retrieve a list of contact using an AVP,
                  in the format that the core function "while" can use.<br>
                  <br>
                  It's working fine when there are no manipulation or no
                  (new) callee parameters to add :<br>
                  <br>
                  route[FORK] {<br>
                      xlog("L_NOTICE","parallel fork requested");<br>
                      $var(i) = 0;<br>
                      while ($var(i) &lt;
                  $(avp(callee_fork){param.count})) {<br>
                              $avp(callee_uri) =
                  $(avp(callee_fork){param.valueat,$var(i)});<br>
                              $ru = $avp(callee_uri);<br>
                              $avp(callee_username) = $rU;<br>
                              $avp(callee_realm) = $rd;<br>
                              setbflag(27);<br>
                              lookup("location","mb");<br>
                              setflag(9);<br>
                              $branch = $ru;<br>
                              append_branch();<br>
                              $var(i) = $var(i) + 1;<br>
                      }<br>
                      route(RTPPROXY);   # rtp proxy set = bflag 11<br>
                      route(ACCOUNTING); # accounting using $rU. $ru,
                  ...<br>
                      route(RELAY);<br>
                      exit;<br>
                  }<br>
                  route[RELAY] {<br>
                      t_on_branch("1");<br>
                      t_on_reply("1");<br>
                      t_on_failure("1");<br>
                      t_relay("0x01");<br>
                      exit;<br>
                  }<br>
                  <br>
                  At this point, I'm totally lost :<br>
                  I have to check if a callee need to use rtpproxy, set
                  up the accounting, change the "from" display based on
                  the destination (PSTN vs. local subscriber), and so
                  on.<br>
                  Everything failed, the parameters are always global
                  (based on the branch("0")) even if I use branch flag,
                  script flag, or do anything into the branch route.<br>
                  <br>
                  branch_route[1] {<br>
                      xlog("L_NOTICE","br1: engage branch $T_branch_idx
                  with R-URI: $T_ruri ($ru)");<br>
                      xlog("L_NOTICE","br1: dest set: $ds / dest uri:
                  $du");<br>
                      if (isbflagset(11)) {<br>
                          xlog("L_NOTICE","br1: rtp proxy set to
                  \"cr\"");<br>
                          engage_rtp_proxy("cr");<br>
                      }<br>
                      if (isbflagset(28)) {<br>
                              uac_replace_from("$avp(caller_cli)","");<br>
                          }<br>
                      }<br>
                  }<br>
                  <br>
                  did I missed something ???<br>
                  <br>
                  Thanks to light my fire, I really need it ...<br>
                  <br>
                  .Sam.<br>
                  <br>
                </div>
              </div>
              <pre><fieldset></fieldset>
_______________________________________________
Users mailing list
<a moz-do-not-send="true" href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a moz-do-not-send="true" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
            </blockquote>
          </div>
        </blockquote>
      </div>
      <br>
    </blockquote>
  </body>
</html>