[asterisk-bugs] [Asterisk 0017138]: CallerID not properly set when using Originate and AGI
Asterisk Bug Tracker
noreply at bugs.digium.com
Thu Jul 22 16:23:39 CDT 2010
A NOTE has been added to this issue.
======================================================================
https://issues.asterisk.org/view.php?id=17138
======================================================================
Reported By: kobaz
Assigned To: jpeeler
======================================================================
Project: Asterisk
Issue ID: 17138
Category: Channels/chan_iax2
Reproducibility: always
Severity: minor
Priority: normal
Status: acknowledged
Target Version: 1.6.2.11
Asterisk Version: SVN
JIRA: SWP-1534
Regression: No
Reviewboard Link:
SVN Branch (only for SVN checkouts, not tarball releases): N/A
SVN Revision (number only!):
Request Review:
======================================================================
Date Submitted: 2010-04-05 16:03 CDT
Last Modified: 2010-07-22 16:23 CDT
======================================================================
Summary: CallerID not properly set when using Originate and
AGI
Description:
Dialplan:
context Dialer_DialPhone {
s => {
if ("${PhoneAutoAnswer}" == "1") {
SIPAddHeader(Call-Info: answer-after=0');
SIPAddHeader(alert-info: alert-autoanswer');
}
Set(CALLERID(name)=${DstCallerIdName});
Set(CALLERID(num)=${DstCallerIdNum});
Dial(${PhoneDevice},10);
Hangup();
}
}
context Dialer_DialNumber {
s => {
Set(CALLERID(name)=${SrcCallerIdName});
Set(CALLERID(num)=${SrcCallerIdNum});
// Dial(IAX2/out-tipton-local/${DstNumber},120,r); // this works
goto ${PhoneClassOfService}, ${DstNumber}, 1; // this doesn't
Hangup();
}
}
You should be able to override the callerid even if the call will be sent
to an agi script.
Note that agi_callerid and agi_calleridname are actually correct as set in
the dialplan.. but when the agi executes the Dial... callerid gets sent out
as "s <s>" as shown in the iax debug.
Note that callerid is not changed by the agi script.
If you replace the goto, with the Dial() straight from dialplan, CALLING
NUMBER and CALLING NAME will be correct in the iax call.
======================================================================
----------------------------------------------------------------------
(0124881) kobaz (reporter) - 2010-07-22 16:23
https://issues.asterisk.org/view.php?id=17138#c124881
----------------------------------------------------------------------
Here's the scenerio:
I want to call Phone A: SIP/201 (PhoneDevice), and have the callerid of
"Company <1164>" show up on this phone (DstCallerIdName/Num)
I want the other leg to call IAX/tipton-local/3007 (DstNumber), and have
the callerid of "FooBarInc <8005551120>" (SrcCallerIdName/Num) show up on
the other end
----------------------
Dialplan
----------------------
context Dialer_DialPhone {
s => {
Set(CALLERID(name)=${DstCallerIdName});
Set(CALLERID(num)=${DstCallerIdNum});
Dial(${PhoneDevice},10);
Hangup();
}
}
context Dialer_DialNumber {
s => {
Set(CALLERID(name)=${SrcCallerIdName});
Set(CALLERID(num)=${SrcCallerIdNum});
Dial(IAX2/tipton-local/${DstNumber});
Hangup();
}
}
----------------------
AMI
----------------------
Username: admin
Secret: admin
Events: off
Action: Login
Exten: s
CallerID: FooBarInc <8005551120>
Async: true
Channel: Local/s at Dialer_DialPhone
Context: Dialer_DialNumber
Action: Originate
Priority: 1
Timeout: 10000
Variable:
DstCallerIdName=Company,DstCallerIdNum=1164,DstNumber=3007,PhoneAutoAnswer=1,PhoneDevice=SIP/201,SrcCallerIdName=FooBarInc,SrcCallerIdNum=8005551120
The above works fine... appropriate devices are dialed, callerids are set
right..
===========================
===========================
===========================
Replace Dialer_DialNumber with:
context Dialer_DialNumber {
s => {
Set(CALLERID(name)=${SrcCallerIdName});
Set(CALLERID(num)=${SrcCallerIdNum});
AGI(agiTest.pl);
Hangup();
}
}
And you have a simple agi script:
agiTest.pl
----------
#!/usr/bin/perl
$| = 1;
my $agi;
sub getVar {
my ($var) = @_;
print STDOUT "GET FULL VARIABLE \${$var}\n";
my $val = <STDIN>; chomp($val); $val =~ (/\((.*)\)/); $val = $1;
return $val;
}
sub setVar {
my ($var, $val) = @_;
print STDOUT "SET VARIABLE $var \"$val\"\n";
my $val = <STDIN>;
return $val;
}
while (<STDIN>) {
chomp();
last if (!length($_));
if (/^agi_(\w+)\:\s+(.*)$/) { $agi->{$1} = $2; }
}
sleep(5); # <--- delay until local channel is cleaned up... comment this
out and callerid will be sent
my $dstNumber = getVar('DstNumber');
#my $srcCallerIdName = getVar('SrcCallerIdName'); # <--- uncomment these,
and callerid will always be correct
#setVar('CALLERID(name)', $srcCallerIdName);
#my $srcCallerIdNum = getVar('SrcCallerIdNum');
#setVar('CALLERID(num)', $srcCallerIdNum);
print STDOUT "EXEC Dial IAX2/tipton-local/$dstNumber\n";
--------------------------
I've figured out what's happening... the local channel that the agi is
running on, goes away and gets converted to SIP/201... and now you've lost
callerid information that was originally set.
Issue History
Date Modified Username Field Change
======================================================================
2010-07-22 16:23 kobaz Note Added: 0124881
======================================================================
More information about the asterisk-bugs
mailing list