Hi, <br><br>Thanks. That was useful. But it is more like calling myself and hence making a loop. <br><br>I was thinking of how Asterisk detects a loop where more than one participants are involved. Also whether for detection of the loop, Asterisk will require to store and receive information from the calling person that all these numbers have been call forwarded to since that will be needed to find out whether or not you are call forwarding to the same person.
<br><br>Thanks<br><br>Regards<br><br>Arpit<br><br><div><span class="gmail_quote">On 4/1/07, <b class="gmail_sendername">Leif Madsen</b> &lt;<a href="mailto:leif.madsen@asteriskdocs.org">leif.madsen@asteriskdocs.org</a>&gt; wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Sunday 01 April 2007 03:34:53 Arpit Mehta wrote:<br>&gt; I just want to know if Asterisk handles a looping case and where does it
<br>&gt; handle that .<br>&gt;<br>&gt; A--&gt; B --&gt; C--&gt; D --&gt; B<br>&gt;<br>&gt; If A calls&nbsp;&nbsp;B ,<br>&gt;&nbsp;&nbsp; B call fwds to C ,<br>&gt;&nbsp;&nbsp; C call fwds to D ,<br>&gt;&nbsp;&nbsp; D call fwds to B . Now there is a loop .<br>&gt; How does asterisk prevent this loop? I just to know where (as in which
<br>&gt; module in the Asterisk source code) and how is this prevented (that is if a<br>&gt; data structure of all the numbers that it has call fwded to is passed on to<br>&gt; B,C,D so that it can detect a loop)?<br>&gt;
<br>&gt; Thanks. I hope you understand my scenario. Any suggestions are welcome.<br><br>As far I might understand it, Asterisk would basically parse the Via: headers<br>to determine where the call was coming from, and if it detected a loop,
<br>*should* handle that (this does seem like a loop, and not a spiral).<br><br>I&#39;ll have to defer this to the SIP experts and C experts, but basically here<br>is the code that chan_sip.c (at line 13185 of my chan_sip.c file) that checks
<br>for the loop:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Check if this is a loop */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ast_test_flag(&amp;p-&gt;flags[0], SIP_OUTGOING) &amp;&amp; p-&gt;owner &amp;&amp;<br>(p-&gt;owner-&gt;_state != AST_STATE_UP)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* This is a call to ourself.&nbsp;&nbsp;Send ourselves an error code
<br>and stop<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;processing immediately, as SIP really has no good mechanism<br>for<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;being able to call yourself */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* If pedantic is on, we need to check the tags. If they&#39;re
<br>different, this is<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in fact a forked call through a SIP proxy somewhere. */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transmit_response(p, &quot;482 Loop Detected&quot;, req);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p-&gt;invitestate = INV_COMPLETED;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>Leif Madsen.<br></blockquote></div><br><br clear="all"><br>-- <br>Arpit Mehta<br>Graduate Student<br>Department of Computer Science
<br>Columbia University<br><br>Tel: 1-646-387-5998