[Home]

Summary:ASTERISK-11451: Asterisk 1.4 AMI Originate does not sufficiently set CDR(accountcode) on the first call leg
Reporter:Anthony Messina (amessina)Labels:
Date Opened:2008-02-15 15:45:28.000-0600Date Closed:2008-04-25 07:11:53
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/ManagerInterface
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 12007-accountcode.diff
Description:Using Asterisk 1.4.17 and:

Using the AMI as follows (numbers hidden for privacy; Channel number and Exten ARE different):
Action: Originate
Channel: Local/1NXXNXXXXXX@outbound/n
Context: outbound
Exten: 1NXXNXXXXXX
Priority: 1
Account: 12345
Async: True

With the following (initial) part of my dialplan:
[outbound]
exten => _1NXXNXXXXXX,1,Macro(outbound,${EXTEN})

[macro-outbound]
exten => s,1,NoOp(Accountcode is: ${CDR(accountcode)})
exten => s,n,NoOp(Attempting to call ${ARG1} from ${MACRO_CONTEXT} using account code ${CDR(accountcode)})
exten => s,n,Set(ARRAY(CALLERID(num),num,enum-num,enum-domain)="${CDR(accountcode)},${ARG1},+${ARG1},e164.org")

I get the following results (numbers hidden for privacy):
== Parsing '/etc/asterisk/manager.conf': Found
== Manager 'directory' logged on from 127.0.0.1
== Manager 'directory' logged off from 127.0.0.1
-- Executing [1NXXNXXXXXX@outbound:1] Macro("Local/1NXXNXXXXXX@outbound-a6ab,2", "outbound|1NXXNXXXXXX") in new stack
-- Executing [s@macro-outbound:1] NoOp("Local/1NXXNXXXXXX@outbound-a6ab,2", "Accountcode is: ") in new stack
-- Executing [s@macro-outbound:2] NoOp("Local/1NXXNXXXXXX@outbound,2", "Attempting to call 1NXXNXXXXXX from outbound using account code ") in new stack
-- Executing [s@macro-outbound:3] Set("Local/1NXXNXXXXXX@outbound-a6ab,2", "ARRAY(CALLERID(num)|num|enum-num|enum-domain)="|1NXXNXXXXXX|+1NXXNXXXXXX|e164.org"") in new stack

You can see that the CDR(accountcode) variable is not available at call time, for some reason, but it is available when I do "core show channels verbose" during the call and it is correctly placed in the (MySQL) CDR *AFTER* the call completes.

****** ADDITIONAL INFORMATION ******

I am not sure what the problem is.  I am trying to accomplish the following:

Most of the devices on my network are mine, and all share the accountcode=<my_real_pstn_number> setting in their configuration. I have a few devices for which I would like to route calls a bit differently, based on their accountcode.  That's why i thought I'd simplify things and use pstn numbers for the accountcode and would be able to set the outbound Caller*ID to the accountcode.

Now that I'm trying to integrate the AMI into a secured portion of my website, I am not able to do this.

I'd like to keep the callerid="Name" <internal exten> settings in my devices
so internally, we see the extensions instead of a full pstn number.

I do consider this somewhere in between "major" and "minor" as it prevents me from segregating outbound calls to certain routes from the manager.
Comments:By: Jason Parker (jparker) 2008-02-15 15:51:31.000-0600

This may be related to ASTERISK-11431

By: Anthony Messina (amessina) 2008-02-15 16:10:43.000-0600

It seems that in issue 0011986, the details aren't posted to the CDR.  In my case, however, the CDR(accountcode) is posted to the CDR.  It's just not available at call time using ${CDR(accountcode)}, which is what I need for outbound call routing.

