<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body>
<p>Greetings!</p>
<p><span>I have the following line in features.conf:</span><br /><span>parse =&gt; *9,peer/both,AGI,/etc/asterisk/agi/map.pl</span></p>
<p>What that script does is parsing AGI variables and doing some things based on them, nothing special.</p>
<p><span>During outgoing call, those variables get messed up. Let's look at an example: number 404 calls 2010000, it is being routed over PRI line. When 'agi debug' is active, one can see what parameters are being fed to script:</span></p>
<p><span></span><span>AGI Tx &gt;&gt; agi_request: /etc/asterisk/agi/map.pl</span><br /><span>AGI Tx &gt;&gt; agi_channel: Zap/63-1</span><br /><span>AGI Tx &gt;&gt; agi_language: en</span><br /><span>AGI Tx &gt;&gt; agi_type: Zap</span><br /><span>AGI Tx &gt;&gt; agi_uniqueid: 1322049810.4307</span><br /><span>AGI Tx &gt;&gt; agi_callerid: 0442010000</span><br /><span>AGI Tx &gt;&gt; agi_calleridname: unknown</span><br /><span>AGI Tx &gt;&gt; agi_callingpres: 3</span><br /><span>AGI Tx &gt;&gt; agi_callingani2: 0</span><br /><span>AGI Tx &gt;&gt; agi_callington: 0</span><br /><span>AGI Tx &gt;&gt; agi_callingtns: 0</span><br /><span>AGI Tx &gt;&gt; agi_dnid: 481</span><br /><span>AGI Tx &gt;&gt; agi_rdnis: unknown</span><br /><span>AGI Tx &gt;&gt; agi_context: from_pstn</span><br /><span>AGI Tx &gt;&gt; agi_extension:</span><br /><span>AGI Tx &gt;&gt; agi_priority: 1</span><br /><span>AGI Tx &gt;&gt; agi_enhanced: 0.0</span><br /><span>AGI Tx &gt;&gt; agi_accountcode:</span><br /><br /><span>Looking at the callerid and dnid being swapped, one can say that for some reason Asterisk sees this call as incoming from PRI (context kind of approves this). I gave it lots of thinking, and the only conclusion I could come to was - it's because I run my application on 'peer'. But it's not a problem, as I could just swap them back in my script. The problem is, as you can see, our dnid is 481, however we are calling from 404. And moreover - each time I try to call, I get different dnid, like 401, 408 and so on. I thought that it could be last called number on PRI - but it is not.</span><br /><span>If the call is really incoming (comes from PSTN) - all variables get passed correctly, and my script is happy. When I issue 'show channel' command during active call, I see that variables are incorrect in Asterisk on A-leg (i.e. SIP/404-someid), and variables are correct on B-leg (i.e. ZAP/63-1 in our example).</span></p>
<p>Is that some bug, or misconfiguration, or maybe wrong programming?</p>
<p>&nbsp;</p>
<div>
<pre><span class="sig"><span style="color: #999999;">-- </span><br /><span style="color: #999999;">With Best Regards</span><br /><span style="color: #999999;"><a title="mailto:mlischuk@itx.com.ua" href="mailto:mlischuk@itx.com.ua">Mikhail Lischuk</a></span><span style="color: #999999;"><br /></span></span></pre>
</div>
</body></html>