Change the to sip header

I am currently using Asterisk 16.31.0 , and have a request like this:
Number A called B, and B forward to mobile C,
is there a way to do with pjsip like this:
exten => _X.,n,Dial(SIP/${EXTEN}!123456), this only work with sip .

Need to transfer calls and also tried Add Diversion header ,doesn’t work.

There is no manipulation of most generated headers, such as To, aside from them being set as a result of other values. You can’t do like the chan_sip dial string does.

Adding arbitrary headers does work, as does using the normal REDIRECTING functionality. For help with that you’d need to state what you’re actually using/trying.

I have 2 asterisk (A1, B1) systems. A1 and B1 are connected via SIP TRUNK, and B1 is connected to the operator’s system. When mobile A dials the landline number of system A1, it is then forwarded to mobile C offline by B, and then sent to system B1 and finally to the operator’s system. Now mobile C needs to display the number of mobile A.


need to change the to header to number B.

and if i use exten => _X.,n,Dial(SIP/${EXTEN}!0573123456),it works.

PJSIP does not currently support changing the To header like that. You could submit a feature request[1] if you wish.

[1] GitHub - asterisk/asterisk-feature-requests: A place to submit feature and improvement requests for the Asterisk project. Contains no code.

is there a way i can change the to header from beginning? use dial or other application?
this is what got the sip:

and this is the sip after using dial:

the dialplan is :
‘_95575XXXXXX.’ => 1. Set(p1=${CUT(PJSIP_HEADER(read,Diversion),>,1)})
2. Set(_p2=${CUT(p1,:,2)})
3. Dial(PJSIP/546022${EXTEN:5}@TG1-CTSIP1,60,b(from-sip^callee_handler^1)) [extensions_additional.conf:28]
4. Hangup()

callee_handler’ => 1. NoOp()
2. Set(REDIRECTING(from-num,i)=${p2})
3. Set(REDIRECTING(from-num-pres)=allowed)
4. Return()

The To header is equivalent to the Request URI in PJSIP, and the user portion of that is comprised from the dialed number in the dial string.

is there a way to change the user part before dial?

Dial(PJSIP/546022${EXTEN:5}@TG1-CTSIP1,60,b(from-sip^callee_handler^1))

The dialed number there is what is used in both the Request URI and To URI. You change that, you change them both. You can’t change the To header individually.

is there any other application can do ?
it’s a forward call, and the opretioner want to know weather is a real forward call.and we must sent the orgcallee number

The answer remains no on changing just the To header. Such a thing would require code modifications/functionality added to do so.

Asterisk is a back to back user agent, and client user agents SHOULD set the Request URI to the same as the request To header one, according to the RFC. So, in fact, the dial string contains the To header URI.

It’s using an API in PJProject that is intended for user agents, not proxies.

i have the same question like this post,but not have audio problem.

maybe the right answer is add history-info in sip header,here it is:
exten=> _0X.,n,SIPAddHeader(P-Asserted-Identity: “${CALLERID(num)}” sip:${CALLERID(num)}@112.25.x.x)
exten=> _0X.,n,SIPAddHeader(History-Info: sip:${EXTEN}@112.25.x.x;index=1.1)
exten=> _0X.,n,SIPAddHeader(History-Info: sip:05278079xxxx@112.25.x.x;index=1)
exten=> _0X.,n,dial(sip/${EXTEN})

i found asterisk 18 origian support history-info,is there easy way i can add history-info ?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.