If the INVITE comes in from Asterisk, OpenSER replies with 480 and lets Asterisk deal with sending call to voicemail (e.g. dialstatus = unavailable). This eliminates the loop because the INVITE does not come back to Asterisk.<br>
<br><div class="gmail_quote">On Fri, Apr 11, 2008 at 12:33 AM, Iñaki Baz Castillo &lt;<a href="mailto:ibc@in.ilimit.es">ibc@in.ilimit.es</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
El Thursday 10 April 2008 23:00:28 Adrian A escribió:<br>
<div class="Ih2E3d">&gt; Here is how I solve this.<br>
&gt;<br>
&gt; In Asterisk, I add a SIP header just before sending it to OpenSER using the<br>
&gt; function: SipAddHeader(P-hint: From Asterisk).<br>
&gt;<br>
&gt; Then, in OpenSER I have the following:<br>
&gt;<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # check to see if user is online<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!lookup(&quot;location&quot;)) {<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # SIP from Asterisk or not a call attempt<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (search(&quot;(P-hint):.From Asterisk&quot;) ||<br>
&gt; !(method==INVITE)) { sl_send_reply(&quot;480&quot;,&quot;User Temporarily Unavailable&quot;);<br>
&gt; exit;<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; route(2);<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit;<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<br>
&gt;<br>
&gt; route[2] {<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Let Asterisk deal with voicemail/forward<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sl_send_reply(&quot;181&quot;, &quot;Forward to Voicemail&quot;);<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prefix(&quot;vm&quot;);<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setflag(9);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # forward to Asterisk<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; route(1);<br>
&gt; }<br>
<br>
</div>I can&#39;t understand why that should work, in fact Asterisk is receiving the<br>
same INVITE he sent (well, RURI modified but the Asterisk bug is that it<br>
doesn&#39;t recogniza a spiral).<br>
<div class="Ih2E3d"><br>
<br>
--<br>
Iñaki Baz Castillo<br>
<a href="mailto:ibc@in.ilimit.es">ibc@in.ilimit.es</a><br>
_______________________________________________<br>
</div><div><div></div><div class="Wj3C7c">Users mailing list<br>
<a href="mailto:Users@lists.openser.org">Users@lists.openser.org</a><br>
<a href="http://lists.openser.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.openser.org/cgi-bin/mailman/listinfo/users</a><br>
</div></div></blockquote></div><br>