SipAddHeader() not working

Hello,

my SIP Trunk Provider needs the Caller ID to be transferred as P-Prefered-Identity.

To achieve this, i’ve added the following lines to extensions_custom.conf:

[macro-dialout-trunk-predial-hook]
exten => s,1,SipAddHeader(P-Preferred-Identity:sip:[email protected])
exten => s,n,MacroExit()

Asterisk shows these modification in logfiles too:

Executing [[email protected]:1] SIPAddHeader(“PJSIP/374-0000002d”, “P-Preferred-Identity:sip:[email protected]”) in new stack
Executing [[email protected]:2] MacroExit(“PJSIP/374-0000002d”, “”) in new stack

But when I’m tcpdumping these packets, none of the invites to sipgate do contain the p-preferred-identity:

When searching Wireshark for any packets containing the preferred identity, no results, the header wasn’t added.

I have no clue why.

You can’t use SIPAddHeader with PJSIP channels. See this thread:

Thanks,

I’ve tried the following:

[macro-dialout-trunk-predial-hook]
exten => s,1,Set(PJSIP_HEADER(add,P-Preferred-Identity)=sip:[email protected])
exten => s,n,MacroExit()

But it’s still not working. Anyhow, we will use our own Trunk now, making Sipgate (and the header adding) more or less needless.

Thanks for your help.

No, you can’t add SIP headers to a pjsip channel that way. The proper method is noted in the link above.

The other solution is to switch this trunk back to a Chan-SIP connection. Then your SipAddHeader() call will actually work because it is part of the right interface stack.