Using the '/n' switch does not make a difference (though I'm not sure if it should).

By: Tilghman Lesher (tilghman) 2008-02-15 18:43:55.000-0600

What happens if you use a channel other than the Local channel?

By: Anthony Messina (amessina) 2008-02-15 21:57:20.000-0600

Well, if I use a SIP channel, for example, the first leg of the call won't pass through the outbound macro.  So it's not an issue; the SIP/Zap/IAX2 channel (or whatever) will be local and handled *around* the outbound macro.

What I'm hoping for is the ability to initiate a call to a phone number that *may* exist outside of my box.  If I use the Local channel, I am able to route the call to whatever number I wish, using LCR, etc.  If I simply use a SIP or IAX2 channel, I won't be able to take advantage of things like local numbers, enum, dundi, etc.

Here's my outbound macro, if that will help make sense:
http://messinet.com/node/190

By: Jason Parker (jparker) 2008-04-02 13:44:32

After looking at this again, I'm not sure I see any issue.

You say that the account code is set in the various configuration files, but at the point where you're trying to read the account code, you haven't actually used any of these devices.

Am I missing something?

By: Jason Parker (jparker) 2008-04-02 15:00:05

Patch attached.  With this patch, the CDR accountcode gets set on the source channel.

The question is whether it is correct to do so or not.

By: Anthony Messina (amessina) 2008-04-03 12:46:06

I have a (maybe not so) simple setup where I run a server for various family members.  I will route any internal, local pstn, and e164-dundi calls for free.  After that, I have the dialplan go to using a VoIP provider--each of us has a different account with perhaps different providers--I don't want to set up a billing scheme.

It gets a bit more complicated when I run an ldap/addressbook portion of my website where I have it set to click on a number to originate calls through the AMI.

I want to say, use the voip provider as follows:

voipprovider-123456

where [voipprovider-123456] is defined in sip.conf and 123456 is the accountcode for the family member, usually their pots number for simplification.

this works in the dialplan as they are connecting using devices where i have defined the "accountcode=".  using the manager, however, i can set the accountcode, but i need it to be available as the call processes, so the outbound macro can take advantage of it when it gets to:

Dial(SIP/<dialed-number>@voipprovider-123456)

i DO thank you for your help on this.  perhaps i am crazy and there is a better way (or both) to ensure that i can specify an outgoing trunk based on an accountcode specified in AMI ?

By: Tilghman Lesher (tilghman) 2008-04-21 20:23:03

qwell:  actually, I think that makes perfect sense.  The source channel will never again run ast_cdr_update (in all likelihood), as it's now connected to a Local channel.

amessina:  does this patch solve your issue?

By: Tilghman Lesher (tilghman) 2008-04-21 20:26:21

qwell:  actually, what we may want to do is leave the code alone, except to add a ast_cdr_update(), to force the change.  That also ensures that we copy the value to underlying CDRs, if forked.

By: Anthony Messina (amessina) 2008-04-24 12:32:57

That patch does work. Though I think you're right in note ASTERISK-8343791.

By: Digium Subversion (svnbot) 2008-04-24 14:48:20

Repository: asterisk
Revision: 114621

U   branches/1.4/channels/chan_local.c

------------------------------------------------------------------------
r114621 | tilghman | 2008-04-24 14:48:20 -0500 (Thu, 24 Apr 2008) | 4 lines

Ensure that when we set the accountcode, it actually shows up in the CDR.
(Fix for AMI Originate)
(Closes issue ASTERISK-11451)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=114621

By: Digium Subversion (svnbot) 2008-04-24 14:49:44

Repository: asterisk
Revision: 114622

_U  trunk/
U   trunk/channels/chan_local.c

------------------------------------------------------------------------
r114622 | tilghman | 2008-04-24 14:49:44 -0500 (Thu, 24 Apr 2008) | 12 lines

Merged revisions 114621 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114621 | tilghman | 2008-04-24 14:53:36 -0500 (Thu, 24 Apr 2008) | 4 lines

Ensure that when we set the accountcode, it actually shows up in the CDR.
(Fix for AMI Originate)
(Closes issue ASTERISK-11451)

........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=114622

By: Digium Subversion (svnbot) 2008-04-24 14:50:36

Repository: asterisk
Revision: 114623

_U  branches/1.6.0/
U   branches/1.6.0/channels/chan_local.c

------------------------------------------------------------------------
r114623 | tilghman | 2008-04-24 14:50:35 -0500 (Thu, 24 Apr 2008) | 20 lines

Merged revisions 114622 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
r114622 | tilghman | 2008-04-24 14:54:57 -0500 (Thu, 24 Apr 2008) | 12 lines

Merged revisions 114621 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114621 | tilghman | 2008-04-24 14:53:36 -0500 (Thu, 24 Apr 2008) | 4 lines

Ensure that when we set the accountcode, it actually shows up in the CDR.
(Fix for AMI Originate)
(Closes issue ASTERISK-11451)

........

................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=114623

By: Digium Subversion (svnbot) 2008-04-25 07:11:53

Repository: asterisk
Revision: 114643

_U  team/seanbright/resolve-shadow-warnings/
U   team/seanbright/resolve-shadow-warnings/apps/app_alarmreceiver.c
U   team/seanbright/resolve-shadow-warnings/apps/app_chanspy.c
U   team/seanbright/resolve-shadow-warnings/apps/app_dial.c
U   team/seanbright/resolve-shadow-warnings/apps/app_disa.c
U   team/seanbright/resolve-shadow-warnings/apps/app_externalivr.c
U   team/seanbright/resolve-shadow-warnings/apps/app_followme.c
U   team/seanbright/resolve-shadow-warnings/apps/app_meetme.c
U   team/seanbright/resolve-shadow-warnings/apps/app_queue.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_alsa.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_gtalk.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_h323.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_iax2.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_jingle.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_local.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_mgcp.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_misdn.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_oss.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_sip.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_skinny.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_unistim.c
U   team/seanbright/resolve-shadow-warnings/channels/chan_zap.c
U   team/seanbright/resolve-shadow-warnings/include/asterisk/channel.h
U   team/seanbright/resolve-shadow-warnings/include/asterisk/manager.h
U   team/seanbright/resolve-shadow-warnings/main/channel.c
U   team/seanbright/resolve-shadow-warnings/main/http.c
U   team/seanbright/resolve-shadow-warnings/main/manager.c
U   team/seanbright/resolve-shadow-warnings/res/res_musiconhold.c

------------------------------------------------------------------------
r114643 | seanbright | 2008-04-25 07:11:47 -0500 (Fri, 25 Apr 2008) | 263 lines

Merged revisions 114585,114588,114592,114595,114598,114601,114604,114606,114609,114612,114617,114622,114625,114629,114633,114635,114637 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
r114585 | oej | 2008-04-23 12:53:34 -0400 (Wed, 23 Apr 2008) | 10 lines

Merged revisions 114584 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114584 | oej | 2008-04-23 18:51:41 +0200 (Ons, 23 Apr 2008) | 2 lines

Add 502 support for both directions, not only one...  (see r114571)

........

................
r114588 | russell | 2008-04-23 13:18:29 -0400 (Wed, 23 Apr 2008) | 10 lines

Merged revisions 114587 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114587 | russell | 2008-04-23 12:16:32 -0500 (Wed, 23 Apr 2008) | 2 lines

Fix find_callno_locked() to actually return the callno locked in some more cases.

........

................
r114592 | russell | 2008-04-23 14:01:00 -0400 (Wed, 23 Apr 2008) | 13 lines

Merged revisions 114591 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114591 | russell | 2008-04-23 12:55:31 -0500 (Wed, 23 Apr 2008) | 5 lines

Store the manager session ID explicitly as 4 byte ID instead of a ulong.  The
mansession_id cookie is coded to be limited to 8 characters of hex, and this
could break logins from 64-bit machines in some cases.
(inspired by AST-20)

........

................
r114595 | qwell | 2008-04-23 14:33:28 -0400 (Wed, 23 Apr 2008) | 16 lines

Merged revisions 114594 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114594 | qwell | 2008-04-23 13:28:44 -0500 (Wed, 23 Apr 2008) | 8 lines

Fix reload/unload for res_musiconhold module.

(closes issue ASTERISK-11060)
Reported by: sunder
Patches:
     M11575_14_rev3.diff uploaded by junky (license 177)
     bug11575_trunk.diff.txt uploaded by jamesgolovich (license 176)

........

................
r114598 | russell | 2008-04-23 16:53:05 -0400 (Wed, 23 Apr 2008) | 18 lines

Merged revisions 114597 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114597 | russell | 2008-04-23 15:49:18 -0500 (Wed, 23 Apr 2008) | 10 lines

Fix an issue that caused getting the correct next channel to not always work.
Also, remove setting the amount of time to wait for a digit from 5 seconds back
down to 1/10 of a second.  I believe this was so the beep didn't get played over
and over really fast, but a while back I put in another fix for that issue.

(closes issue ASTERISK-11895)
Reported by: jsmith
Patches:
     app_chanspy_channel_walk.trunk.patch uploaded by jsmith (license 15)

........

................
r114601 | russell | 2008-04-23 18:53:20 -0400 (Wed, 23 Apr 2008) | 14 lines

Merged revisions 114600 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114600 | russell | 2008-04-23 17:18:12 -0500 (Wed, 23 Apr 2008) | 6 lines

Improve some broken cookie parsing code.  Previously, manager login over HTTP
would only work if the mansession_id cookie was first.  Now, the code builds
a list of all of the cookies in the Cookie header.  This fixes a problem
observed by users of the Asterisk GUI.
(closes AST-20)

........

................
r114604 | russell | 2008-04-24 10:55:21 -0400 (Thu, 24 Apr 2008) | 3 lines

Change a verbose message to debug.
(closes issue ASTERISK-11911)

................
r114606 | oej | 2008-04-24 10:59:05 -0400 (Thu, 24 Apr 2008) | 11 lines

Merged revisions 114603 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114603 | oej | 2008-04-24 16:55:18 +0200 (Tor, 24 Apr 2008) | 3 lines

Only have one max-forwards header in outbound REFERs.
Discovered in the Asterisk SIP Masterclass in Orlando. Thanks Joe!

........

................
r114609 | russell | 2008-04-24 11:56:55 -0400 (Thu, 24 Apr 2008) | 12 lines

Merged revisions 114608 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114608 | russell | 2008-04-24 10:55:21 -0500 (Thu, 24 Apr 2008) | 4 lines

Fix a silly mistake in a change I made yesterday that caused chan_iax2 to blow
up very quickly.
(issue ASTERISK-11912)

........

................
r114612 | qwell | 2008-04-24 12:47:01 -0400 (Thu, 24 Apr 2008) | 17 lines

Merged revisions 51989 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

(closes issue ASTERISK-11893)
Reported by: daniele
Patches:
     misdn-moh-1.6.0-beta7.1.patch uploaded by daniele (license 471)
Tested by: daniele

Technically, I didn't use the patch above except to find out what revision to merge - but it's the same thing as this revision.

........
r51989 | crichter | 2007-01-24 06:57:22 -0600 (Wed, 24 Jan 2007) | 1 line

added fix from ASTERISK-8652
........

................
r114617 | tilghman | 2008-04-24 15:24:31 -0400 (Thu, 24 Apr 2008) | 6 lines

Fix DST calculation, and fix bug in calculation of whether conf has started yet or not
(Closes issue ASTERISK-11715)
Reported by: DEA
Patches:
      app_meetme-rt-dst-sched-fix.txt uploaded by DEA (license 3)

................
r114622 | tilghman | 2008-04-24 15:54:57 -0400 (Thu, 24 Apr 2008) | 12 lines

Merged revisions 114621 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114621 | tilghman | 2008-04-24 14:53:36 -0500 (Thu, 24 Apr 2008) | 4 lines

Ensure that when we set the accountcode, it actually shows up in the CDR.
(Fix for AMI Originate)
(Closes issue ASTERISK-11451)

........

................
r114625 | mmichelson | 2008-04-24 16:06:06 -0400 (Thu, 24 Apr 2008) | 18 lines

Merged revisions 114624 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114624 | mmichelson | 2008-04-24 15:04:24 -0500 (Thu, 24 Apr 2008) | 10 lines

Resolve a deadlock in chan_local by releasing the channel lock
temporarily.

(closes issue ASTERISK-11181)
Reported by: callguy
Patches:
     11712.patch uploaded by putnopvut (license 60)
Tested by: acunningham


........

................
r114629 | mmichelson | 2008-04-24 16:43:52 -0400 (Thu, 24 Apr 2008) | 16 lines

Merged revisions 114628 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114628 | mmichelson | 2008-04-24 15:43:03 -0500 (Thu, 24 Apr 2008) | 8 lines

Output of channel variables when eventwhencalled=vars was set
was being truncated two characters. This patch corrects the
problem.

(closes issue ASTERISK-11891)
Reported by: davidw


........

................
r114633 | mmichelson | 2008-04-24 17:35:39 -0400 (Thu, 24 Apr 2008) | 19 lines

Merged revisions 114632 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r114632 | mmichelson | 2008-04-24 16:35:08 -0500 (Thu, 24 Apr 2008) | 11 lines

Re-invite RTP during a masquerade so that, for instance, an AMI
redirect of two channels which are natively bridged will preserve audio
on both channels. This prevents a problem with Asterisk not re-inviting
due to one of the channels having being a zombie.

(closes issue ASTERISK-11910)
Reported by: mneuhauser
Patches:
     asterisk-1.4-114602_restore-RTP-on-fixup.patch uploaded by mneuhauser (license 425)


........

................
r114635 | file | 2008-04-24 18:11:46 -0400 (Thu, 24 Apr 2008) | 4 lines

Hey look, it builds.
(closes issue ASTERISK-11916)
Reported by: falves11

................
r114637 | mvanbaak | 2008-04-24 18:16:48 -0400 (Thu, 24 Apr 2008) | 8 lines

Pass the hangup cause all the way to the calling app/channel.

(closes issue ASTERISK-10842)
Reported by: rain
Patches:
     20071207__pass_cause_in_hangup_control_frame.diff.txt uploaded by Corydon76 (license 14)
brought up-to-date to trunk by me

................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=114643