<div dir="ltr"><div dir="ltr"><div>Davor,<br><br></div>Have you attempted to do a Set(PJSIP_HEADER(remove,Diversion)=)) in your add_diversion context to remove the header Asterisk is passing through?<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 10, 2018 at 3:04 AM Davor Jovanovic <<a href="mailto:davor.jovanovic@srce.hr">davor.jovanovic@srce.hr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
I’m trying to rewrite Diversion header when call forwarding is done on <br>
the phone. The phone sends "302 Moved Temporarily" response and sets <br>
Diversion header to a local number, but before Asterisk sends this call <br>
towards TSP provider I need to change Diversion header to a full PSTN <br>
number. I am using PJSIP_HEADER in a pre-dial handler (configuration is <br>
below). On the same call I can add some other custom headers (logs are <br>
below).<br>
<br>
Is there any chance I can rewrite Diversion header in this scenario with <br>
PJSIP_HEADER function? Asterisk version is 16.0.1 built from source on <br>
Debian 9.<br>
<br>
<br>
Thank you<br>
<br>
Davor<br>
<br>
<br>
# Outgoing context - TSP provider<br>
[outgoing]<br>
exten => <br>
0123456789,1,Dial(PJSIP/${EXTEN}@${SBC_1},,b(add_diversion^FWDdiver^1))<br>
  same => n,Hangup()<br>
<br>
# Diversion manipulation context<br>
[add_diversion]<br>
exten => <br>
FWDdiver,1,Set(PJSIP_HEADER(add,Diversion)=<<a href="mailto:sip%3Afull_pstn_no@example.com" target="_blank">sip:full_pstn_no@example.com</a>>\;reason=unconditional\;screen=yes\;privacy=off))<br>
exten => <br>
FWDdiver,2,Set(PJSIP_HEADER(add,CustomOne)=<<a href="mailto:sip%3Acustom_one@example.com" target="_blank">sip:custom_one@example.com</a>>\;reason=unconditional\;screen=yes\;privacy=off))<br>
exten => <br>
FWDdiver,3,Set(PJSIP_HEADER(add,CustomTwo)=<<a href="mailto:sip%3Acustom_two@example.com" target="_blank">sip:custom_two@example.com</a>>\;reason=unconditional\;screen=yes\;privacy=off))<br>
exten => FWDdiver,4,Return()<br>
<br>
<br>
Asterisk*CLI><br>
    -- Now forwarding PJSIP/527-00000168 to 'Local/0123456789@outgoing' <br>
(thanks to PJSIP/836-00000169)<br>
[Dec 10 10:25:08] NOTICE[26309][C-000000c0]: app_dial.c:1005 do_forward: <br>
Not accepting call completion offers from call-forward recipient <br>
Local/0123456789@outgoing-0000002c;1<br>
     -- Executing [0123456789@outgoing:1] <br>
Dial("Local/0123456789@outgoing-0000002c;2", <br>
"PJSIP/0123456789@SBC1,,b(add_diversion^FWDdiver^1)") in new stack<br>
     -- PJSIP/SBC1-0000016a Internal Gosub(add_diversion,FWDdiver,1) start<br>
     -- Executing [FWDdiver@add_diversion:1] Set("PJSIP/SBC1-0000016a", <br>
"PJSIP_HEADER(add,Diversion)=<<a href="mailto:sip%3Afull_pstn_no@example.com" target="_blank">sip:full_pstn_no@example.com</a>>;reason=unconditional;screen=yes;privacy=off)") <br>
in new stack<br>
     -- Executing [FWDdiver@add_diversion:2] Set("PJSIP/SBC1-0000016a", <br>
"PJSIP_HEADER(add,CustomOne)=<<a href="mailto:sip%3Acustom_one@example.com" target="_blank">sip:custom_one@example.com</a>>;reason=unconditional;screen=yes;privacy=off)") <br>
in new stack<br>
     -- Executing [FWDdiver@add_diversion:3] Set("PJSIP/SBC1-0000016a", <br>
"PJSIP_HEADER(add,CustomTwo)=<<a href="mailto:sip%3Acustom_two@example.com" target="_blank">sip:custom_two@example.com</a>>;reason=unconditional;screen=yes;privacy=off)") <br>
in new stack<br>
     -- Executing [FWDdiver@add_diversion:4] <br>
Return("PJSIP/SBC1-0000016a", "") in new stack<br>
<br>
<br>
Phone => Asterisk<br>
U <a href="http://10.201.8.192:5060" rel="noreferrer" target="_blank">10.201.8.192:5060</a> -> <a href="http://10.201.1.19:5060" rel="noreferrer" target="_blank">10.201.1.19:5060</a><br>
SIP/2.0 302 Moved Temporarily.<br>
Diversion: <<a href="mailto:sip%3A836@10.201.1.19" target="_blank">sip:836@10.201.1.19</a>>;reason=unconditional.<br>
<br>
<br>
Asterisk => TSP provider<br>
U <a href="http://10.201.1.19:5060" rel="noreferrer" target="_blank">10.201.1.19:5060</a> -> <a href="http://10.201.1.15:5060" rel="noreferrer" target="_blank">10.201.1.15:5060</a><br>
CustomOne: <br>
<<a href="mailto:sip%3Acustom_one@example.com" target="_blank">sip:custom_one@example.com</a>>;reason=unconditional;screen=yes;privacy=off.<br>
CustomTwo: <br>
<<a href="mailto:sip%3Acustom_two@example.com" target="_blank">sip:custom_two@example.com</a>>;reason=unconditional;screen=yes;privacy=off.<br>
Diversion: <<a href="mailto:sip%3A836@192.168.1.101" target="_blank">sip:836@192.168.1.101</a>>;reason=unconditional.<br>
<br>
-- <br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" rel="noreferrer" target="_blank">http://www.api-digital.com</a> --<br>
<br>
Check out the new Asterisk community forum at: <a href="https://community.asterisk.org/" rel="noreferrer" target="_blank">https://community.asterisk.org/</a><br>
<br>
New to Asterisk? Start here:<br>
      <a href="https://wiki.asterisk.org/wiki/display/AST/Getting+Started" rel="noreferrer" target="_blank">https://wiki.asterisk.org/wiki/display/AST/Getting+Started</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
   <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" rel="noreferrer" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a></blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">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.<br>---Heinlein</div>