Hi, <br><br>sorry if I haven&#39;t been clear in the last mail(s). I&#39;ll try to recap. <br><br>I have a call with 3 branches that are serially forked. branch 1 and 2 can be PSTN number or SIP URI. branch 3 is voicemail. I do not want to account 1st branch if call is missed, only the 2nd one. <br>
<br>Here are the snippets from the configuration file that I&#39;m using since I&#39;ve started this thread. I&#39;ve bolded parts where acc related flags are set.<br><br>route { ....<br>        route(WITHINDLG);   ....<br>
 <br>        if ( is_method(&quot;INVITE&quot;) ) { ...<br>                <b>setflag(FLT_ACC);   # [1]</b><br>                #check for user defined forking priorities and timers<br>
                route(FORK);<br>        }<br>        route(LOCATION);<br>        route(RELAY);<br>}<br><br>#check for user defined forking priorities and timers<br>route[FORK]{  ...<br>
                # user has multiple contacts, do serial forking<br>
                setflag(FLT_USRPREF);  ....<br>                # overwrite request URI with highest priority contact<br>
                if ($avp(prio1) =~ &quot;^sip:00&quot;) $ru = $avp(prio1) + &quot;@host&quot;;<br>                else $ru = $avp(prio1);  ....<br>
}<br><br>route[RELAY] {<br>        if (is_method(&quot;INVITE&quot;)) {<br>                t_on_reply(&quot;REPLY_ONE&quot;);<br>
                t_on_failure(&quot;FAIL_ONE&quot;);<br><br>                #if users have priorities set, use FAIL_FORK failure route<br>                if ( isflagset(FLT_USRPREF) ) t_on_failure(&quot;FAIL_FORK&quot;);<br>
        }<br>
        if (!t_relay()) sl_reply_error();<br>        exit;<br>}<br><br># Handle requests within SIP dialogs<br>route[WITHINDLG] {<br>        if (has_totag()) {<br>                if (loose_route()) {<br>                        if (is_method(&quot;BYE&quot;)) {<br>
                                <b>setflag(FLT_ACC);</b> <b># [2]</b><br>                                <b>setflag(FLT_ACCFAILED);</b> <b># [3]</b><br>
                        }<br>                        route(RELAY);<br>                }  ....} }<br><br># USER location service<br>route[LOCATION] {<br>        if ($ru =~ &quot;^sip:00&quot;) xlog(&quot;L_INFO&quot;,&quot;SKIP lookup...&quot;);<br>
        else {<br>                if (!lookup(&quot;location&quot;)) {<br>                        switch ($rc) {<br>                                case -1:<br>                                case -3:<br>                                        t_newtran();<br>

                                        t_reply(&quot;404&quot;, &quot;Not Found&quot;);<br>                                        exit;<br>                                case -2:<br>                                        sl_send_reply(&quot;405&quot;, &quot;Method Not Allowed&quot;);<br>

                                        exit;<br>                        }<br>                }<br>        }<br>        # when routing via usrloc, log the missed calls also, but only if user doesn&#39;t have prios set<br>

        if ( is_method(&quot;INVITE&quot;) &amp;&amp; !(isflagset(FLT_USRPREF))) {<br>                <b>setflag(FLT_ACCMISSED);</b> <b># [4] - not used in serial forking scenario<br></b>        }<br>}<br><br># Failure route for forked calls<br>
failure_route[FAIL_FORK] { ...<br>                # handle 2nd branch<br>                if ( ($avp(prio) == 2) &amp;&amp; ( isflagset(FLT_USRPREF) )) {<br>                        t_on_failure(&quot;FAIL_FORK&quot;);<br>
<br>                        if ($avp(prio2) =~ &quot;^sip:00&quot;) $ru = $avp(prio2) + &quot;@host&quot;; # tel number<br>                        else {<br>                                $ru = $avp(prio2); # sip uri<br>
                                route(LOCATION);<br>
                        }<br>                        <b>setflag(FLT_ACCMISSED); # [5]</b><br>                }<br>                # 3rd branch is voicemail<br>                else {<br>                        $ru = $(avp(uuid));<br>

                        rewritehostport(&quot;host:port&quot;);<br>                        append_hf(&quot;P-App-Name: voicemail\r\n&quot;);<br>
                        append_hf(&quot;P-App-Param: Email-Address=$avp(email)\r\n&quot;);<br>                }<br>                route(RELAY);<br><br>        if (t_is_canceled()) {<br>                exit;<br>
        }<br>}
