Benoit Panizzon
2019-Nov-15 14:05 UTC
[asterisk-users] pre-dial handler, how to access variables from calling channel?
Hi List
Implementing screening and routing I have stumbled over this issue:
[pbx-router]
exten => s,1,NoOp(ROUTER FROM: ${CALLERID(Number)} TO: ${DESTINATION})
same => n,Set(SOURCE=${CHANNEL(name)})
same => n,Set(PAI=${PJSIP_HEADER(read,P-Asserted-Identity)})
same => n,Set(FROM=${CALLERID(Number)})
same => n,Set(TO=${DESTINATION})
same => n,Set(DIVERSION=${PJSIP_HEADER(read,Diversion)})
same => n,AGI(router.agi)
same => n,GoTo(dial-out,s,1)
[predial-handler]; Manipulate Header on OUTBOUND channel
exten => screen-update,1,NoOp(PREDIAL FROM: ${CALLERID(Number)} TO:
${DESTINATION} PAI: ${PAI})
same => n,Set(PJSIP_HEADER(update,P-Asserted-Identity)=${PAI})
same => n,Return
[dial-out]
exten => s,1,NoOp(DIAL FROM: ${CALLERID(Number)} TO: ${DESTINATION} PAI:
${PAI})
same =>
n,Dial(PJSIP/${DESTINATION},,b(predial-handler,screen-update,1))
same => n,HangUp()
router.agi does perform among other things like emergency
location routing: _screening_. It checks if the FROM and PAI sent from
the customer correspond to phone numbers assigned to that customer and
if not, replaces them with the correct values, also taking account
customers with clip-no-screening agreement (they can set 'From' maybe
also screened to some allowed number ranges, but PAI is 'Provider
provided, Network screened' therefore we MUST set this to the customers
real phone number)
I can correct ${CALLERID(number)} on the calling channel and this is
preserved on the outgoing channel.
But I have not yet found any 'easy' way to pass the corrected ${PAI}
Variable to the callee channel.
Mit freundlichen Grüssen
-Benoît Panizzon-
--
I m p r o W a r e A G - Leiter Commerce Kunden
______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00
CH-4133 Pratteln Fax +41 61 826 93 01
Schweiz Web http://www.imp.ch
______________________________________________________
Tony Mountifield
2019-Nov-15 14:27 UTC
[asterisk-users] pre-dial handler, how to access variables from calling channel?
In article <20191115150532.53eb10e2 at go.imp.ch>, Benoit Panizzon <benoit.panizzon at imp.ch> wrote:> Hi List > > Implementing screening and routing I have stumbled over this issue: > > [pbx-router] > exten => s,1,NoOp(ROUTER FROM: ${CALLERID(Number)} TO: ${DESTINATION}) > same => n,Set(SOURCE=${CHANNEL(name)}) > same => n,Set(PAI=${PJSIP_HEADER(read,P-Asserted-Identity)}) > .... > > But I have not yet found any 'easy' way to pass the corrected ${PAI} > Variable to the callee channel.Try changing PAI to __PAI when setting: same => n,Set(__PAI=${PJSIP_HEADER(read,P-Asserted-Identity)}) When setting a variable, if you prepend a single underscore, e.g. "_PAI", the variable will be inherited by any channels created by the current channel (child channels), but will not be inherited further (it is effectively created as "PAI", which is then non-inheritable). If you prepend two underscores, e.g. "__PAI", the variable will be inherited by child channels, and will then be further inherited by grandchild channels and so on (it is effectively created as "__PAI" each time). You don't need to speficy the __ when reading the variable, just use ${PAI} as before. See https://wiki.asterisk.org/wiki/display/AST/Variable+Inheritance Cheers Tony -- Tony Mountifield Work: tony at softins.co.uk - http://www.softins.co.uk Play: tony at mountifield.org - http://tony.mountifield.org
Benoit Panizzon
2019-Nov-18 12:28 UTC
[asterisk-users] pre-dial handler, how to access variables from calling channel?
Hi Tony> See https://wiki.asterisk.org/wiki/display/AST/Variable+InheritanceThank you, exactly what I was looking for! Mit freundlichen Grüssen -Benoît Panizzon- -- I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________ Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________
Maybe Matching Threads
- Perl AGI: read variable with quotes
- Global number rewriting rules affecting ALL headers?
- On Register, run a script, validate source IP
- Global number rewriting rules affecting ALL headers?
- pjsip: How is asterisk choosing the IP address to put in the Contact header?