[asterisk-users] PJSIP_HEADER - Diversion header manipulation

John Kiniston johnkiniston at gmail.com
Mon Dec 10 11:23:27 CST 2018


Davor,

Have you attempted to do a Set(PJSIP_HEADER(remove,Diversion)=)) in your
add_diversion context to remove the header Asterisk is passing through?

On Mon, Dec 10, 2018 at 3:04 AM Davor Jovanovic <davor.jovanovic at srce.hr>
wrote:

> 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.
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> Check out the new Asterisk community forum at:
> https://community.asterisk.org/
>
> New to Asterisk? Start here:
>       https://wiki.asterisk.org/wiki/display/AST/Getting+Started
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users



-- 
A human being should be able to change a diaper, plan an invasion, butcher
a hog, conn a ship, design a building, write a sonnet, balance accounts,
build a wall, set a bone, comfort the dying, take orders, give orders,
cooperate, act alone, solve equations, analyze a new problem, pitch manure,
program a computer, cook a tasty meal, fight efficiently, die gallantly.
Specialization is for insects.
---Heinlein
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20181210/e1c42892/attachment.html>


More information about the asterisk-users mailing list