Incoming call to an extension which is forwarded out

Hi all,

asterisk-1.2.9.1

Im trying to implement a whitelist on outgoing trunk.

I have a problem that when an extension is forwarded to a trunk I don’t have a reference to the extension that did the forwarding thus I cannot check in the list of allowed users. When the dialparties.agi detects that the incoming call is forwarded, the dial command is invoked. (I tried to set the CALLERIDNUM but no cigar,see below.) When my inlist.agi is invoked I don’t seem to have a reference to the extension that did the forwarding.

The trace below is an incoming call to 20531629 from 20531627 via a trunk. 20531629 is a DID to 629. 629 is forwarded out to 90152516241.

any ideas on how I can get the extension that did the forwarding?

Is a ‘dial’ a bran new instance of a call where I only have the callerid as the reference? If so this is bad.

[macro-dial]
exten => s,1,AGI,dialparties.agi
exten => s,2,NoOp(Returned from dialparties with no extensions to call)
exten => s,3,Set(DIALSTATUS=BUSY)
exten => s,10,Set(CALLERIDNUM=2233)
exten => s,11,Dial(${ds})

[outrt-001-kbonly]
exten => 90152516241,1(booger),Noop(${BLINDTRANSFER})
exten => 90152516241,n(booger),Noop(${FAX_RX})
exten => 90152516241,n(booger),Noop(${MACRO_EXTEN})
exten => 90152516241,n,AGI(inlist.agi,1,${CALLERIDNUM},inlist,direct)
exten => 90152516241,n(playcannot),Playback(sorry-cant-let-you-do-that)
exten => 90152516241,n,Hangup
exten => 90152516241,n(direct),Macro(dialout-trunk,1,${EXTEN:1},)
exten => 90152516241,n,Macro(outisbusy,)

Output log:

-- Executing Set("Zap/2-1", "CALLERIDNUM=2233") in new stack
-- Executing Dial("Zap/2-1", "Local/90152516241@from-internal|15|trT") in new stack
-- Called 90152516241@from-internal
-- Executing NoOp("Local/90152516241@from-internal-1686,2", "") in new stack
-- Executing NoOp("Local/90152516241@from-internal-1686,2", "620") in new stack
-- Executing NoOp("Local/90152516241@from-internal-1686,2", "") in new stack
-- Executing AGI("Local/90152516241@from-internal-1686,2", "inlist.agi|1|20531627|inlist|direct") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/inlist.agi

inlist.agi|1|20531627|inlist|direct: hello world from [1, 20531627, inlist, direct ]
inlist.agi|1|20531627|inlist|direct: got [agi_request: inlist.agi]
inlist.agi|1|20531627|inlist|direct: got [agi_channel: Local/90152516241@from-internal-1686,2]
inlist.agi|1|20531627|inlist|direct: got [agi_language: en]
inlist.agi|1|20531627|inlist|direct: got [agi_type: Local]
inlist.agi|1|20531627|inlist|direct: got [agi_uniqueid: 1151572851.905]
inlist.agi|1|20531627|inlist|direct: got [agi_callerid: 20531627]
inlist.agi|1|20531627|inlist|direct: got [agi_calleridname: unknown]
inlist.agi|1|20531627|inlist|direct: got [agi_callingpres: 0]
inlist.agi|1|20531627|inlist|direct: got [agi_callingani2: 0]
inlist.agi|1|20531627|inlist|direct: got [agi_callington: 0]
inlist.agi|1|20531627|inlist|direct: got [agi_callingtns: 0]
inlist.agi|1|20531627|inlist|direct: got [agi_dnid: unknown]
inlist.agi|1|20531627|inlist|direct: got [agi_rdnis: unknown]
inlist.agi|1|20531627|inlist|direct: got [agi_context: from-internal]
inlist.agi|1|20531627|inlist|direct: got [agi_extension: 90152516241]
inlist.agi|1|20531627|inlist|direct: got [agi_priority: 4]
inlist.agi|1|20531627|inlist|direct: got [agi_enhanced: 0.0]
inlist.agi|1|20531627|inlist|direct: got [agi_accountcode: ]

… man finally found the solution.

this page voip-info.org/wiki-Asterisk+variables “Inheritance of Channel Variables” discribes the problem. When a variable is set and a dial is invoked the dialled instance gets a “clean slate”. However if a variable is prefixed with ‘_’ or ‘’ then it is passed on to the child(ren). So all I had to do was define a variable preifxed with '’ containing the extension then the dialplan from subsequent dials will have access to this variable ie

exten => 629,n,Set(__SN_EXT_NUM=629)
then in a child dialplan I just use SN_EXT_NUM.

sorry for any inconvenience :blush: