PJSIP how do I add a Prefix only to INVITE and not to the "To" header

Oure current provider vant that we send a INVITE with a prefix but that prefix should not be part of the To: header

provider request that we add a prefix “03” to INVITE, but I cant find any options to set INVITE to something else

like this PREFIX=03

INVITE sip:034588888888@1.2.1.1;user=phone SIP/2.0
From: <sip:+4511111111@tdc-sbg-2.uni-tel.dk;user=phone>;tag=f364b7c9-8ac7-4886-a737-1e0f0d037340
To: <sip:+4588888888@1.2.1.1;user=phone>

have tried to use these, with no luck

[default|
Dial(PJSIP/accout1/sip: ${PREFIX}{NUMBER}@${REMOTE_IP})
[default|
Dial(PJSIP/${PREFIX}{NUMBER}@accout1/!+${NUMBER})

https://blog.michael.kuron-germany.de/2014/10/asterisk-change-number-in-to-header/

[default|
Dial(PJSIP/${PREFIX}{NUMBER}@accout1,,b(Dial_Handler))

[Dial_Handler]
Set(PJSIP_HEADER(add,To)=+${NUMBER})
Set(PJSIP_HEADER(add,INVITE)=${PREFIX}{${NUMBER})

My understanding is that chan_pjsip only supports the standards recommended method of setting To: and the request URI to the same value, when originating a call.

As you can see, from rfc3261 your ITSP is requiring you to violate a SHOULD level requirement of the SIP RFC, so they cannot expect their service to work with an arbitrary SIP client.

3 Likes

Indeed, there is no ability that I can think of currently to set them differently.

Thanks for the quick answer
I will contact our TSP and tell the to provide documentation to where in the RFC that state INVITE and To is allowed to differ
as according to rfc3261 it violate a SHOULD level requirement

#section-8.1.1.1
"The initial Request-URI of the message SHOULD be set to the value of the URI in the To field. "

section-12.2.1.1
“The URI in the To field of the request MUST be set to the remote URI from the dialog state.”