<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    iirc (because the discussion was back in 2002-2003), 200ok has to be
    always forwarded by a proxy -- the rfc needs to be consulted for
    proper answer.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <div class="moz-cite-prefix">On 26/05/14 13:36, Jason Penton wrote:<br>
    </div>
    <blockquote
cite="mid:CALoGXNWP=5eN_SeBfWJOaKPpLAb_s0eyM=2xNrN3-DeZpgC4Ew@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi,
        <div><br>
        </div>
        <div>I am confused by the TM reply processing logic in a
          particular scenario. For example, if an INVITE transaction has
          had a final reply (let's assume 500 Error in this case). Now,
          if a 200 OK comes through the proxy to accept the call then
          according to the code below, the relay will be relayed to the
          calling party.... why? This will also cause the tm transaction
          state to change from state 5 (deleted) to state (4)
          confirmed.... Is this correct? (a result of this scenario is
          that the A UAC will receive a 500 followed by a 200....)</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>
          <div>static enum rps t_should_relay_response( struct cell
            *Trans , int new_code,</div>
          <div><span class="" style="white-space:pre"> </span>int
            branch , int *should_store, int *should_relay,</div>
          <div><span class="" style="white-space:pre"> </span>struct
            cancel_info *cancel_data, struct sip_msg *reply )</div>
          <div>{</div>
          <div><span class="" style="white-space:pre"> </span>int
            branch_cnt;</div>
          <div><span class="" style="white-space:pre"> </span>int
            picked_code;</div>
          <div><span class="" style="white-space:pre"> </span>int
            new_branch;</div>
          <div><span class="" style="white-space:pre"> </span>int
            inv_through;</div>
          <div><span class="" style="white-space:pre"> </span>int
            extra_flags;</div>
          <div><span class="" style="white-space:pre"> </span>int i;</div>
          <div><span class="" style="white-space:pre"> </span>int
            replies_dropped;</div>
          <div><br>
          </div>
          <div><span class="" style="white-space:pre"> </span>/* note:
            this code never lets replies to CANCEL go through;</div>
          <div><span class="" style="white-space:pre"> </span>   we
            generate always a local 200 for CANCEL; 200s are</div>
          <div><span class="" style="white-space:pre"> </span>   not
            relayed because it's not an INVITE transaction;</div>
          <div><span class="" style="white-space:pre"> </span>   >=
            300 are not relayed because 200 was already sent</div>
          <div><span class="" style="white-space:pre"> </span>   out</div>
          <div><span class="" style="white-space:pre"> </span>*/</div>
          <div><span class="" style="white-space:pre"> </span>DBG("->>>>>>>>>
            T_code=%d, new_code=%d\n",Trans->uas.status,new_code);</div>
          <div><span class="" style="white-space:pre"> </span><font
              style="background-color:rgb(255,0,0)" color="#000000">inv_through=new_code>=200
              && new_code<300 && is_invite(Trans);</font></div>
          <div><span class="" style="white-space:pre"> </span><span
              style="background-color:rgb(255,0,0)">/* if final response
              sent out, allow only INVITE 2xx  */</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>if (
              Trans->uas.status >= 200 ) {</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>if
              (inv_through) {</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>DBG("DBG:
              t_should_relay_response: 200 INV after final sent\n");</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>*should_store=0;</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>Trans->uac[branch].last_received=new_code;</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>*should_relay=branch;</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>return
              RPS_PUSHED_AFTER_COMPLETION;</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>}</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>/* except the
              exception above, too late  messages will</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>   be
              discarded */</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>goto discard;</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>}</span></div>
          <div><span style="background-color:rgb(255,0,0)"><br>
            </span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>/* if final
              response received at this branch, allow only INVITE 2xx */</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>if
              (Trans->uac[branch].last_received>=200</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>&&
              !(inv_through &&
              Trans->uac[branch].last_received<300)) {</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>/* don't
              report on retransmissions */</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>if
              (Trans->uac[branch].last_received==new_code) {</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>DBG("DEBUG:
              final reply retransmission\n");</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>goto discard;</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>}</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>/* if you
              FR-timed-out, faked a local 408  and 487 came or</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span> *  faked a
              CANCEL on a non-replied branch don't</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span> * report on
              it either */</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>if
              ((Trans->uac[branch].last_received==487) || </span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>(Trans->uac[branch].last_received==408
              && new_code==487)) {</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>DBG("DEBUG: %d
              came for a %d branch (ignored)\n",</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>new_code,
              Trans->uac[branch].last_received);</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>goto discard;</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>}</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>/* this looks
              however how a very strange status rewrite attempt;</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span> * report on
              it */</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>LOG(L_ERR,
              "ERROR: t_should_relay_response: status rewrite by UAS: "</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>"stored: %d,
              received: %d\n",</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>Trans->uac[branch].last_received,
              new_code );</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>goto discard;</span></div>
          <div><span style="background-color:rgb(255,0,0)"><span
                class="" style="white-space:pre"> </span>}</span></div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div><span class="" style="white-space:pre"> </span>/* no
            final response sent yet */</div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
sr-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a></pre>
  </body>
</html>