<br><br>With code above I&#39;m testing following scenarios, where <a href="mailto:oz@abc.hr">oz@abc.hr</a> calls <a href="mailto:pero@abc.hr">pero@abc.hr</a>. Due to <a href="mailto:pero@abc.hr">pero@abc.hr</a> settings and priorities set, 1st branch is PSTN number, 2nd branch is <a href="mailto:sip%3Apero@abc.hr">sip:pero@abc.hr</a> and 3rd branch is voicemail:<br>
1. pero doesn&#39;t answer 1st branch and 2nd branch, voicemail activates. There are no logs in missed_calls. I want to have a single log in missed_calls for this case.<br>2. pero doesn&#39;t answer 1st branch, declines call at 2nd branch (486 Busy), voicemail activates. There are no logs in missed_calls. I want to have a single log in missed_calls for this case.<br>
3. pero doesn&#39;t answer 1st branch, 2nd branch rings, oz cancels call, voicemail doesn&#39;t activate. There is a single log in missed_calls (487). This is ok, as expected.<br>4. 1st branch rings, oz cancels call. There is a single log in missed_calls (487). This is also ok.<br>
Logs in acc table exist and are good for all 4 cases - all of them are related to established call to voicemail server. <br><br>Previously, I&#39;ve tested several variations of config file above:<br><br>Variation 1: remove [1], [2] and [3]. (look for bolded lines above). In this variation, only [5] is related to acc flags and is set in failure route. When testing 4 scenarios above, there are no logs in acc and acc_missed table. This is probably related to your comment that acc does not register 
itself for a tm callback that is used for handling accounting events if there are no flags defined in request route block.<br><br>Variation 2: [1], [2], [3] are used again, but 3rd branch is removed, there is no voicemail. Lets go through 4 scenarios again:<br>
1. pero doesn&#39;t answer 1st branch and 2nd branch.  There is a single log in missed_calls (408) - OK.<br>2. pero doesn&#39;t answer 1st branch, declines call at 2nd branch (486 Busy). There is a single log in missed_calls (486) - OK.<br>
3. pero doesn&#39;t answer 1st branch, 2nd branch rings, oz cancels call. There is a single log in missed_calls (487) - OK.<br>4. 1st branch rings, oz cancels call. There is a single log in missed_calls (487) - OK.<br>There are no logs in acc table. This is OK because no calls have been established. Everything works as expected here! However, I need the voicemail, I can&#39;t replace it for accounting.<br>
<br>Variation 3: [1],  [2], [3] are used, as well as voicemail. [5] is removed from failure route. Instead, in failure route setflag(FL_2NDBRANCH) is set when 2nd branch is processed. In RELAY route following line is added: if ( isflagset(FL_2NDBRANCH) ) setflag(FLT_ACCMISSED). Results are the same as for original configuration. <br>
<br><br><br><div class="gmail_quote">On Mon, Sep 26, 2011 at 12:06 PM, Daniel-Constantin Mierla <span dir="ltr">&lt;<a href="mailto:miconda@gmail.com">miconda@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hello,<div class="im"><br>
    <br>
    On 9/26/11 11:44 AM, Ozren Lapcevic wrote:
    <blockquote type="cite"><br>
      <div class="gmail_quote">On Sat, Sep 24, 2011 at 9:11 AM,
        Daniel-Constantin Mierla <span dir="ltr">&lt;<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div bgcolor="#FFFFFF" text="#000000"> Hello,<br>
            <br>
            just to refresh in case you mentioned already, do you set
            acc missed call flag in request route block?<br>
          </div>
        </blockquote>
        <div><br>
          <br>
          No. I&#39;m setting setflag(FLT_ACCMISSED) in failure route for
          serially forked calls. <br>
        </div>
      </div>
    </blockquote></div>
    ok, so that caused not to register to TM for a callback on failure
    events when the transaction for respective INVITE was created.<div class="im"><br>
    <blockquote type="cite">
      <div class="gmail_quote">
        <div><br>
          (Also, I&#39;m setting setflag(FLT_ACC); in main route for
          INVITES. I&#39;m setting setflag(FLT_ACC) and
          setflag(FLT_ACCFAILED) in WITHINDLG route for loose routed
          BYEs.)<br>
        </div>
      </div>
    </blockquote></div>
    This is different that what we looked after.<div class="im"><br>
    <blockquote type="cite">
      <div class="gmail_quote">
        <div>
          <br>
          Previously, before starting this thread, and before any of
          your patches, I&#39;ve tried setting FLT_ACCMISSED in LOCATION
          route and in RELAY route, but didn&#39;t help with properly
          accounting only the 2nd branch. <br>
        </div>
      </div>
    </blockquote>
    <br></div>
    Because it caused the first branch also to be recorded to missed
    calls.</div></blockquote><div><br>By that, I meant Variation 3. <br><br><br></div><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">
<div class="im">
      
        <br><blockquote type="cite"><div class="gmail_quote">
        <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"> I found another issue
            that if this flag is no set in request route, the callback
            to tm that is used for accounting missed calls is not
            registered. Can you try with 3.2.0 (git master branch at
            this moment) and set the acc_prepare_flag parameter, plus
            the flag itself for invites?<br>
          </div>
        </blockquote>
        <div><br>
          <br>
          I&#39;ve installed new Kamailio with instructions from: <a href="http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git" target="_blank">http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git</a>.
          However, default kamailio config file and kamctl file both
          show 3.1 version. How can I check whether I have 3.2 version
          installed?<br>
        </div>
      </div>
    </blockquote></div>
    Do:<br>
    <br>
    /usr/local/sbin/kamailio -V<br>
    <br>
    The config file kamailio.cfg is not overwritten if already exists,
    to prevent mistakenly loss (no backup).<br></div></blockquote><div> </div><div><br>Ok, I have good version installed. I&#39;ll test it and report results. <br><br><br>Cheers<br>Ozren<br><br><br></div><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">
    <div class="im"><blockquote type="cite">
      <div class="gmail_quote">
        <div>
          <br>
          acc_prepare_flag should be set in main route, e.g. in the same
          place as FLT_ACC for INVITES?<br>
        </div>
      </div>
    </blockquote></div>
    Yes, it has to be set in request route {...} block.<br>
    <br>
    Cheers,<br><font color="#888888">
    Daniel</font><div class="im"><br>
    <br>
    <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
Kamailio Advanced Training, Oct 10-13, Berlin: <a href="http://asipto.com/u/kat" target="_blank">http://asipto.com/u/kat</a>
<a href="http://linkedin.com/in/miconda" target="_blank">http://linkedin.com/in/miconda</a> -- <a href="http://twitter.com/miconda" target="_blank">http://twitter.com/miconda</a></pre>
  </div></div>

</blockquote></div><br>