[asterisk-users] PJSIP_HEADER - Diversion header manipulation
Davor Jovanovic
davor.jovanovic at srce.hr
Mon Dec 10 04:02:33 CST 2018
Hi all,
I’m trying to rewrite Diversion header when call forwarding is done on
the phone. The phone sends "302 Moved Temporarily" response and sets
Diversion header to a local number, but before Asterisk sends this call
towards TSP provider I need to change Diversion header to a full PSTN
number. I am using PJSIP_HEADER in a pre-dial handler (configuration is
below). On the same call I can add some other custom headers (logs are
below).
Is there any chance I can rewrite Diversion header in this scenario with
PJSIP_HEADER function? Asterisk version is 16.0.1 built from source on
Debian 9.
Thank you
Davor
# Outgoing context - TSP provider
[outgoing]
exten =>
0123456789,1,Dial(PJSIP/${EXTEN}@${SBC_1},,b(add_diversion^FWDdiver^1))
same => n,Hangup()
# Diversion manipulation context
[add_diversion]
exten =>
FWDdiver,1,Set(PJSIP_HEADER(add,Diversion)=<sip:full_pstn_no at example.com>\;reason=unconditional\;screen=yes\;privacy=off))
exten =>
FWDdiver,2,Set(PJSIP_HEADER(add,CustomOne)=<sip:custom_one at example.com>\;reason=unconditional\;screen=yes\;privacy=off))
exten =>
FWDdiver,3,Set(PJSIP_HEADER(add,CustomTwo)=<sip:custom_two at example.com>\;reason=unconditional\;screen=yes\;privacy=off))
exten => FWDdiver,4,Return()
Asterisk*CLI>
-- Now forwarding PJSIP/527-00000168 to 'Local/0123456789 at outgoing'
(thanks to PJSIP/836-00000169)
[Dec 10 10:25:08] NOTICE[26309][C-000000c0]: app_dial.c:1005 do_forward:
Not accepting call completion offers from call-forward recipient
Local/0123456789 at outgoing-0000002c;1
-- Executing [0123456789 at outgoing:1]
Dial("Local/0123456789 at outgoing-0000002c;2",
"PJSIP/0123456789 at SBC1,,b(add_diversion^FWDdiver^1)") in new stack
-- PJSIP/SBC1-0000016a Internal Gosub(add_diversion,FWDdiver,1) start
-- Executing [FWDdiver at add_diversion:1] Set("PJSIP/SBC1-0000016a",
"PJSIP_HEADER(add,Diversion)=<sip:full_pstn_no at example.com>;reason=unconditional;screen=yes;privacy=off)")
in new stack
-- Executing [FWDdiver at add_diversion:2] Set("PJSIP/SBC1-0000016a",
"PJSIP_HEADER(add,CustomOne)=<sip:custom_one at example.com>;reason=unconditional;screen=yes;privacy=off)")
in new stack
-- Executing [FWDdiver at add_diversion:3] Set("PJSIP/SBC1-0000016a",
"PJSIP_HEADER(add,CustomTwo)=<sip:custom_two at example.com>;reason=unconditional;screen=yes;privacy=off)")
in new stack
-- Executing [FWDdiver at add_diversion:4]
Return("PJSIP/SBC1-0000016a", "") in new stack
Phone => Asterisk
U 10.201.8.192:5060 -> 10.201.1.19:5060
SIP/2.0 302 Moved Temporarily.
Diversion: <sip:836 at 10.201.1.19>;reason=unconditional.
Asterisk => TSP provider
U 10.201.1.19:5060 -> 10.201.1.15:5060
CustomOne:
<sip:custom_one at example.com>;reason=unconditional;screen=yes;privacy=off.
CustomTwo:
<sip:custom_two at example.com>;reason=unconditional;screen=yes;privacy=off.
Diversion: <sip:836 at 192.168.1.101>;reason=unconditional.
More information about the asterisk-users
mailing list