<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div>Hi Zaka<div>You have misunderstood this line : <span style="color: rgb(255, 0, 0); font-family: Tahoma; font-size: 10pt;">if (!t_relay()) {</span></div><div><br></div><div>That line explicitly calls t_relay() and the packet is relayed at that time.  If the packet cannot be relayed then the t_relay() function returns an error and the conditional block is executed.</div><div><br></div><div>Paul Smith<br><div apple-content-edited="true"><div><br></div><br class="Apple-interchange-newline">
</div>
<br><div><div>On 13 Nov 2014, at 09:10, Zaka Ul Isam <<a href="mailto:Zaka.Ul@albtelecom.al">Zaka.Ul@albtelecom.al</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div ocsi="0" fpstyle="1" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="direction: ltr; font-family: Tahoma; font-size: 10pt;">Morning Paul:<br><br>Thanks a million, mate!<br>So, if I understood correctly, in the:<span class="Apple-converted-space"> </span><br><font color="FF0000"><br>if (!t_relay()) {<br>sl_reply_error();</font><br><br>!t_relay will check the error condition in sending out the stateful message.  However, in this code snippet, t_relay is not explicitly called. Therefore, as in kamailio-advanced-config, route[relay] should be performing this.<span class="Apple-converted-space"> </span><br><br>But it is not the case. Instead the main routing block first calls several other routes:<br><br>route(REQINIT);<br>route(NATDETECT);<br><br>and then # CANCEL processing<br>    if (is_method("CANCEL")) {<br>       <span class="Apple-converted-space"> </span><font color="FF0000">if (t_check_trans())   ????????<br>            t_relay();<br>        exit;</font><br><br>Please forgive my ignorance, but I am baffled here.<br><br>The next occurrence of t_relay is:<br><br>if ( is_method("ACK") ) {<br>      <b><font color="FF0000"> </font></b><font color="FF0000"><span class="Apple-converted-space"> </span>if ( t_check_trans() ) {</font><br>            # no loose-route, but stateful ACK;<br>            # must be an ACK after a 487<br>            # or e.g. 404 from upstream server<br>           <font color="FF0000"><span class="Apple-converted-space"> </span>t_relay();</font><br>            exit;<br><br><br>Many anticipatory thanks again!<br><br>Have an awesome day!<br><br>Zaka<br><br>________________________________________<br>From: <a href="mailto:sr-users-bounces@lists.sip-router.org">sr-users-bounces@lists.sip-router.org</a> [<a href="mailto:sr-users-bounces@lists.sip-router.org">sr-users-bounces@lists.sip-router.org</a>] on behalf of Paul Smith [<a href="mailto:paul.smith@claritytele.com">paul.smith@claritytele.com</a>]<br>Sent: Thursday, November 13, 2014 9:38 AM<br>To: <a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>Subject: Re: [SR-Users] Kamailio Routing Logic<br><br>Hi Zaka,<br>The stageful forwarding takes place in the t_relay() function. If relaying is unsuccessful then an error is returned and the conditional block executed to send an error back to the originator using sl_reply_error().<br><br>Your other question is about why to use the call to route(1): Yes you could just put the content of route[1] into the main route block and it would work fine. In more complex scripts it is neater to put code which is executed in lots of different place into a separate block and then call the block. That way if you need to modify that code you only have one place to maintain. The t_relay() function is a good example of a block of functionality that is reached from loads of places … so generally a route[relay] block is a good idea.<br><br>Paul Smith<br><br>On 13 Nov 2014, at 07:52, Zaka Ul Isam <<a href="mailto:Zaka.Ul@albtelecom.al">Zaka.Ul@albtelecom.al</a>> wrote:<br><br>> Hello Friends and Gurus:<br>><br>> I am struggling with routing and need a bit of clarification WRT following:<br>><br>> route {<br>> if ($fU=="601"&&is_method("INVITE"))<br>> record_route();<br>> rewritehost("10.0.10.111"); //SS IP<br>> route(1);<br>> }<br>> route[1] {<br>> # send it out now; use stateful forwarding as it works reliably<br>> # even for UDP2TCP<br>> if (!t_relay()) {<br>> sl_reply_error();<br>> };<br>> exit;<br>> }<br>> * In the above stateful forwarding what is the rationale of calling route (1) within main route block? Could the t_relay statement afyer rewriting the host part of URI not have performed the stateful forwarding?<br>><br>> ** In route[1] there is is only an expression abt logical not condition about t_relay() (if methods in this function are not invoked??)<br>> I wonder where exactly is stateful forwarding taking place?<br>><br>> 1- Is it the default action?<br>> 2- Or in function sl_reply_error()?<br>><br>> Thanks a lot in advance!<br>><br>> Zaka<br>><br>> ________________________________<br>><br>> Albtelecom & Eagle Mobile invite you to protect together the Environment. Please do not print the e-mail unless really necessary.<br>><br>> Albtelecom & Eagle Mobile iu ftojnė tė mbrojmė sė bashku Mjedisin. Lutemi tė mos e printoni kėtė komunikim elektronik nėse nuk ėshtė vėrtet i nevojshėm.<br>><br>> ________________________________<br>><br>> This e-mail and any files transmitted with it are confidential and intended solely for the use of the addressee/s. If you are not the intended recipient you are hereby notified that any dissemination, forwarding, copying or use of any of the information is strictly prohibited. If you receive this e-mail in error, please notify the sender immediately and delete it! Albtelecom makes no warranty as to the accuracy or completeness of any information contained in this message and hereby excludes any liability of any kind for the information contained therein or for the information transmission, reception, storage or use of such in any way whatsoever. The opinions expressed in this message may belong to sender alone and may not necessarily reflect the opinions of Albtelecom. Albtelecom shall bear no liability for any loss or damage caused by software or e-mail viruses.<br>><br>> Ky mesazh dhe ēdo informacion i transmetuar nė pėrmbajtje te kėtij mesazhi ėshtė konfidencial dhe ėshtė i destinuar vetėm pėr marrėsin e destinuar. Nėse nuk jeni marrėsi i destinuar, Ju bėjmė me dije se ēdo pėrhapje, transmetim, kopjim apo pėrdorim i ēdo informacioni ėshtė i ndaluar. Nėse e merrni kėtė mesazh gabimisht, ju lutem kontaktoni urgjentisht nisėsin e tij dhe fshijeni atė. Albtelecom nuk jep asnjė garanci pėr saktėsinė apo plotėsinė e informacionit nė pėrmbajtje tė kėtij mesazhi dhe nuk mban asnjė pėrgjegjėsi pėr informacionin e pėrmbajtur, transmetimin, marrjen, ruajtjen apo pėrdorimin e tij nė ēfarėdolloj mėnyre. Mendimet e shprehura nė kėtė mesazh mund t'i pėrkasin vetė nisėsit dhe nuk mund tė reflektojnė domosdoshmėrisht qėndrimet e Albtelecom. Albtelecom nuk do tė mbaje asnjė pėrgjegjėsi pėr humbje ose dėme te shkaktuara nga programet apo viruset.<br>> _______________________________________________<br>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>> <a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>> <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br><br><br>_______________________________________________<br>SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br><a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br><a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br></div>_______________________________________________<br>SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br><a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br><a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a></div></blockquote></div><br></div></body></html>